KTM - KIELER Transformation Mapping

 

Topics

This subproject provides a tracing mechanism for arbitary model-elements across multiple model transformations, based on EMF.

The main propose of KTM is to allow bidirectional information transfer between abstract models and their resultant transformed models.


Transformation Tree Model

 

To offer a mapping between model-elements during multiple transformations KTM introduces a model called TransformationTree to represent these relations.

It is based on an EMF-Metamodel.

The structure of the model can be separated into two parts.

First part (upper half) is a tree of transformations. Each Model-class is a representation of a concrete model which is transformed. So models are nodes and ModelTransformations are edges. Thus the Model representing the root-model of a tree is also the root of a concrete TransformationTree-model.

Second part (lower half) is object-mapping. Instances of models contain EObjects as their elements, which are represented by Element-class in TransformationTree metamodel. The Elements of two models are connected with ElementTransformations-class to model their origination relationship in corresponding model transformation.

 

An abstract example of an instance of this model:


Extensions

Two classes are provided by this project to extend functionality of the core model.

TransformationMapping (JavaDoc)

The main propose of this class is generation of a object-mapping during transformation process.

Therefor it provides different functions for incremental registering of single parent-child-relations between EObjects.

Furthermore, the extension allows to extract the mapping and check completeness of mapped elements against content of transformed models.

TransformationTreeExtensions (JavaDoc)

This class provides all functionalities to easily traverse and search in a TransformationTree.

Furthermore, it allows to modify trees by creating, deleting or appending new transformations and transformed models.

Additionally this extension provides functionality to extract a concrete mapping between two arbitary model intances from a TransformationTree.


Implementation Details


Example

Creating Mapping during Transformation

The following code is a modifcation of the tranformation "Spilt Trigger and Effects" of SCCharts.

package de.cau.cs.kieler.ktm.test.transformations

import com.google.inject.Inject
import de.cau.cs.kieler.ktm.extensions.TransformationMapping
import de.cau.cs.kieler.sccharts.Region
import de.cau.cs.kieler.sccharts.Transition
import de.cau.cs.kieler.sccharts.extensions.SCChartsExtension
/**
 * @author als
 */
class SCChartTestTransformation {
    @Inject
    extension TransformationMapping
    @Inject
    extension SCChartsExtension

    // -- Mapping Access    
    def extractMapping() {
        extractMappingData;
    }

    //-------------------------------------------------------------------------
    //--                 S P L I T   T R A N S I T I O N                     --
    //-------------------------------------------------------------------------
    // For every transition T that has both, a trigger and an effect do the following:
    //   For every effect:
    //     Create a conditional C and add it to the parent of T's source state S_src.
    //     create a new true triggered immediate effect transition T_eff and move all effects of T to T_eff.
    //     Set the T_eff to have T's target state. Set T to have the target C.
    //     Add T_eff to C's outgoing transitions. 
    def Region transformTriggerEffect(Region rootRegion) {
        // Clone the complete SCCharts region 
        var targetRootRegion = rootRegion.mappedCopy; //NEW - mapping information (changed copy to mappedCopy)
        // Traverse all transitions
        for (targetTransition : targetRootRegion.getAllContainedTransitions) {
            targetTransition.transformTriggerEffect(targetRootRegion);
        }
        targetRootRegion;
    }
    def void transformTriggerEffect(Transition transition, Region targetRootRegion) {
        // Only apply this to transition that have both, a trigger and one or more effects 
        if (((transition.trigger != null || !transition.immediate) && !transition.effects.nullOrEmpty) || transition.effects.size > 1) {
            val targetState = transition.targetState
            val parentRegion = targetState.parentRegion
            val transitionOriginalTarget = transition.targetState
            var Transition lastTransition = transition
            for (effect : transition.effects.immutableCopy) {
                val effectState = parentRegion.createState(targetState.id + effect.id)
                effectState.mapParents(transition.mappedParents); //NEW - mapping information
                effectState.setTypeConnector
                val effectTransition = createImmediateTransition.addEffect(effect)
                effectTransition.mapParents(transition.mappedParents); //NEW - mapping information
                effectTransition.setSourceState(effectState)
                lastTransition.setTargetState(effectState)
                lastTransition = effectTransition
            }
            lastTransition.setTargetState(transitionOriginalTarget)
        }
    }
}

Create TransformationTree with Mapping

To test the transformation and mapping we will transform th following ABO-SCChart.

The following code snipped performs the transformation on our ABO-example, extracts the mapping and creates a transformation tree.

aboSplitTE = transformation.transformTriggerEffect(abo);

Model aboSplitTEModel = transformationTreeExtensions.initializeTransformationTree(
                            transformation.extractMapping(),
                            "splitTriggerEffect", 
                            abo, "ABO", 
                            aboSplitTE, "ABO-splitTriEff");

tranformationTree = transformationTreeExtensions.root(aboSplitTEModel);

The result of transformation is the following SCChart. ABO-splitTriEff.

Resulting TransformationTree has following structure.

Furthermore the TransformationTree now contains the following mapping information.

Here you can see the effect of the transformation causing the transformation to split up.