Ecore Metamodel
EPackage
vocabulary = new Vocabulary
vocabulary.iri = ePackage.nsURI
vocabulary.prefix = ePackage.nsPrefix
vocabulary.separator = '#'
vocabulary.ownedAnnotations += createAnnotation(dc:title, vocabulary.prefix)
vocabulary.ownedImports = OWL.iri + (iris of all referenced EPackages)
vocabulary.ownedMembers = map(ePackage.eClassifiers) + map(ePackage.eClassifiers.filter(EClass).eStructuralFeatures)
EClass
if (eClass.isAbstract or eClass.isInterface and all eClass.eSuperClasses are also so)
entity = new Aspect
else
entity = new Concept
entity.name = eClass.name
entity.ownedAnnotations += createAnnotation(rdfs:label, toLabel(entity.name))
entity.ownedSpecializedTerms += map(eClass.eSuperClasses)
for (eAttribute: eClass.eAttributes.filter(lowerBound > 0 || upperBound > 1) {
entity.ownedRestrictions += createScalarPropertyCardinalityRestriction(eAttribute)
}
for (eReference: eClass.eReferences.filter(lowerBound > 0 || upperBound > 1) {
entity.ownedRestrictions += createRelationCardinalityRestriction(eReference)
}
entity.ownedKeys = createKey(eClass.eAttributes.filter(a|a.isId))
EEnum
enum = new EnumeratedScalar
enum.name = eEnum.name
enum.ownedLiterals = map(eEnum.literals)
enum.ownedAnnotations += creatAnnotation(rdfs:label, toLabel(enum.name))
EEnumLiteral
literal = new QuotedLiteral
literal.value = eLiteral.name
EDataType
scalar = new FacetedScalar
scalar.name = eDataType.name
scalar.ownedAnnotations += createAnnotation(rdfs:label, toLabel(scalar.name))
EAttribute
property = new ScalarProperty
if (eAttribute.name collides with that of another EStructuralFeature in the EPackage)
property.name = eAttribute.name + '_' + eAttribute.eContainingClass.name
else
property.name = eAttribute.name
property.domain = map(eAttribute.eContainingClass)
property.range = map(eAttribute.eAttributeType)
property.functional = (eAttribute.getUpperBound == 1)
property.ownedAnnotations += createAnnotation(rdfs:label, toLabel(property.name))
EReference
if !isMappable(eReference) return;
entity = new EntityRelation
if (eReference.name collides with that of another EStructuralFeature in the EPackage)
entity.name = firstCapital(eReference.name) + '_' + eReference.eContainingClass.name + '_Reference'
else
property.name = firstCapital(eReference.name) + '_Reference'
entity.source = map(eReference.eContainingClass)
entity.target = map(eReference.eReferenceType)
entity.functional = (eReference.getUpperBound == 1)
entity.ownedAnnotations += createAnnotation(rdfs:label, toLabel(entity.name))
entity.forward = new ForwardRelation
if (eReference.name collides with that of another EStructuralFeature in the EPackage)
entity.forward.name = eReference.name + '_' + eReference.eContainingClass.name
else
entity.forward.name = eReference.name
entity.forward.ownedAnnotations += createAnnotation(rdfs:label, toLabel(entity.forward.name))
if (eReference.eOpposite != null) {
entity.reverse = new ReversedRelation
if (eReference.eOppposite.name collides with that of another EStructuralFeature in the EPackage)
entity.reverse.name = eReference.eOpposite.name + '_' + eReference.eOpposite.eContainingClass.name
else
entity.reverse.name = eReference.eOpposite.name
entity.reverse.ownedAnnotations += createAnnotation(rdfs:label, toLabel(entity.reverse.name))
}
// ------
function boolean isMappable(eReference) {
return eReference.eOpposite == null ||
eReference.eIsContainer == true ||
isLessThan(eReference.upperBound, eReference.eOpposite.upperBound) || // notice that upperBound * is encoded as -1
eReference.name < eReference.eOpposite.name ||
eReference.eContainingClass.name < eReference.eOpposite.eContainingClass.name ||
eReference.eContainingClass.ePackage.nsURI < eReference.eOpposite.eContainingClass.ePackage.nsURI;
}
OML Annotations
isRelationEntity (on EClass)
Flags that the eClass should be mapped to a RelationEntity. It has to be coupled with flagging one of the class's (direct or inherited) EReferences isForward and another as isReverse.
isForward (on EReference)
Flags the eReference as a forward relation (and not as a RelationEntity) of another RelationEntity
isReverse (on EReference)
Flags the eReference as a reverse relation (and not as a RelationEntity) of another RelationEntity
GenModel Annotation
documentation (on ENamedElement)
Maps to dc:description "value" annotation placed on the named element
UML Annotations
duplicates (on EClass)
for (duplicate : Set<EStructuralFeatures>) {
original = <find EStructuralFeature (or another duplicate) with the same name in the nearest superclass of the EClass>
if duplicate.type != original.type)
placeAllRangeRestrictionOnEntity(original, duplicate)
if (duplicate.lowerBound != original.lowerBound || duplicate.upperBound != original.upperBound)
placeCardinalityRestrictionOnEntity(original, duplicate)
}
subsets (on EReference)
entity = <find the RelationEntity that maps to the EReference>
supersetEntity = <find the RelationEntity that maps to the superset EReference>
if (entity.ownedSpecializedTerms.excludes(supersetEntity))
entity.ownedSpecializedTerms += supersetEntity