Example: Heterogeneous Model Merging with ECL/EML


  • Comparison.ecl
  • Merging.eml
  • Entity.emf
  • DomainVocabulary.emf
  • Get it!
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:

  1. download the following zip archive(s), extract them and import them as new Eclipse projects
  2. or check out the code from the SVN
    • go to the SVN repository
    • navigate to trunk/examples
    • check out the org.eclipse.epsilon.examples.metamodels project
    • check out the org.eclipse.epsilon.examples.mergeentitywithvocabulary project

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

  1. register all .ecore metamodels in the org.eclipse.epsilon.examples.metamodels project (select all of them and then right click and select Register EPackages)
  2. right click the .launch file in the org.eclipse.epsilon.examples.mergeentitywithvocabulary project
  3. select Run as... and click the first item in the menu that pops up
What's this?
What are .emf files?
Even more examples...