rule MatchSystemWithVocabulary match s : Source!System with v : Vocabulary!Vocabulary { compare { return true; } } rule MatchEntityWithTerm match s : Source!Entity with t : Vocabulary!Term { compare { return s.name = t.name or t."alias".exists(a|a.name = s.name); } }
rule MergeEntityWithTerm merge s : Source!Entity with t : Vocabulary!Term into m : Target!Entity { m.name := t.name; m.inDomain := true; } rule MergeSystemWithVocabulary merge s : Source!System with v : Vocabulary!Vocabulary into t : Target!System { t.entity := s.entity.equivalent(); } rule TransformEntity transform s : Source!Entity to t : Target!Entity { t.name := s.name; t.inDomain := false; }
@namespace(uri="Entity", prefix="Entity") package Entity; class System { val Entity[*]#system entity; } class Entity { attr String name; ref System#entity system; attr Boolean inDomain; }
@namespace(uri="DomainVocabulary", prefix="DomainVocabulary") package DomainVocabulary; class Vocabulary { val Term[*] term; } class Term { attr String name; val Alias[*] alias; } class Alias { attr String name; }
There are two ways to get the code of this example:
Once you have checked out/imported the code, to run the example you need to go through the following steps:
In this example, we demonstrate merging heterogeneous models that conform to the Entity.emf and DomainVocabulary.emf metamodels using the Epsilon Comparison and Merging Languages.
In the first step, we use the Comparison.ecl ECL program to establish correspondences between the two models, and in the second step we use the Merging.eml EML program to merge the two models on the identified correspondences.
.emf files are Ecore metamodels expressed using the Emfatic textual syntax.
More examples are available in the examples folder of the SVN repository.