Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added example for Mapping and TransformationTree creation

...

  • All references to EObjects are references to a copy of the original EObject. This allows to represent immutable mapping. To reidentify corresponding EObjects TransformationTreeExtensions provides search functions which will check for structural matching models.
  • Models in TransformationTrees may be transient. This indicates that all references to EObjects in all Elements of the transient model are removed. Thus these models can't be source of a new appended transformation and can not be associated with it's original model. The main propose of this feature is to improve scalability of TransformationTrees by removing unnecessary references to internal model, but preserve traversing functionality of the ObjectMapping.
  • Mappings can be incomplete causing resulting transfromation tree to be incomplete. A incomplete tree does not represent every object in a model with a corresponding Element. This may break some paths of element transformations, but allows to omit model-immanent objects like annotations from mapping. TranformationMapping extension provies a function to check completeness of mapping against its models.

...

Example

...

Creating Mapping during Transformation

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

Code Block
themeEclipse
languagejava
titleModified SCChart Transformation
firstline1
linenumberstrue
collapsetrue
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.

Image Added

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

Code Block
themeEclipse
languagejava
titleTransform and create TranformationTree
firstline1
linenumberstrue
collapsetrue
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.

Image Added

Resulting TransformationTree has following structure.

Image Added

Furthermore the TransformationTree now contains the following mapping information.

Image Added

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