Cross-reference case study

An alternative implementation, explained.

Facet-oriented modelling with metaDepth

The implementation of the annotation model case study using cross-references is available here: crossrefs.zip. To run it just type "run P2GTrafo" in metaDepth's console.

The following artefacts were necessary:

  • Modified Census and graphical meta-models to include cross-references.
  • An ETL transformation to create graphical elements from census ones:
    metaDepth / code
    @metamodel(name=Person,file=Person.mdepth,domain=source)
    @metamodel(name=ConcreteSyntax,file=ConcreteSyntax.mdepth,domain=target)
    @greedy
    rule FemaleToCircle 
      transform s : SLevel0!Person 
      to        t : Target!Circle
    {
      guard : s.female
    
      t.radius := 2*s.age;
      t.label  := s.name;
      t.semanticObject := s;
      t.linkedTo ::= s.marriedWith;  
        
      t.labelField := "name";
      s.csElement := t;  
    }
    
    @greedy
    rule MaleToRectangle 
      transform s : SLevel0!Person 
      to        t : Target!Rectangle
    {
      guard : not s.female
    
      t.height := s.age;
      t.width := s.age;
      t.label  := s.name;
      t.semanticObject := s; 
      t.linkedTo ::= s.marriedWith;
      
      t.labelField := "name";
      s.csElement := t; 
    }
    
    pre{
      for (e in Target!Element.all) {
        delete e;
      }
    }
      
    The transformation needs to be reexecuted whenever the Census model changes
  • An EOL program to update the Census model when some attribute in the graphical model changes:
    metaDepth / code
    operation main()  {
      for ( r in Rectangle.all) {     
         r.semanticObject.name := r.label;
         r.semanticObject.age := r.width; 
      }
      for ( r in Circle.all) {
         r.semanticObject.name := r.label;
         r.semanticObject.age := r.radius/2;
      }
    }
    The previous program is less efficient than a facet implementation, since we traverse all graphical forms.
  • A new variation of the Draw MetaDepth command (called drawcrossref), which invokes the previous EOL program when some attribute changes. Please note that the name EOL program needed to be hard-coded in the Java program.