Identity
Elements often need to be referenced, either in other parts of the model or as way to find the element within the model during tests or other logic.
ElementClasses can annotate attributes as identifiers. In elements, the values of these attributes will be combined to create a unique key.
<elementClass name="ScriptParameterType">
<group name="org.normalizedsystems.scripts" ontology="scriptElements"/>
<role name="node"/>
<attributes>
<attribute name="name">
<isIdentifier>true</isIdentifier>
<dataType name="Name" ontology="scriptElements"/>
</attribute>
</attributes>
</elementClass>
Composition
If an ElementClass has identifiers and is part of a Composition or Extension, the key of the parent will become part of the keys of its children. This makes the children unique within the context of the parent.
This does introduce some restrictions on the model:
- Parents are required to have identifiers.
- The Composition Reference needs to have an Opposite Reference.
If you need to leave the parent out of the key, you can set isGloballyUnique
to true.
The key is then constructed solely from the identity attributes of the ElementClass.
In this case, these identifiers need to form a key that is unique over the entire model.
<elementClass name="ValueType">
<isGloballyUnique>true</isGloballyUnique>
<group name="valueTypes" ontology="elements"/>
<role name="data"/>
<attributes>
<attribute name="name">
<isIdentifier>true</isIdentifier>
<dataType name="Name" ontology="elements"/>
</attribute>
</attributes>
</elementClass>