Previous Page | Next Page

Using the SAS Java Metadata Interface

Getting Information About Repositories

Before you can read or write metadata, you must identify the repositories that are registered on a SAS Metadata Server. You should be familiar with the repository identifiers to indicate which repository to access. You can list the repositories that are defined on a SAS Metadata Server by using the getRepositories method. The getRepositories method exists in the MdOMIUtil interface.

The following code issues a getRepositories method:

   /**
    * This example retrieves a list of the repositories that are registered 
    * on the SAS Metadata Server. 
    * @return the list of available repositories (list of CMetadata objects)
    */
   public List getRepositories()
   {
      try
      {
         // Repositories are listed with the getRepositories method.
         System.out.println("\nThe repositories contained on this 
SAS Metadata Server are: ");
         
         MdOMIUtil omiUtil = _factory.getOMIUtil();
         List reposList = omiUtil.getRepositories();
         Iterator iter = reposList.iterator();
         while (iter.hasNext())
         {
            // Print the name and id of each repository.
            CMetadata repository = (CMetadata) iter.next();
            System.out.println("Repository: " + 
                               repository.getName() 
                               + " (" + repository.getFQID() +")");
         }
         return reposList;
      }
      catch (MdException e)
      {
         e.printStackTrace();
      }
      catch (RemoteException e)
      {
         e.printStackTrace();
      }
      return new ArrayList();
   }

Here is an example of the output that might be returned by the GetRepositories method:

The repositories contained on this SAS Metadata Server are:
Repository: Foundation (A0000001.A5PCE796)
Repository: MyProject (A0000001.A5RVLQQ9)
Repository: Custom1 (A0000001.A5T27ER8)
Repository: Custom2 (A0000001.A5IUI1BI)

The two-part number in each line is the repository identifier. The first part of the number (A0000001) is the SAS Repository Manager identifier and is the same for all repositories. The second part of the number is the unique repository ID. This is the identifier that we will use to create and read metadata.

The CMetadata interface is the base interface that is used to describe all metadata objects. Method parameters take in a CMetadata object to allow the methods to be used with any SAS Open Metadata Interface metadata object.

Previous Page | Next Page | Top of Page