rule Models match l : Left!Model with r : Right!Model { compare : true } rule Class match l : Left!Class with r : Right!Class { compare : l.name = r.name }
context SimpleOO!Class { constraint BothAbstractOrNot { guard : self.getMatching().isDefined() check : self.getMatching().isAbstract = self.isAbstract message : 'Inconsistent value in feature "abstract" ' + 'of class ' + self.name } } @cached operation SimpleOO!Class getMatching() : Any { var match := matchTrace.matches.selectOne (m|m.left = self or m.right = self); if (not match.isDefined()) { return null; } if (match.left = self) { return match.right; } else { return match.left; } }
rule MergeModel merge l : Left!Model with r : Right!Model into t : Target!Model { t.name := l.name + ' and ' + r.name; t.contents ::= l.contents + r.contents; } rule MergeClass merge l : Left!Class with r : Right!Class into t : Target!Class { t.name := l.name; t.isAbstract := l.isAbstract; } rule CopyModel transform s : Source!Model to t : Target!Model { t.contents ::= s.contents; } rule CopyClass transform s : Source!Class to t : Target!Class { t.name := s.name; t.isAbstract := s.isAbstract; }
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 use ECL to compare two OO models, then use EVL to check the identified matches for consistency and finally EML to merge them. The three different programs are bound together and executed sequentially using the workflow.
.emf files are Ecore metamodels expressed using the Emfatic textual syntax.
More examples are available in the examples folder of the SVN repository.