Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

KTM - KIELER Transformation Mapping

Panel
bgColororange
titleDEPRECATEDDeprecated since 0.12

This article is deprecated. The described features are no longer available in current releases.

KTM was redesigned is now available as KiTT . The documentation will be updated eventually.

 

included in KiCool.


Topics

Table of Contents
maxLevel2
minLevel2

...

Transformation Tree Model

 


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

...

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


An abstract example of an instance of this model:

...

The codeblock blow show a snipped of SCChartCoreTransformation with additional mapping registration.


Code Block

...

code
language
java
themeEclipse
languagefirstlinejava1
titletransformTriggerEffect CodeSnippedfirstline1
linenumberstrue
collapsetrue
...
    @Inject
    extension TransformationMapping

...

    // NEW - Mapping access delegation  
    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) {
        clearMapping; //NEW - clear previous mapping information to assure a single consistent mapping
        // 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);
        }
        val completeness = checkMappingCompleteness(rootRegion, targetRootRegion); //NEW - DEBUG
        targetRootRegion;
    }
    def void transformTriggerEffect(Transition transition, Region targetRootRegion) {
       // Only apply this to transition that have both, a trigger (or is a termination) and one or more effects 
        if (((transition.trigger != null || !transition.immediate || transition.typeTermination) && !transition.effects.nullOrEmpty) ||
            transition.effects.size > 1) {
            val targetState = transition.targetState
            val parentRegion = targetState.parentRegion
            val transitionOriginalTarget = transition.targetState
            var Transition lastTransition = transition
            val firstEffect = transition.effects.head
            for (effect : transition.effects.immutableCopy) {
                 // Optimization: Prevent transitions without a trigger
                 if(transition.immediate && transition.trigger == null && firstEffect == effect) {
                        // skip
                 } else { 
                    val effectState = parentRegion.createState(GENERATED_PREFIX + "S")
                    effectState.mapParents(transition.mappedParents); //NEW - mapping information
                    effectState.uniqueName
                    val effectTransition = createImmediateTransition.addEffect(effect)
                    effectTransition.mapParents(transition.mappedParents); //NEW - mapping information
                    
                    effectTransition.setSourceState(effectState)
                    lastTransition.setTargetState(effectState)
                    lastTransition = effectTransition
                 }
            }
            lastTransition.setTargetState(transitionOriginalTarget)
        }
    }

...

The following code will now perform each transformation stepwise and updates a transformation tree each step.


Code Block

...

code
language
java
themeEclipse
languagefirstlinejava1
titleTransform and create TranformationTreefirstline1
linenumberstrue
collapsetrue
aboSplitTE = SCCtransformation.transformTriggerEffect(abo);

ModelWrapper aboSplitTEModel =
        transformationTree.initializeTransformationTree(SCCtransformation.extractMapping(), "TriggerEffect", abo, "coreSCChart", aboSplitTE, "coreSCChart-splitTriggerEffect");

aboNormalized = SCCtransformation.transformSurfaceDepth(aboSplitTE);

ModelWrapper aboNormalizedModel =
        transformationTree.addTransformationToTree(SCCtransformation.extractMapping(), aboSplitTEModel, "SurfaceDepth", aboSplitTE, aboNormalized, "normalizedCoreSCChart");

aboSCG = SCGtransformation.transformSCG(aboNormalized);

ModelWrapper aboSCGModel =
        transformationTree.addTransformationToTree(SCGtransformation.extractMapping(), aboNormalizedModel, "SCC2SCG", aboNormalized, aboSCG,"SCG");

tree = transformationTree.root(aboSCGModel);

 


The resulting TransformationTree has following structure and representing each step and model of the transformation.

 


Image Modified
Image Modified
Image Modified
Image Modified
Image Modified

 


Furthermore the TransformationTree now contains mapping information for the whole transformation chain.

...

The following code has starts with an instance of the initial ABO SCChart and SCG, along with the TranformationTree above. 


code
Code Block
language
java
themeEclipse
languagefirstlinejava1
titleresolveMappingfirstline1
linenumberstrue
collapsetrue
@Inject
extension TransformationTreeExtensions

//Find nodes of model instances in tree
val aboSCCModelWrapper = transformationTree.findModel(aboSCC,"coreSCChart");
val aboSCGModelWrapper = transformationTree.findModel(aboSCG,"SCG");

//resolve
val mapping = resolvemapping(aboSCCModelWrapper, aboSCC, aboSCGModelWrapper, aboSCG);

...


The returned mapping is a multi mapping between all object in aboSCC and their resulting objects in aboSCG.

This mapping can now displayed in models or used for various information propagation between elements of the models.

 


Also a more detailed view is available, showing all EObjects relation.

 


Visualisation

If you have a TransformationTree file (.ktmt) you can open a KLighD visualisation by right-clicking on file in project-tree and selecting 'Open Transformation Tree'.

...

If Selective selective mapping edge is enabled no mapping edges are displayed. If you select (CLICK) an element in one of the two model its relation to corresponding element is displayed. You can multi-select with CTRL+CLICK or deselect by clicking on an edge.