Naming Objects, Collections, and Relationships

Meta Data Services Programming

Meta Data Services Programming

Naming Objects, Collections, and Relationships

This section provides guidelines for identifying objects, collections, and relationships by name. Different naming guidelines apply depending on whether you are naming objects of an information model, or naming object instances in a repository.

Naming Information Model Elements

When you create ClassDef, RelationshipDef, and CollectionDef objects in an information model, you specify a name that you can use later to reference that meta data type. You can provide this name by specifying the Name parameter in a creation method (for example, CreateClassDef, CreateInterfaceDef, CreateRelationColDef, and so on).

Depending on how you define a relationship collection, you can determine how objects of that collection are subsequently named (this naming occurs when you populate an information model). Specifically, you can specify that object names are explicitly named through the INamedObject interface. If you are accustomed to assigning object names yourself, or if your information model is structured in such a way that the destination of a naming relationship collection is not obvious, you can use this interface to attach a Name property to an information model object. You can then provide a name when creating an instance of that object.

The following example shows an incomplete code sample that gives you a basic idea about how to implement INamedObject for a repository object. When you use this interface, be sure to set the COLLECTION_OBJECTNAMING flag on the collection.

Dim oRepository as Repository
Dim oCObject as ClassDef
Dim oINamedObject as InterfaceDef
Dim oIObject as InterfaceDef
Dim oRContains as RelationshipDef
Dim oColObjectContains as CollectionDef
...
Set oINamedObject = oRepository.object(OBJID_INamedObject)
oCObject.AddInterface oINamedObject
...
Set oColObjectContains = oIObject.CreateRealtionshipColDef(objid_null, name_collection, dispid_collection, True, COLLECTION_NAMING, oRContains)
Naming Object Instances

When you populate an information model with meta data instances, you can allow the repository engine to name the object for you, or you can provide a name.

How the Repository Engine Names Object Instances

The repository engine uses relationship collections to create names for objects. Specifically, the relationship collection that determines an object instance name is the target object collection. When the target object collection contains uniquely named objects, and when it is the sole target of the source object, the identity of the target object is unambiguous. However, if more than one target is possible, you should assign an explicit name to avoid having the repository engine select one for you.

You can choose to let objects assume different names when accessed through a relationship, as opposed to the single name that it assumes when it is accessed through the object. Naming an object through a relationship has the benefit of referring to the same object through different names depending on the context in which it is used. In this case, the relationship collection provides the context.

For more information, see Naming and Unique-naming Collections.

How to Explicitly Name an Object Instance

If an object supports the INamedObject interface in the information model, you can call an object by its INamedObject::Name property. You can also use IRepositoryItem::Name to supply a name.

See Also

Changing an Object Version's Name

Changing a Destination Relationship's Name

INamedObject Interface

Naming Conventions

Retrieving an Object Version's Name

Selecting Items in a Collection

Type Information Aliasing