Changes for page Transformation Mapping (KTM)
Last modified by Richard Kreissig on 2023/09/14 11:14
<
>
edited by Alexander Schulz-Rosengarten
on 2018/11/22 14:46
on 2018/11/22 14:46
edited by Alexander Schulz-Rosengarten
on 2014/01/10 11:28
on 2014/01/10 11:28
Change comment:
update according to metamodel changes
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,11 +1,7 @@ 1 1 = KTM - KIELER Transformation Mapping = 2 2 3 -{{panel bgColor="orange" title="Deprecated since 0.11"}} 4 -This article is deprecated. KTM was redesigned is now available as KiTT included in KiCool. 5 -{{/panel}} 3 + 6 6 7 -\\ 8 - 9 9 === Topics === 10 10 11 11 ... ... @@ -20,7 +20,7 @@ 20 20 21 21 == Transformation Tree Model == 22 22 23 - \\19 + 24 24 25 25 To offer a mapping between model-elements during multiple transformations KTM introduces a model called TransformationTree to represent these relations. 26 26 ... ... @@ -34,7 +34,7 @@ 34 34 35 35 **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. 36 36 37 - \\33 + 38 38 39 39 An abstract example of an instance of this model: 40 40 ... ... @@ -74,36 +74,29 @@ 74 74 75 75 == Example == 76 76 77 -In this example we will perform some transformations on SCCharts. 78 - 79 -The source chart is a ABO, the "Hello World" of SCCharts. 80 - 81 -ABO is already a CoreSCChart, so we will perform normalization and a transformation to SCG. 82 - 83 83 === Creating Mapping during Transformation === 84 84 85 - In ordertonote every singleelementtransformationofa model transformation,weusetheTransformationMapping extension.75 +The following code is a modifcation of the tranformation "Spilt Trigger and Effects" of SCCharts. 86 86 87 -After each creation of new Objects for transformed model the mapping must be updated with it's origin information. 88 - 89 -The codeblock blow show a snipped of SCChartCoreTransformation with additional mapping registration. 90 - 91 -\\ 92 - 93 -{{code language="java" theme="Eclipse" firstline="1" title="transformTriggerEffect CodeSnipped" linenumbers="true" collapse="true"}} 94 -... 95 - @Inject 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 79 +import com.google.inject.Inject 80 +import de.cau.cs.kieler.ktm.extensions.TransformationMapping 81 +import de.cau.cs.kieler.sccharts.Region 82 +import de.cau.cs.kieler.sccharts.Transition 83 +import de.cau.cs.kieler.sccharts.extensions.SCChartsExtension 84 +/** 85 + * @author als 86 + */ 87 +class SCChartTestTransformation { 88 + @Inject 96 96 extension TransformationMapping 97 - 98 -... 99 - 90 + @Inject 91 + extension SCChartsExtension 100 100 // NEW - Mapping access delegation 101 101 def extractMapping() { 102 102 extractMappingData; 103 103 } 104 - 105 -... 106 - 107 107 //------------------------------------------------------------------------- 108 108 //-- S P L I T T R A N S I T I O N -- 109 109 //------------------------------------------------------------------------- ... ... @@ -121,160 +121,70 @@ 121 121 for (targetTransition : targetRootRegion.getAllContainedTransitions) { 122 122 targetTransition.transformTriggerEffect(targetRootRegion); 123 123 } 124 - val completeness = checkMappingCompleteness(rootRegion, targetRootRegion); //NEW - DEBUG 125 - targetRootRegion; 113 + //check if mapping is complete (only for test proposes) 114 + val diff = rootRegion.checkMappingCompleteness(targetRootRegion); 115 + if (diff.key.empty && diff.value.empty) { 116 + targetRootRegion; 117 + } else { 118 + null 119 + } 126 126 } 127 127 def void transformTriggerEffect(Transition transition, Region targetRootRegion) { 128 - // Only apply this to transition that have both, a trigger (or isatermination) and one or more effects129 - if (((transition.trigger != null || !transition.immediate || transition.typeTermination) && !transition.effects.nullOrEmpty) ||122 + // Only apply this to transition that have both, a trigger and one or more effects 123 + if (((transition.trigger != null || !transition.immediate) && !transition.effects.nullOrEmpty) || 130 130 transition.effects.size > 1) { 131 131 val targetState = transition.targetState 132 132 val parentRegion = targetState.parentRegion 133 133 val transitionOriginalTarget = transition.targetState 134 134 var Transition lastTransition = transition 135 - val firstEffect = transition.effects.head 136 136 for (effect : transition.effects.immutableCopy) { 137 - // Optimization: Prevent transitions without a trigger 138 - if(transition.immediate && transition.trigger == null && firstEffect == effect) { 139 - // skip 140 - } else { 141 - val effectState = parentRegion.createState(GENERATED_PREFIX + "S") 142 - effectState.mapParents(transition.mappedParents); //NEW - mapping information 143 - effectState.uniqueName 144 - val effectTransition = createImmediateTransition.addEffect(effect) 145 - effectTransition.mapParents(transition.mappedParents); //NEW - mapping information 146 - 147 - effectTransition.setSourceState(effectState) 148 - lastTransition.setTargetState(effectState) 149 - lastTransition = effectTransition 150 - } 130 + val effectState = parentRegion.createState(targetState.id + effect.id) 131 + effectState.mapParents(transition.mappedParents); //NEW - mapping information 132 + effectState.setTypeConnector 133 + val effectTransition = createImmediateTransition.addEffect(effect) 134 + effectTransition.mapParents(transition.mappedParents); //NEW - mapping information 135 + effectTransition.setSourceState(effectState) 136 + lastTransition.setTargetState(effectState) 137 + lastTransition = effectTransition 151 151 } 152 152 lastTransition.setTargetState(transitionOriginalTarget) 153 153 } 154 154 } 142 +} 155 155 {{/code}} 156 156 157 -=== Create TransformationTree === 145 +=== Create TransformationTree with Mapping === 158 158 159 -T he followingcodewill now performeachtransformationstepwiseandupdatesatransformationtree eachstep.147 +To test the transformation and mapping we will transform th following ABO-SCChart. 160 160 161 - \\149 +[[image:attach:example_abo.jpeg]] 162 162 163 -{{code language="java" theme="Eclipse" firstline="1" title="Transform and create TranformationTree" linenumbers="true" collapse="true"}} 164 -aboSplitTE = SCCtransformation.transformTriggerEffect(abo); 151 +The following code snipped performs the transformation on our ABO-example, extracts the mapping and creates a transformation tree. 165 165 166 - ModelWrapper aboSplitTEModel =167 - transformationTree.initializeTransformationTree(SCCtransformation.extractMapping(), "TriggerEffect",abo, "coreSCChart", aboSplitTE, "coreSCChart-splitTriggerEffect");153 +{{code title="Transform and create TranformationTree" theme="Eclipse" linenumbers="true" language="java" firstline="1" collapse="true"}} 154 +aboSplitTE = transformation.transformTriggerEffect(abo); 168 168 169 -aboNormalized = SCCtransformation.transformSurfaceDepth(aboSplitTE); 156 +Model aboSplitTEModel = transformationTreeExtensions.initializeTransformationTree( 157 + transformation.extractMapping(), 158 + "splitTriggerEffect", 159 + abo, "coreSCChart", 160 + aboSplitTE, "coreSCChart-splitTriggerEffect"); 170 170 171 -ModelWrapper aboNormalizedModel = 172 - transformationTree.addTransformationToTree(SCCtransformation.extractMapping(), aboSplitTEModel, "SurfaceDepth", aboSplitTE, aboNormalized, "normalizedCoreSCChart"); 173 - 174 -aboSCG = SCGtransformation.transformSCG(aboNormalized); 175 - 176 -ModelWrapper aboSCGModel = 177 - transformationTree.addTransformationToTree(SCGtransformation.extractMapping(), aboNormalizedModel, "SCC2SCG", aboNormalized, aboSCG,"SCG"); 178 - 179 -tree = transformationTree.root(aboSCGModel); 162 +tranformationTree = transformationTreeExtensions.root(aboSplitTEModel); 180 180 {{/code}} 181 181 182 - \\165 +The result of transformation is the following SCChart. ABO-splitTriggerEffect. 183 183 184 - The resulting TransformationTree has following structureand representing eachstepandmodelof thetransformation.167 +[[image:attach:example_abo_splitTE.jpeg]] 185 185 186 - \\169 +Resulting TransformationTree has following structure. 187 187 188 -(% class="wrapped" %) 189 -|=(% style="text-align: center;" colspan="4" %)(% style="text-align: center;" colspan="4" %) 190 -((( 191 -(% class="content-wrapper" %) 192 -((( 193 193 [[image:attach:example_tree.jpeg]] 194 -))) 195 -))) 196 -|(% style="text-align: center;" colspan="1" %)(% style="text-align: center;" colspan="1" %) 197 -((( 198 -(% class="content-wrapper" %) 199 -((( 200 -[[image:attach:example_abo.jpeg]] 201 -))) 202 -)))|(% style="text-align: center;" colspan="1" %)(% style="text-align: center;" colspan="1" %) 203 -((( 204 -(% class="content-wrapper" %) 205 -((( 206 -[[image:attach:example_abo_splitTE.jpeg]] 207 -))) 208 -)))|(% style="text-align: center;" colspan="1" %)(% style="text-align: center;" colspan="1" %) 209 -((( 210 -(% class="content-wrapper" %) 211 -((( 212 -[[image:attach:example_abo_norm.jpeg]] 213 -))) 214 -)))|(% style="text-align: center;" colspan="1" %)(% style="text-align: center;" colspan="1" %) 215 -((( 216 -(% class="content-wrapper" %) 217 -((( 218 -[[image:attach:example_abo_scg.jpeg]] 219 -))) 220 -))) 221 221 222 - \\173 +Furthermore the TransformationTree now contains the following mapping information. 223 223 224 - FurthermoreTransformationTree now contains mapping information for thewholechain.175 +[[image:attach:example_tree_transformation.jpeg]] 225 225 226 - Now we canusean additionalfeatureofKTM,the resolvingof mappingsbetweenarbitarymodels.177 +Here you can see the effect of the transformation causing the transformation to split up. 227 227 228 -The following code has starts with an instance of the initial ABO SCChart and SCG, along with the TranformationTree above. 229 - 230 -\\ 231 - 232 -{{code language="java" theme="Eclipse" firstline="1" title="resolveMapping" linenumbers="true" collapse="true"}} 233 -@Inject 234 -extension TransformationTreeExtensions 235 - 236 -//Find nodes of model instances in tree 237 -val aboSCCModelWrapper = transformationTree.findModel(aboSCC,"coreSCChart"); 238 -val aboSCGModelWrapper = transformationTree.findModel(aboSCG,"SCG"); 239 - 240 -//resolve 241 -val mapping = resolvemapping(aboSCCModelWrapper, aboSCC, aboSCGModelWrapper, aboSCG); 242 -{{/code}} 243 - 244 -\\ 245 - 246 -The returned mapping is a multi mapping between all object in aboSCC and their resulting objects in aboSCG. 247 - 248 -This mapping can now displayed in models or used for various information propagation between elements of the models. 249 - 250 -[[image:attach:example_abo_resolved.jpeg]] 251 - 252 -\\ 253 - 254 -Also a more detailed view is available, showing all EObjects relation. 255 - 256 -\\ 257 - 258 -[[image:attach:example_abo_resolved_elements.jpeg]] 259 - 260 -== Visualisation == 261 - 262 -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//'. 263 - 264 -=== Diagram Options === 265 - 266 -//Model Visualisation//: If enabled tries to visaulize selected models with KLighD else a EObject-represenation is created. 267 - 268 -//EObject Attributes//: If enabled shows Attributes of EObject in EObject-represenation. 269 - 270 -//Selective mapping edges//: If enabled shows only selected mapping edges. 271 - 272 -=== Interaction === 273 - 274 -//CTRL+CLICK//: Selects a Node in TransformationTree as source and displays its represented model. 275 - 276 -//SHIFT+CLICK//: Selects a Node in TransformationTree as target, displays both models and the resolved mapping as edges (currenly only between States/Regions). 277 - 278 -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. 279 - 280 -\\ 179 +[[image:attach:als-ktm-splitTriggerEffect-detail.jpg]]
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 - 508232231 +8651594 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/ 50823223/Transformation Mapping (KTM)1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/8651594/Transformation Mapping (KTM)