Example: Compare, validate and merge OO models

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

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;

Clone Epsilon's Git repository:

  • navigate to examples
  • import the org.eclipse.epsilon.examples.oomerging project

Once you have checked out/imported the code, to run the example you need to go through the following steps:

  1. register any .ecore metamodels in the org.eclipse.epsilon.examples.oomerging project
  2. right click the .launch file in the org.eclipse.epsilon.examples.oomerging project
  3. select Run as... and click the first item in the menu that pops up

What's this?

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.

What are .emf files?

.emf files are Ecore metamodels expressed using the Emfatic textual syntax.

More examples...

Epsilon Object Language
Epsilon Transformation Language
Epsilon Generation Language
Epsilon Validation Language
Epsilon Merging Language
Epsilon Flock
Epsilon Model Generation Language
Epsilon Pattern Language
Combining the Epsilon Languages

Even more examples...

More examples are available in the examples folder of the Git repository.