Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "VIATRA/Transformation/Transformation API"

(Model Manipulation Primitives)
Line 56: Line 56:
 
Model manipulation primitives are implemented by instances of IModelManipulations interface. Currently, two implementations are available:
 
Model manipulation primitives are implemented by instances of IModelManipulations interface. Currently, two implementations are available:
  
1. SimpleModelManipulations - uses plain EMF API
+
# SimpleModelManipulations - uses plain EMF API
2. ModelManipulationsWithEditingDomain - uses EMF Edit commands on EditingDomain instances
+
# ModelManipulationsWithEditingDomain - uses EMF Edit commands on EditingDomain instances
  
 
If some transformation needs specific primitives (e.g. transaction support), new instances can introduce extra methods as required.
 
If some transformation needs specific primitives (e.g. transaction support), new instances can introduce extra methods as required.

Revision as of 10:47, 20 September 2013

VIATRA2 EMF Transformation API


Batch Transformation API

Three extension classes used for transformations:

  • BatchTransformation - hides IncQueryEngine and RuleEngine; manages group initialization of rules - instead of an extension method, this can also be used as a base class
  • TransformationStatements - control structure
  • ModelManipulation - generic model manipulation primitives; hides details of EditingDomains (if necessary); implementation not batch transformation specific

Batch Transformation Rules

  • Special rule type
    • Precondition + action
    • Life cycle:
      • Stateless
        • rule does not maintain state whether an activation has fired or not
        • Lifecycle: firing: active -> active
      • Stateful
        • rule maintains whether an an activation has fired or not
        • Lifecycle: firing: active -> fired

(Batch) Transformation Statements

Name Parameters Description
choose Batch Transformation Rule, (opt: filter) Fires a single activation
forall Batch Transformation Rule, (opt: filter) Fires all current activations. If the firings change the set of activations, it won't change the set of fired activations.
until Batch Transformation Rule, break condition, (opt: filter) After firing the first activation, it checks whether the break condition became true; if yes, exits, if not, it restarts. It does not store the initial set of activations. Useful for iterate-choose scenarios. Break conditions are implemented using Match Predicates - functions that receive Match instances as parameters.
find IQuerySpecification, (opt: filter) Returns a match of a selected query

Incremental Transformation API

TBA

Model Manipulation Primitives

Model manipulation primitives are implemented by instances of IModelManipulations interface. Currently, two implementations are available:

  1. SimpleModelManipulations - uses plain EMF API
  2. ModelManipulationsWithEditingDomain - uses EMF Edit commands on EditingDomain instances

If some transformation needs specific primitives (e.g. transaction support), new instances can introduce extra methods as required.

Name Parameters Description
create Resource; EClass Creates an object with the corresponding EClass type, and puts it into the root of the selected resource
createChild EObject (container); EReference; EClass Creates an object with the corresponding EClass type, and puts it into the selected reference; the reference must be of containment type
addTo EObject (container); EStructuralFeature; Object Adds an existing object to the corresponding container with a reference; if using a reference it must *not* be of containment type
remove EObject Removes the EObject from the model
remove EObject (container); EStructuralFeature; Object Removes an object from the selected container; when using a containment EReference, also removes it from the resource set
remove EObject (container); EStructuralFeature Removes all objects from a multivalued feature; when using a containment EReference, also removes them from the resource set
set EObject (container); EStructuralFeature; Object Sets the value of a single-valued feature
move EObject(s), EObject (new container), EStructuralFeature Moves elements to a new container, and removes them from an old one. 'Remark': The implementation here is specific, as it relies on features of the index.

Examples

A (not very well tested) example transformation is available by implementing the Petri net to State Charts case of the Transformation Tool Contest 2013.

Back to the top