Hide last authors
Alexander Schulz-Rosengarten 5.1 1 = KTM - KIELER Transformation Mapping =
2
Alexander Schulz-Rosengarten 17.1 3 {{panel bgColor="orange" title="DEPRECATED"}}
Alexander Schulz-Rosengarten 19.1 4 This article is deprecated. KTM was redesigned is now available as KiTT included in KiCool.
Alexander Schulz-Rosengarten 17.1 5 {{/panel}}
6
Alexander Schulz-Rosengarten 18.1 7 \\
Alexander Schulz-Rosengarten 6.1 8
Alexander Schulz-Rosengarten 7.1 9 === Topics ===
Alexander Schulz-Rosengarten 6.1 10
11
Alexander Schulz-Rosengarten 7.1 12
Alexander Schulz-Rosengarten 6.1 13 {{toc maxLevel="2" minLevel="2"/}}
14
15 This subproject provides a tracing mechanism for arbitary model-elements across multiple model transformations, based on EMF.
16
Alexander Schulz-Rosengarten 8.1 17 The main propose of KTM is to allow bidirectional information transfer between abstract models and their resultant transformed models.
Alexander Schulz-Rosengarten 6.1 18
19 ----
20
21 == Transformation Tree Model ==
22
Alexander Schulz-Rosengarten 18.1 23 \\
Alexander Schulz-Rosengarten 6.1 24
25 To offer a mapping between model-elements during multiple transformations KTM introduces a model called TransformationTree to represent these relations.
26
27 It is based on an EMF-Metamodel.
28
Alexander Schulz-Rosengarten 7.1 29 [[image:attach:als-ktmt-metamodel.png]]
Alexander Schulz-Rosengarten 6.1 30
31 The structure of the model can be separated into two parts.
32
Alexander Schulz-Rosengarten 11.1 33 **First part** (upper half) is a tree of transformations. Each ModelWrapper-class is a representation of a model which is transformed. So ModelWrapper are nodes and ModelTransformations are edges. Thus the ModelWrapper representing the initial-source-model of all transformation is also the root of a TransformationTree-model.
Alexander Schulz-Rosengarten 6.1 34
Alexander Schulz-Rosengarten 11.1 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.
Alexander Schulz-Rosengarten 6.1 36
Alexander Schulz-Rosengarten 18.1 37 \\
Alexander Schulz-Rosengarten 6.1 38
39 An abstract example of an instance of this model:
40
Alexander Schulz-Rosengarten 7.1 41 [[image:attach:abstract_example_tree.png]]
Alexander Schulz-Rosengarten 6.1 42
43 ----
44
45 == Extensions ==
46
47 Two classes are provided by this project to extend functionality of the core model.
48
Alexander Schulz-Rosengarten 7.1 49 === TransformationMapping ([[JavaDoc>>attach:TransformationMapping.html]]) ===
Alexander Schulz-Rosengarten 6.1 50
Alexander Schulz-Rosengarten 8.1 51 The main propose of this class is generation of a object-mapping during transformation process.
Alexander Schulz-Rosengarten 6.1 52
Alexander Schulz-Rosengarten 8.1 53 Therefor it provides different functions for incremental registering of single parent-child-relations between EObjects.
Alexander Schulz-Rosengarten 6.1 54
55 Furthermore, the extension allows to extract the mapping and check completeness of mapped elements against content of transformed models.
56
Alexander Schulz-Rosengarten 7.1 57 === TransformationTreeExtensions ([[JavaDoc>>attach:TransformationTreeExtensions.html]]) ===
Alexander Schulz-Rosengarten 6.1 58
Alexander Schulz-Rosengarten 7.1 59 This class provides all functionalities to easily traverse and search in a TransformationTree.
Alexander Schulz-Rosengarten 6.1 60
61 Furthermore, it allows to modify trees by creating, deleting or appending new transformations and transformed models.
62
Alexander Schulz-Rosengarten 8.1 63 Additionally this extension provides functionality to extract a concrete mapping between two arbitary model intances from a TransformationTree.
64
Alexander Schulz-Rosengarten 6.1 65 ----
66
67 == Implementation Details ==
68
Alexander Schulz-Rosengarten 11.1 69 * All references to EObjects in EObjectWrapper 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.
70 * 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.
Alexander Schulz-Rosengarten 9.1 71 * 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.
Alexander Schulz-Rosengarten 6.1 72
Alexander Schulz-Rosengarten 7.1 73 ----
Alexander Schulz-Rosengarten 6.1 74
75 == Example ==
76
Alexander Schulz-Rosengarten 12.1 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
Alexander Schulz-Rosengarten 10.1 83 === Creating Mapping during Transformation ===
84
Alexander Schulz-Rosengarten 12.1 85 In order to note every single element transformation of a model transformation, we use the TransformationMapping extension.
Alexander Schulz-Rosengarten 10.1 86
Alexander Schulz-Rosengarten 12.1 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
Alexander Schulz-Rosengarten 18.1 91 \\
Alexander Schulz-Rosengarten 12.1 92
Alexander Schulz-Rosengarten 18.1 93 {{code language="java" theme="Eclipse" firstline="1" title="transformTriggerEffect CodeSnipped" linenumbers="true" collapse="true"}}
Alexander Schulz-Rosengarten 12.1 94 ...
95  @Inject
Alexander Schulz-Rosengarten 10.1 96 extension TransformationMapping
Alexander Schulz-Rosengarten 12.1 97
98 ...
99
Alexander Schulz-Rosengarten 11.1 100 // NEW - Mapping access delegation
Alexander Schulz-Rosengarten 10.1 101 def extractMapping() {
102 extractMappingData;
103 }
Alexander Schulz-Rosengarten 12.1 104
105 ...
106
Alexander Schulz-Rosengarten 10.1 107 //-------------------------------------------------------------------------
108 //-- S P L I T T R A N S I T I O N --
109 //-------------------------------------------------------------------------
110 // For every transition T that has both, a trigger and an effect do the following:
111 // For every effect:
112 // Create a conditional C and add it to the parent of T's source state S_src.
113 // create a new true triggered immediate effect transition T_eff and move all effects of T to T_eff.
114 // Set the T_eff to have T's target state. Set T to have the target C.
115 // Add T_eff to C's outgoing transitions.
116 def Region transformTriggerEffect(Region rootRegion) {
Alexander Schulz-Rosengarten 11.1 117 clearMapping; //NEW - clear previous mapping information to assure a single consistent mapping
Alexander Schulz-Rosengarten 10.1 118 // Clone the complete SCCharts region
119 var targetRootRegion = rootRegion.mappedCopy; //NEW - mapping information (changed copy to mappedCopy)
120 // Traverse all transitions
121 for (targetTransition : targetRootRegion.getAllContainedTransitions) {
122 targetTransition.transformTriggerEffect(targetRootRegion);
123 }
Alexander Schulz-Rosengarten 12.1 124 val completeness = checkMappingCompleteness(rootRegion, targetRootRegion); //NEW - DEBUG
125 targetRootRegion;
Alexander Schulz-Rosengarten 10.1 126 }
127 def void transformTriggerEffect(Transition transition, Region targetRootRegion) {
Alexander Schulz-Rosengarten 12.1 128 // Only apply this to transition that have both, a trigger (or is a termination) and one or more effects
129 if (((transition.trigger != null || !transition.immediate || transition.typeTermination) && !transition.effects.nullOrEmpty) ||
Alexander Schulz-Rosengarten 11.1 130 transition.effects.size > 1) {
Alexander Schulz-Rosengarten 10.1 131 val targetState = transition.targetState
132 val parentRegion = targetState.parentRegion
133 val transitionOriginalTarget = transition.targetState
134 var Transition lastTransition = transition
Alexander Schulz-Rosengarten 12.1 135 val firstEffect = transition.effects.head
Alexander Schulz-Rosengarten 10.1 136 for (effect : transition.effects.immutableCopy) {
Alexander Schulz-Rosengarten 12.1 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 }
Alexander Schulz-Rosengarten 10.1 151 }
152 lastTransition.setTargetState(transitionOriginalTarget)
153 }
154 }
155 {{/code}}
156
Alexander Schulz-Rosengarten 12.1 157 === Create TransformationTree ===
Alexander Schulz-Rosengarten 10.1 158
Alexander Schulz-Rosengarten 12.1 159 The following code will now perform each transformation stepwise and updates a transformation tree each step.
Alexander Schulz-Rosengarten 10.1 160
Alexander Schulz-Rosengarten 18.1 161 \\
Alexander Schulz-Rosengarten 10.1 162
Alexander Schulz-Rosengarten 18.1 163 {{code language="java" theme="Eclipse" firstline="1" title="Transform and create TranformationTree" linenumbers="true" collapse="true"}}
Alexander Schulz-Rosengarten 12.1 164 aboSplitTE = SCCtransformation.transformTriggerEffect(abo);
Alexander Schulz-Rosengarten 10.1 165
Alexander Schulz-Rosengarten 12.1 166 ModelWrapper aboSplitTEModel =
167 transformationTree.initializeTransformationTree(SCCtransformation.extractMapping(), "TriggerEffect", abo, "coreSCChart", aboSplitTE, "coreSCChart-splitTriggerEffect");
Alexander Schulz-Rosengarten 10.1 168
Alexander Schulz-Rosengarten 12.1 169 aboNormalized = SCCtransformation.transformSurfaceDepth(aboSplitTE);
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);
Alexander Schulz-Rosengarten 10.1 180 {{/code}}
181
Alexander Schulz-Rosengarten 18.1 182 \\
Alexander Schulz-Rosengarten 10.1 183
Alexander Schulz-Rosengarten 12.1 184 The resulting TransformationTree has following structure and representing each step and model of the transformation.
Alexander Schulz-Rosengarten 10.1 185
Alexander Schulz-Rosengarten 18.1 186 \\
Alexander Schulz-Rosengarten 10.1 187
Alexander Schulz-Rosengarten 18.1 188 (% class="wrapped" %)
189 |=(% style="text-align: center;" colspan="4" %)(% style="text-align: center;" colspan="4" %)
Alexander Schulz-Rosengarten 12.1 190 (((
Alexander Schulz-Rosengarten 18.1 191 (% class="content-wrapper" %)
192 (((
Alexander Schulz-Rosengarten 10.1 193 [[image:attach:example_tree.jpeg]]
Alexander Schulz-Rosengarten 12.1 194 )))
Alexander Schulz-Rosengarten 18.1 195 )))
196 |(% style="text-align: center;" colspan="1" %)(% style="text-align: center;" colspan="1" %)
Alexander Schulz-Rosengarten 12.1 197 (((
Alexander Schulz-Rosengarten 18.1 198 (% class="content-wrapper" %)
199 (((
Alexander Schulz-Rosengarten 12.1 200 [[image:attach:example_abo.jpeg]]
Alexander Schulz-Rosengarten 18.1 201 )))
202 )))|(% style="text-align: center;" colspan="1" %)(% style="text-align: center;" colspan="1" %)
Alexander Schulz-Rosengarten 12.1 203 (((
Alexander Schulz-Rosengarten 18.1 204 (% class="content-wrapper" %)
205 (((
Alexander Schulz-Rosengarten 12.1 206 [[image:attach:example_abo_splitTE.jpeg]]
Alexander Schulz-Rosengarten 18.1 207 )))
208 )))|(% style="text-align: center;" colspan="1" %)(% style="text-align: center;" colspan="1" %)
Alexander Schulz-Rosengarten 12.1 209 (((
Alexander Schulz-Rosengarten 18.1 210 (% class="content-wrapper" %)
211 (((
Alexander Schulz-Rosengarten 12.1 212 [[image:attach:example_abo_norm.jpeg]]
Alexander Schulz-Rosengarten 18.1 213 )))
214 )))|(% style="text-align: center;" colspan="1" %)(% style="text-align: center;" colspan="1" %)
Alexander Schulz-Rosengarten 12.1 215 (((
Alexander Schulz-Rosengarten 18.1 216 (% class="content-wrapper" %)
217 (((
Alexander Schulz-Rosengarten 12.1 218 [[image:attach:example_abo_scg.jpeg]]
219 )))
Alexander Schulz-Rosengarten 18.1 220 )))
Alexander Schulz-Rosengarten 10.1 221
Alexander Schulz-Rosengarten 18.1 222 \\
Alexander Schulz-Rosengarten 10.1 223
Alexander Schulz-Rosengarten 12.1 224 Furthermore the TransformationTree now contains mapping information for the whole transformation chain.
Alexander Schulz-Rosengarten 10.1 225
Alexander Schulz-Rosengarten 12.1 226 Now we can use an additional feature of KTM, the resolving of mappings between arbitary models.
Alexander Schulz-Rosengarten 11.1 227
Alexander Schulz-Rosengarten 12.1 228 The following code has starts with an instance of the initial ABO SCChart and SCG, along with the TranformationTree above.
229
Alexander Schulz-Rosengarten 18.1 230 \\
Alexander Schulz-Rosengarten 12.1 231
Alexander Schulz-Rosengarten 18.1 232 {{code language="java" theme="Eclipse" firstline="1" title="resolveMapping" linenumbers="true" collapse="true"}}
Alexander Schulz-Rosengarten 12.1 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
Alexander Schulz-Rosengarten 18.1 244 \\
Alexander Schulz-Rosengarten 12.1 245
246 The returned mapping is a multi mapping between all object in aboSCC and their resulting objects in aboSCG.
Alexander Schulz-Rosengarten 13.1 247
Alexander Schulz-Rosengarten 14.1 248 This mapping can now displayed in models or used for various information propagation between elements of the models.
Alexander Schulz-Rosengarten 13.1 249
250 [[image:attach:example_abo_resolved.jpeg]]
251
Alexander Schulz-Rosengarten 18.1 252 \\
Alexander Schulz-Rosengarten 13.1 253
Alexander Schulz-Rosengarten 14.1 254 Also a more detailed view is available, showing all EObjects relation.
Alexander Schulz-Rosengarten 13.1 255
Alexander Schulz-Rosengarten 18.1 256 \\
Alexander Schulz-Rosengarten 13.1 257
258 [[image:attach:example_abo_resolved_elements.jpeg]]
259
Alexander Schulz-Rosengarten 16.1 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
Alexander Schulz-Rosengarten 18.1 280 \\