How to link two metamodels?
There are two ways to link metamodels:
- you either want to link them on a certain level as to create a mere association between the two conceptual worlds.
- or you want to add your custom metamodel to an existing metamodel and use your new concepts in said existing model.
In the first case, defining an association reference would be the right choice. This allows you the freedom of defining the nature and degree of coupling yourself.
In the second case, you would either have to create a Model Extension, using extension references or use the concept of polymorphism and sub/superClasses over two ontologies.
Model Extension
In a Model Extension, there are:
- A parent ElementClass, e.g.
elements::Component, which can be extended. - A child ElementClass, e.g.
demo::CustomElement. - A reference with associationType
extension, which goes from the child to the parent.
Steps to create a Model Extension
- Add the dependency on theh target ontology to your own ontology.
- Define the child ElementClass like any other ElementClass
- Define the extension reference that describes the link from the child in your ontology to the parent in the target ontology.
- 1. Ontology
- 2. ElementClass
- 3. Reference
model/demo.xml
<ontology name="demo">
<dependencies>
<ontology name="elements"/>
</dependencies>
</ontology>
model/elementClasses/CustomElement.xml
<elementClass name="CustomElement">
<isGloballyUnique>false</isGloballyUnique>
<isAbstract>false</isAbstract>
<isSealed>false</isSealed>
<group name="custom" ontology="demo"/>
<role name="element"/>
<attributes>
<attribute name="name">
<isIdentifier>true</isIdentifier>
<dataType name="Name" ontology="demo"/>
</attribute>
</attributes>
</elementClass>
model/references/CustomElement_component.xml
<reference name="component">
<associationType name="extension"/>
<owner name="CustomElement" ontology="demo"/>
<target name="Component" ontology="elements"/>
<cardinality>
<minimum>0</minimum>
<maximum>1</maximum>
</cardinality>
</reference>
Important to note is that, when creating an extension, the element you are targeting must be extendable. This
parent element should have the option meta.composite.extendable. Currently, only 3 ElementClasses in the elements
ontology are extendable, and can be used as parent:
- ApplicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution.
- Component
- DataElement