Changes for page Transformation Mapping (KTM)
Last modified by Richard Kreissig on 2023/09/14 11:14
<
>
edited by Alexander Schulz-Rosengarten
on 2014/01/23 11:23
on 2014/01/23 11:23
edited by Alexander Schulz-Rosengarten
on 2014/01/03 17:00
on 2014/01/03 17:00
Change comment:
added example for Mapping and TransformationTree creation
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -26,9 +26,9 @@ 26 26 27 27 The structure of the model can be separated into two parts. 28 28 29 -**First part** (upper half) is a tree of transformations. Each Model Wrapper-class is a representation of a model which is transformed. SoModelWrapperare nodes and ModelTransformations are edges. Thus theWrapperrepresenting theinitial-source-model of alltransformationis also the root of a TransformationTree-model.29 +**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. 30 30 31 -**Second part** (lower half) is object-mapping. Instances of models contain EObjects as their elements, which are represented by E ObjectWrapper-class in thismetamodel. TheObjectWrapperof two models are connected with EObjectTransformations-class to expresstheir origination relationship in corresponding model transformation.31 +**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. 32 32 33 33 34 34 ... ... @@ -62,8 +62,8 @@ 62 62 63 63 == Implementation Details == 64 64 65 -* All references to EObjects in EObjectWrapperare 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.66 -* 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 object-mapping.65 +* 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. 66 +* 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. 67 67 * 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. 68 68 69 69 ---- ... ... @@ -70,36 +70,32 @@ 70 70 71 71 == Example == 72 72 73 -In this example we will perform some transformations on SCCharts. 74 - 75 -The source chart is a ABO, the "Hello World" of SCCharts. 76 - 77 -ABO is already a CoreSCChart, so we will perform normalization and a transformation to SCG. 78 - 79 79 === Creating Mapping during Transformation === 80 80 81 - In ordertonote every singleelementtransformationofa model transformation,weusetheTransformationMapping extension.75 +The following code is a modifcation of the tranformation "Spilt Trigger and Effects" of SCCharts. 82 82 83 -After each creation of new Objects for transformed model the mapping must be updated with it's origin information. 77 +{{code title="Modified SCChart Transformation" theme="Eclipse" linenumbers="true" language="java" firstline="1" collapse="true"}} 78 +package de.cau.cs.kieler.ktm.test.transformations 84 84 85 -The codeblock blow show a snipped of SCChartCoreTransformation with additional mapping registration. 86 - 87 - 88 - 89 -{{code title="transformTriggerEffect CodeSnipped" theme="Eclipse" linenumbers="true" language="java" firstline="1" collapse="true"}} 90 -... 91 - @Inject 80 +import com.google.inject.Inject 81 +import de.cau.cs.kieler.ktm.extensions.TransformationMapping 82 +import de.cau.cs.kieler.sccharts.Region 83 +import de.cau.cs.kieler.sccharts.Transition 84 +import de.cau.cs.kieler.sccharts.extensions.SCChartsExtension 85 +/** 86 + * @author als 87 + */ 88 +class SCChartTestTransformation { 89 + @Inject 92 92 extension TransformationMapping 91 + @Inject 92 + extension SCChartsExtension 93 93 94 -... 95 - 96 - // NEW - Mapping access delegation 94 + // -- Mapping Access 97 97 def extractMapping() { 98 98 extractMappingData; 99 99 } 100 100 101 -... 102 - 103 103 //------------------------------------------------------------------------- 104 104 //-- S P L I T T R A N S I T I O N -- 105 105 //------------------------------------------------------------------------- ... ... @@ -110,7 +110,6 @@ 110 110 // Set the T_eff to have T's target state. Set T to have the target C. 111 111 // Add T_eff to C's outgoing transitions. 112 112 def Region transformTriggerEffect(Region rootRegion) { 113 - clearMapping; //NEW - clear previous mapping information to assure a single consistent mapping 114 114 // Clone the complete SCCharts region 115 115 var targetRootRegion = rootRegion.mappedCopy; //NEW - mapping information (changed copy to mappedCopy) 116 116 // Traverse all transitions ... ... @@ -117,110 +117,61 @@ 117 117 for (targetTransition : targetRootRegion.getAllContainedTransitions) { 118 118 targetTransition.transformTriggerEffect(targetRootRegion); 119 119 } 120 - val completeness = checkMappingCompleteness(rootRegion, targetRootRegion); //NEW - DEBUG 121 121 targetRootRegion; 122 122 } 123 123 def void transformTriggerEffect(Transition transition, Region targetRootRegion) { 124 - // Only apply this to transition that have both, a trigger (or is a termination) and one or more effects 125 - if (((transition.trigger != null || !transition.immediate || transition.typeTermination) && !transition.effects.nullOrEmpty) || 126 - transition.effects.size > 1) { 118 + // Only apply this to transition that have both, a trigger and one or more effects 119 + if (((transition.trigger != null || !transition.immediate) && !transition.effects.nullOrEmpty) || transition.effects.size > 1) { 127 127 val targetState = transition.targetState 128 128 val parentRegion = targetState.parentRegion 129 129 val transitionOriginalTarget = transition.targetState 130 130 var Transition lastTransition = transition 131 - val firstEffect = transition.effects.head 132 132 for (effect : transition.effects.immutableCopy) { 133 - // Optimization: Prevent transitions without a trigger 134 - if(transition.immediate && transition.trigger == null && firstEffect == effect) { 135 - // skip 136 - } else { 137 - val effectState = parentRegion.createState(GENERATED_PREFIX + "S") 138 - effectState.mapParents(transition.mappedParents); //NEW - mapping information 139 - effectState.uniqueName 140 - val effectTransition = createImmediateTransition.addEffect(effect) 141 - effectTransition.mapParents(transition.mappedParents); //NEW - mapping information 142 - 143 - effectTransition.setSourceState(effectState) 144 - lastTransition.setTargetState(effectState) 145 - lastTransition = effectTransition 146 - } 125 + val effectState = parentRegion.createState(targetState.id + effect.id) 126 + effectState.mapParents(transition.mappedParents); //NEW - mapping information 127 + effectState.setTypeConnector 128 + val effectTransition = createImmediateTransition.addEffect(effect) 129 + effectTransition.mapParents(transition.mappedParents); //NEW - mapping information 130 + effectTransition.setSourceState(effectState) 131 + lastTransition.setTargetState(effectState) 132 + lastTransition = effectTransition 147 147 } 148 148 lastTransition.setTargetState(transitionOriginalTarget) 149 149 } 150 150 } 137 +} 151 151 {{/code}} 152 152 153 -=== Create TransformationTree === 140 +=== Create TransformationTree with Mapping === 154 154 155 -T he followingcodewill now performeachtransformationstepwiseandupdatesatransformationtree eachstep.142 +To test the transformation and mapping we will transform th following ABO-SCChart. 156 156 157 - 144 +[[image:attach:example_abo.jpeg]] 158 158 146 +The following code snipped performs the transformation on our ABO-example, extracts the mapping and creates a transformation tree. 147 + 159 159 {{code title="Transform and create TranformationTree" theme="Eclipse" linenumbers="true" language="java" firstline="1" collapse="true"}} 160 -aboSplitTE = SCCtransformation.transformTriggerEffect(abo);149 +aboSplitTE = transformation.transformTriggerEffect(abo); 161 161 162 -ModelWrapper aboSplitTEModel = 163 - transformationTree.initializeTransformationTree(SCCtransformation.extractMapping(), "TriggerEffect", abo, "coreSCChart", aboSplitTE, "coreSCChart-splitTriggerEffect"); 151 +Model aboSplitTEModel = transformationTreeExtensions.initializeTransformationTree( 152 + transformation.extractMapping(), 153 + "splitTriggerEffect", 154 + abo, "ABO", 155 + aboSplitTE, "ABO-splitTriEff"); 164 164 165 -aboNormalized = SCCtransformation.transformSurfaceDepth(aboSplitTE); 166 - 167 -ModelWrapper aboNormalizedModel = 168 - transformationTree.addTransformationToTree(SCCtransformation.extractMapping(), aboSplitTEModel, "SurfaceDepth", aboSplitTE, aboNormalized, "normalizedCoreSCChart"); 169 - 170 -aboSCG = SCGtransformation.transformSCG(aboNormalized); 171 - 172 -ModelWrapper aboSCGModel = 173 - transformationTree.addTransformationToTree(SCGtransformation.extractMapping(), aboNormalizedModel, "SCC2SCG", aboNormalized, aboSCG,"SCG"); 174 - 175 -tree = transformationTree.root(aboSCGModel); 157 +tranformationTree = transformationTreeExtensions.root(aboSplitTEModel); 176 176 {{/code}} 177 177 178 - 160 +The result of transformation is the following SCChart. ABO-splitTriEff. 179 179 180 - The resulting TransformationTree has following structureand representing eachstepandmodelof thetransformation.162 +[[image:attach:example_abo_splitTE.jpeg]] 181 181 182 - 164 +Resulting TransformationTree has following structure. 183 183 184 -|=(% colspan="4" style="text-align: center;" %)(% colspan="4" style="text-align: center;" %) 185 -((( 186 186 [[image:attach:example_tree.jpeg]] 187 -))) 188 -|(% colspan="1" style="text-align: center;" %)(% colspan="1" style="text-align: center;" %) 189 -((( 190 -[[image:attach:example_abo.jpeg]] 191 -)))|(% colspan="1" style="text-align: center;" %)(% colspan="1" style="text-align: center;" %) 192 -((( 193 -[[image:attach:example_abo_splitTE.jpeg]] 194 -)))|(% colspan="1" style="text-align: center;" %)(% colspan="1" style="text-align: center;" %) 195 -((( 196 -[[image:attach:example_abo_norm.jpeg]] 197 -)))|(% colspan="1" style="text-align: center;" %)(% colspan="1" style="text-align: center;" %) 198 -((( 199 -[[image:attach:example_abo_scg.jpeg]] 200 -))) 201 201 202 - 168 +Furthermore the TransformationTree now contains the following mapping information. 203 203 204 - FurthermoreTransformationTree now contains mapping information for thewholechain.170 +[[image:attach:example_tree_transformation.jpeg]] 205 205 206 -Now we can use an additional feature of KTM, the resolving of mappings between arbitary models. 207 - 208 -The following code has starts with an instance of the initial ABO SCChart and SCG, along with the TranformationTree above. 209 - 210 - 211 - 212 -{{code title="resolveMapping" theme="Eclipse" linenumbers="true" language="java" firstline="1" collapse="true"}} 213 -@Inject 214 -extension TransformationTreeExtensions 215 - 216 -//Find nodes of model instances in tree 217 -val aboSCCModelWrapper = transformationTree.findModel(aboSCC,"coreSCChart"); 218 -val aboSCGModelWrapper = transformationTree.findModel(aboSCG,"SCG"); 219 - 220 -//resolve 221 -val mapping = resolvemapping(aboSCCModelWrapper, aboSCC, aboSCGModelWrapper, aboSCG); 222 -{{/code}} 223 - 224 - 225 - 226 -The returned mapping is a multi mapping between all object in aboSCC and their resulting objects in aboSCG. 172 +Here you can see the effect of the transformation causing the transformation to split up.
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -86515 961 +8651563 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/86515 96/Transformation Mapping (KTM)1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/8651563/Transformation Mapping (KTM)