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.
VIATRA/Transformation/Transformation API
< VIATRA | Transformation
Revision as of 08:17, 19 September 2013 by Ujhelyiz.mit.bme.hu (Talk | contribs)
Contents
VIATRA2 EMF Transformation API
- Based on EVM
- Relies on Xtend features such as extension methods and closures to be
- Language concepts (for requirements overview)
- Documentation for API in org.eclipse.viatra2.emf.git (browse, stats, fork on OrionHub)
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
- Stateless
(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. |
Incremental Transformation API
TBA
Model Manipulation Primitives
To be implemented
Name | Parameters | Description |
---|---|---|
create EObject | Resource; EClass | Creates an object with the corresponding EClass type, and puts it into the root of the selected resource |
create EObject | 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 |
add EObject | EObject (container); EReference; EObject | Adds an existing object to the corresponding container with a reference; the reference must *not* be of containment type |
add value | EObject (container); EAttribute; Object | Adds a value to the selected attribute of the container |
remove EObject | EObject | Removes the EObject from the model |
remove EObject | EObject (container); EReference; EObject | Removes an object from the selected container; if reference is containment, also removes it from the resource set |
move | TBA | TBA |
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.
- Case description: http://planet-sl.org/community/index.php?option=com_community&view=groups&task=viewgroup&groupid=26&Itemid=387&lang=en
- Implementation: https://github.com/izsob/TTC13-PN2SC-EIQ (look for the branch viatra-api)