Previous Page | Next Page

Adding Metadata Objects

Using the AddMetadata Method

The AddMetadata method enables you to create metadata objects that describe both metadata repositories and application elements. Adding a metadata object that describes a metadata repository defines the repository in the SAS Metadata Server's SAS Repository Manager. A SAS Metadata Repository must be defined before you can define metadata objects describing application elements in the repository.

Note:   The SAS 9.2 deployment process creates the initial SAS Metadata Repository for you, so direct use of the SAS Open Metadata Interface to define repositories is no longer necessary nor recommended.  [cautionend]

An application element is an item such as a table, a column, a key, or a SAS library. You create objects representing application elements to describe a data source or other entity used by your application.


Creating a Metadata Object

To create a metadata object with the AddMetadata method, you must provide the following information:

This information is passed as AddMetadata parameters. The parameters are displayed here as XML elements that can be submitted to the SAS Metadata Server in the INMETADATA parameter of the DoRequest method:

<AddMetadata>
   <Metadata>metadata_property_string</Metadata>
   <Reposid>repository_identifier</Reposid>
   <NS>namespace</NS>
   <Flags>268435456</Flags>
   <Options/>
</AddMetadata>
  

To create a metadata object describing a metadata repository, you specify the following information:

To create a metadata object describing an application component, you specify the following information:

The metadata property string must be formatted in XML as described in Constructing a Metadata Property String. At a minimum, the metadata property string must specify the metadata type and any required properties of the object to be created. Most metadata types have required attributes. Some metadata types also have required associations. For information about required and optional properties of the application metadata types, see Alphabetical Listing of SAS Namespace Metadata Types.

Although it is not required, it is recommended that you provide values for all of an object's attributes, and for as many associations as possible in the metadata property string to make your metadata meaningful. Before creating objects, see Selecting Metadata Types to Represent Application Elements.


Creating Associations While Creating an Object

The metadata property string that defines a metadata object describing an application element can also define associations to metadata objects describing related application elements.

An association is defined by including XML subelements in the metadata property string that defines the application element:

The following is an example of a metadata property string that includes XML subelements that define an association:

   <MetadataType Name="Name-of-primary-object" 
         Desc="New object created using AddMetadata">
     <AssociationName>
         <AssociatedMetadataType Name="Name-of-associated-object" 
          Desc="New associated object that is created by AddMetadata"/>
     </AssociationName>
   </MetadataType>
 

The AddMetadata method creates a new object for every property string that is submitted in the <METADATA> element, unless the ObjRef= attribute is included in the property string. ObjRef= is supported only in a nested property string. It specifies that the object instance is an existing metadata object. It instructs the SAS Metadata Server to create an object reference to the specified object without modifying the specified object's other properties.

The SAS Metadata Server creates a new associated object in all of the following cases:


Creating Cross-Repository References

The default behavior of the AddMetadata method is to create the primary metadata object and all references to new and existing objects in the repository specified in the <REPOSID> element. You can also create associations that reference new and existing objects in other repositories. Associations between objects that exist in different repositories are referred to as cross-repository references. A cross-repository reference is created by including the appropriate repository identifier in the associated object definition.


Symbolic Names

A symbolic name is an alias that is preceded by a dollar sign ($). You assign a symbolic name to a metadata object to reference it before it is created. Symbolic names are used to create associations and new associated objects in other repositories. They also enable you to create references between multiple, unrelated metadata objects in a single XML request. For more information about this type of usage, see Example of an AddMetadata Request That Creates Multiple, Unrelated Metadata Objects.

When used to create an association and a new associated object in another repository, the symbolic name has the form Reposid.$Alias. It is specified in the Id= attribute of the association subelement.

When used to create multiple, unrelated metadata objects in the same repository, the form $Alias is used.

The alias can be any name, as long as it is preceded by a dollar sign ($). After the successful completion of AddMetadata or UpdateMetadata processing, the alias and any references to it are automatically replaced with a real object identifier.


Example Metadata Property Strings

The following is an example of a metadata property string that creates an application metadata object and an association to an existing object in another repository:

<MetadataType Name="Name-of-primary-object" 
              Desc="New object created using AddMetadata">
   <AssociationName>
     <AssociatedMetadataType Objref="Reposid.Objectid"/>
   </AssociationName>
</MetadataType>

Note the use of the Objref= attribute and the fact that no other attributes are specified. When ObjRef= is used, the SAS Metadata Server ignores any additional attributes that might be specified. The object identifier in the ObjRef= attribute includes both the repository identifier and the object instance identifier of the target object.

The following is an example of a metadata property string that creates an object, an association, and a new associated object in another repository:

<MetadataType Name="Name-of-primary-object"  
              Desc="New object created using AddMetadata">
   <AssociationName>
     <AssociatedMetadataType Id="Reposid.$SymbolicName" 
                             Name="Name-of-associated-object" 
                             Desc="Associated object that is created by AddMetadata"/>
   </AssociationName>
</MetadataType>

The portion of the property string that identifies the associated object specifies the Id= attribute with the repository identifier and a symbolic name for the new object. (You can determine the available repositories and their unique identifiers by issuing the GetRepositories method. For more information, see Using GetRepositories to Get the Registered Repositories.) Because a new object is created, you must specify at least a Name= value for the associated object and you should include values for other attributes.


Creating Multiple, Unrelated Metadata Objects in an AddMetadata Request

To create multiple, unrelated metadata objects in an AddMetadata request, stack the metadata property strings that define the metadata objects in the <METADATA> element as follows:

<Metadata>
  <MetadataType1 Name="String" Desc="String">
   <AssociationName>
     <AssociatedMetadataType Name="String" Desc="String"/>
   </AssociationName>
 </MetadataType1>
 <MetadataType2 Name="String" Desc="String">
   <AssociationName>
     <AssociatedMetadataType Name="String" Desc="String"/>
   </AssociationName>
 </MetadataType2>
</Metadata>


Creating Multiple Associated Objects

To define multiple associations for an object, stack the associated object definitions within the primary object definition as follows:

<MetadataType Name="String" Desc="String">
   <AssociationName1>
     <AssociatedMetadataType Name="String" Desc="String"/>
   </AssociationName1>
   <AssociationName2>
     <AssociatedMetadataType Name="String" Desc="String"/>
  </AssociationName2>
</MetadataType>

Previous Page | Next Page | Top of Page