Graphical Definition of In-Place Transformations in the Eclipse - - PowerPoint PPT Presentation
Graphical Definition of In-Place Transformations in the Eclipse - - PowerPoint PPT Presentation
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework Enrico Biermann, Karsten Ehrig, Christian Khler, Gnter Kuhns, Gabriele Taentzer, Eduard Weiss Technical University of Berlin University of Leicester A
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 2
A fictious dialog on models
- We made good experiences with model-driven
software development. It‘s much faster!
- Good to hear! That‘s what I told you from the
beginning.
- But I think our models could be better.
- You could test the model smell and check out model
refactoring.
- Okay! That means we can improve our models by
transformation?
- Yes, you need some in-place model transformer.
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 3
Synopsis
Eclipse Modeling Framework EMF model transformer in-place model updates graphical definition
- f transformation rules
analysis and validation of transformations
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 4
Outline
- What is the Eclipse Modeling Framework (EMF)?
- EMF transformation concepts
- Running example: EMF model refactoring
- Execution of EMF transformations
– Interpreter mode – Compiler mode
- Related work
- Conclusions
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 5
Eclipse Modeling Framework (EMF)
EMF class diagram EMF Generator set of Java classes for manipulating the model basic tree-based editor uses XMI
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 6
EMF and MetaObject Facility (MOF)
- EMF consists of a metamodel and technology mappings like
MetaObject Facility (MOF).
- MOF is the basis for a couple of language definitions by the
Object Management Group (OMG), including UML 2.
Ecore Essential MOF Complete MOF EMF MOF Metamodels Technology Mappings XML / XMI, Java (Implementations) XMI, CORBA IDL (Interfaces)
≈
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 7
Eclipse Modeling Framework (EMF)
Ecore Metamodel: Classes, references and properties
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 8
Transformation Model for EMF
EMF Source Model EMF Core Model ECore instance of instance of Transformation Rules instance of applied instance of Transformation Model instance of typed over EMF Target Model
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 9
Sample EMF Model Refactoring
Two refactorings:
- new superclass „NamedElement“ for classes „Place“, „PetriNet“, and „Transition“
- pull up attribute „name“ to class „NamedElement“
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 10
A simple refactoring rule for Ecore
Create a new superclass for a given class
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 11
Transformation Model for EMF
- influenced by graph
transformation due to validation facilities
- LHS checks existence
- f pattern
- NACs check non-
existence of any pattern
- difference between
LHS and RHS defines actions
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 12
Transformation Model for EMF
- mappings are defined as LHS -> RHS or LHS -> NAC
- non-injective mappings, i.e. gluings, are allowed
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 13
A simple refactoring rule for Ecore
Move a class from one package to another Similar: move attribute, create superclass, connect superclass, rename parameter, add /remove parameter, etc.
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 14
A complex Ecore refactoring – Pull up attribute
- 1. Check if all subclasses contain the attribute to be pulled up
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 15
A complex Ecore refactoring – Pull up attribute
- 2. If all subclasses have the attribute, then pull it up
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 16
A complex Ecore refactoring – Pull up attribute
- 3. After pulling up, delete the attribute in all subclasses.
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 17
A complex Ecore refactoring – Pull up attribute
- 4. If there are still annotations, delete them.
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 18
How to perform EMF model transformations?
1. Create an AGG type graph from an EPackage 2. Convert the EMF rules to AGG rules 3. Convert an EMF instance to AGG graph 4. Apply a rule in AGG / validate rules 5. Translate AGG graph back to EMF 6. Check and repair consistency
Interpreter:
1. Create Java code from rules, one class per rule 2. Execute rules on EMF model instances or on EMF models (instances
- f Ecore meta-model)
Compiler:
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 19
Code Snippet for Rule Application
ResourceSet resourceSet = new ResourceSetImpl(); Resource resource =resourceSet.getResource(URI.createFileURI( "src/Ecore/instances/petrimodel.ecore"), true); EPackage model = (EPackage) resource.getContents().get(0); // create the new superclass CreateSuperclassRule createSC = new CreateSuperclassRule(model); createSC.setParA(true); createSC.setParC("PetriNet"); createSC.setParS("NamedElement"); createSC.execute();
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 20
Consistency of EMF Refactorings
- coherent refactoring of model and code
– no problem if purely model-driven
- refactoring result is syntactically correct
- refactoring result fullfills validation properties
– for validation based on graph transformation:
consistence of EMF transformation with graph transformation conflict and dependency analysis of rule applications, termination checks, etc.
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 21
Related Work
EMF-related:
- Merlin
- Eclipse GMT-Project:
– Tefkat – ATL – UMLX – ViaTra2
- MOMENT
Graph transformation-related:
- AToM3
- GReAT
- VMTS
- ViaTra2
- Gmorph
- MOFLON
- MOTMOT
Graphical Definition of In-Place Transformations in the Eclipse Modeling Framework 22
Conclusion and Future Work
- EMF model transformations as in-place model updates
- Interpreter/Compiler for EMF transformations
- Visual definition of transformation rules
- Consistency of EMF transformation with graph transformation
- ffers validation facilities
Future work:
- Complete and integrate transformation engine and editor
- Implement checks for possible containment constraint violations
- Consider different applications:
– Complex Editing Operations (Eclipse GMF), Simulation, Optimizations