package com.sap.mdm.examples; import com.sap.mdm.commands.CommandException; import com.sap.mdm.commands.GetRepositoryRegionListCommand; import com.sap.mdm.data.RegionProperties; import com.sap.mdm.net.ConnectionException; import com.sap.mdm.net.ConnectionPool; import com.sap.mdm.net.ConnectionPoolFactory; import com.sap.mdm.server.DBMSType; import com.sap.mdm.server.RepositoryIdentifier; /* * Copyright © 2004-2006 by SAP AG. * All Rights Reserved. * * SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP * products and services mentioned herein as well as their respective logos are * trademarks or registered trademarks of SAP AG in Germany and in several other * countries all over the world. All other product and service names mentioned * are the trademarks of their respective companies. Data contained in this * document serves informational purposes only. National product specifications * may vary. * * These materials are subject to change without notice. These materials are * provided by SAP AG and its affiliated companies (SAP Group) for informational * purposes only, without representation or warranty of any kind, and SAP Group * shall not be liable for errors or omissions with respect to the materials. * The only warranties for SAP Group products and services are those that are * set forth in the express warranty statements accompanying such products and * services, if any. Nothing herein should be construed as constituting an * additional warranty. * */ /** * This example demonstrates retrieving the list of languages (regions) from a * repository. The steps are: *
    *
  1. Establish connection with the MDM server
  2. *
  3. Retrieve the list of languages
  4. *
* Commands used:
* GetRepositoryRegionListCommand
*
* Source code for GetRepositoryRegions.java */ public class GetRepositoryRegions { private GetRepositoryRegions() { } public static void main(String[] args) { // create connection pool String connectionTag = "LOCALHOST"; ConnectionPool connections = null; try { connections = ConnectionPoolFactory.getInstance(connectionTag); } catch (ConnectionException e) { e.printStackTrace(); return; } // alternatively, a repository identifier can be obtain from the GetRunningRepositoryListCommand RepositoryIdentifier reposId = new RepositoryIdentifier("TestRepos", "LOCALHOST", DBMSType.MS_SQL); // get a list of regions from the repository // this is one of the few commands that doesn't require a session GetRepositoryRegionListCommand cmd = new GetRepositoryRegionListCommand(connections); cmd.setRepositoryIdentifier(reposId); try { cmd.execute(); } catch (CommandException e) { e.printStackTrace(); return; } RegionProperties[] regions = cmd.getRegions(); for (int i = 0; i < regions.length; i++) { System.out.println(regions[i].getName()); } } }