Hide last authors
Alexander Schulz-Rosengarten 5.1 1 = KTM - KIELER Transformation Mapping =
2
Richard Kreissig 24.1 3 == Deprecated since 0.12 ==
Alexander Schulz-Rosengarten 21.1 4 This article is deprecated. The described features are no longer available in current releases.
5
6 KTM was redesigned is now available as KiTT included in KiCool.
Alexander Schulz-Rosengarten 17.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
23
24 To offer a mapping between model-elements during multiple transformations KTM introduces a model called TransformationTree to represent these relations.
25
26 It is based on an EMF-Metamodel.
27
Alexander Schulz-Rosengarten 7.1 28 [[image:attach:als-ktmt-metamodel.png]]
Alexander Schulz-Rosengarten 6.1 29
30 The structure of the model can be separated into two parts.
31
Alexander Schulz-Rosengarten 11.1 32 **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 33
Alexander Schulz-Rosengarten 11.1 34 **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 35
36
37 An abstract example of an instance of this model:
38
Alexander Schulz-Rosengarten 7.1 39 [[image:attach:abstract_example_tree.png]]
Alexander Schulz-Rosengarten 6.1 40
41 ----
42
43 == Extensions ==
44
45 Two classes are provided by this project to extend functionality of the core model.
46
Alexander Schulz-Rosengarten 7.1 47 === TransformationMapping ([[JavaDoc>>attach:TransformationMapping.html]]) ===
Alexander Schulz-Rosengarten 6.1 48
Alexander Schulz-Rosengarten 8.1 49 The main propose of this class is generation of a object-mapping during transformation process.
Alexander Schulz-Rosengarten 6.1 50
Alexander Schulz-Rosengarten 8.1 51 Therefor it provides different functions for incremental registering of single parent-child-relations between EObjects.
Alexander Schulz-Rosengarten 6.1 52
53 Furthermore, the extension allows to extract the mapping and check completeness of mapped elements against content of transformed models.
54
Alexander Schulz-Rosengarten 7.1 55 === TransformationTreeExtensions ([[JavaDoc>>attach:TransformationTreeExtensions.html]]) ===
Alexander Schulz-Rosengarten 6.1 56
Alexander Schulz-Rosengarten 7.1 57 This class provides all functionalities to easily traverse and search in a TransformationTree.
Alexander Schulz-Rosengarten 6.1 58
59 Furthermore, it allows to modify trees by creating, deleting or appending new transformations and transformed models.
60
Alexander Schulz-Rosengarten 8.1 61 Additionally this extension provides functionality to extract a concrete mapping between two arbitary model intances from a TransformationTree.
62
Alexander Schulz-Rosengarten 6.1 63 ----
64
65 == Implementation Details ==
66
Alexander Schulz-Rosengarten 11.1 67 * 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.
68 * 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 69 * 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 70
Alexander Schulz-Rosengarten 7.1 71 ----
Alexander Schulz-Rosengarten 6.1 72
73 == Example ==
74
Alexander Schulz-Rosengarten 12.1 75 In this example we will perform some transformations on SCCharts.
76
77 The source chart is a ABO, the "Hello World" of SCCharts.
78
79 ABO is already a CoreSCChart, so we will perform normalization and a transformation to SCG.
80
Alexander Schulz-Rosengarten 10.1 81 === Creating Mapping during Transformation ===
82
Alexander Schulz-Rosengarten 12.1 83 In order to note every single element transformation of a model transformation, we use the TransformationMapping extension.
Alexander Schulz-Rosengarten 10.1 84
Alexander Schulz-Rosengarten 12.1 85 After each creation of new Objects for transformed model the mapping must be updated with it's origin information.
86
87 The codeblock blow show a snipped of SCChartCoreTransformation with additional mapping registration.
88
Richard Kreissig 24.1 89 {{code language="java" theme="Eclipse" firstline="1" linenumbers="true" collapse="true" title="
90 transformTriggerEffect CodeSnipped"}}
Alexander Schulz-Rosengarten 12.1 91 ...
92  @Inject
Alexander Schulz-Rosengarten 10.1 93 extension TransformationMapping
Alexander Schulz-Rosengarten 12.1 94
95 ...
96
Alexander Schulz-Rosengarten 11.1 97 // NEW - Mapping access delegation
Alexander Schulz-Rosengarten 10.1 98 def extractMapping() {
99 extractMappingData;
100 }
Alexander Schulz-Rosengarten 12.1 101
102 ...
103
Alexander Schulz-Rosengarten 10.1 104 //-------------------------------------------------------------------------
105 //-- S P L I T T R A N S I T I O N --
106 //-------------------------------------------------------------------------
107 // For every transition T that has both, a trigger and an effect do the following:
108 // For every effect:
109 // Create a conditional C and add it to the parent of T's source state S_src.
110 // create a new true triggered immediate effect transition T_eff and move all effects of T to T_eff.
111 // Set the T_eff to have T's target state. Set T to have the target C.
112 // Add T_eff to C's outgoing transitions.
113 def Region transformTriggerEffect(Region rootRegion) {
Alexander Schulz-Rosengarten 11.1 114 clearMapping; //NEW - clear previous mapping information to assure a single consistent mapping
Alexander Schulz-Rosengarten 10.1 115 // Clone the complete SCCharts region
116 var targetRootRegion = rootRegion.mappedCopy; //NEW - mapping information (changed copy to mappedCopy)
117 // Traverse all transitions
118 for (targetTransition : targetRootRegion.getAllContainedTransitions) {
119 targetTransition.transformTriggerEffect(targetRootRegion);
120 }
Alexander Schulz-Rosengarten 12.1 121 val completeness = checkMappingCompleteness(rootRegion, targetRootRegion); //NEW - DEBUG
122 targetRootRegion;
Alexander Schulz-Rosengarten 10.1 123 }
124 def void transformTriggerEffect(Transition transition, Region targetRootRegion) {
Alexander Schulz-Rosengarten 12.1 125 // Only apply this to transition that have both, a trigger (or is a termination) and one or more effects
126 if (((transition.trigger != null || !transition.immediate || transition.typeTermination) && !transition.effects.nullOrEmpty) ||
Alexander Schulz-Rosengarten 11.1 127 transition.effects.size > 1) {
Alexander Schulz-Rosengarten 10.1 128 val targetState = transition.targetState
129 val parentRegion = targetState.parentRegion
130 val transitionOriginalTarget = transition.targetState
131 var Transition lastTransition = transition
Alexander Schulz-Rosengarten 12.1 132 val firstEffect = transition.effects.head
Alexander Schulz-Rosengarten 10.1 133 for (effect : transition.effects.immutableCopy) {
Alexander Schulz-Rosengarten 12.1 134 // Optimization: Prevent transitions without a trigger
135 if(transition.immediate && transition.trigger == null && firstEffect == effect) {
136 // skip
137 } else {
138 val effectState = parentRegion.createState(GENERATED_PREFIX + "S")
139 effectState.mapParents(transition.mappedParents); //NEW - mapping information
140 effectState.uniqueName
141 val effectTransition = createImmediateTransition.addEffect(effect)
142 effectTransition.mapParents(transition.mappedParents); //NEW - mapping information
143
144 effectTransition.setSourceState(effectState)
145 lastTransition.setTargetState(effectState)
146 lastTransition = effectTransition
147 }
Alexander Schulz-Rosengarten 10.1 148 }
149 lastTransition.setTargetState(transitionOriginalTarget)
150 }
151 }
152 {{/code}}
153
Alexander Schulz-Rosengarten 12.1 154 === Create TransformationTree ===
Alexander Schulz-Rosengarten 10.1 155
Alexander Schulz-Rosengarten 12.1 156 The following code will now perform each transformation stepwise and updates a transformation tree each step.
Alexander Schulz-Rosengarten 10.1 157
Richard Kreissig 24.1 158 {{code language="java" theme="Eclipse" firstline="1" linenumbers="true" collapse="true" title="
159 Transform and create TranformationTree"}}
Alexander Schulz-Rosengarten 12.1 160 aboSplitTE = SCCtransformation.transformTriggerEffect(abo);
Alexander Schulz-Rosengarten 10.1 161
Alexander Schulz-Rosengarten 12.1 162 ModelWrapper aboSplitTEModel =
163 transformationTree.initializeTransformationTree(SCCtransformation.extractMapping(), "TriggerEffect", abo, "coreSCChart", aboSplitTE, "coreSCChart-splitTriggerEffect");
Alexander Schulz-Rosengarten 10.1 164
Alexander Schulz-Rosengarten 12.1 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);
Alexander Schulz-Rosengarten 10.1 176 {{/code}}
177
178
Alexander Schulz-Rosengarten 12.1 179 The resulting TransformationTree has following structure and representing each step and model of the transformation.
Alexander Schulz-Rosengarten 10.1 180
181
Alexander Schulz-Rosengarten 18.1 182 (% class="wrapped" %)
Richard Kreissig 24.1 183 |=(% colspan="4" style="text-align: center;" %)(% colspan="4" style="text-align: center;" %)
Alexander Schulz-Rosengarten 12.1 184 (((
Alexander Schulz-Rosengarten 18.1 185 (% class="content-wrapper" %)
186 (((
Alexander Schulz-Rosengarten 10.1 187 [[image:attach:example_tree.jpeg]]
Alexander Schulz-Rosengarten 12.1 188 )))
Alexander Schulz-Rosengarten 18.1 189 )))
Richard Kreissig 24.1 190 |(% colspan="1" style="text-align:center" %)(% colspan="1" style="text-align: center;" %)
Alexander Schulz-Rosengarten 12.1 191 (((
Alexander Schulz-Rosengarten 18.1 192 (% class="content-wrapper" %)
193 (((
Alexander Schulz-Rosengarten 12.1 194 [[image:attach:example_abo.jpeg]]
Alexander Schulz-Rosengarten 18.1 195 )))
Richard Kreissig 24.1 196 )))|(% colspan="1" style="text-align:center" %)(% colspan="1" style="text-align: center;" %)
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_splitTE.jpeg]]
Alexander Schulz-Rosengarten 18.1 201 )))
Richard Kreissig 24.1 202 )))|(% colspan="1" style="text-align:center" %)(% colspan="1" style="text-align: center;" %)
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_norm.jpeg]]
Alexander Schulz-Rosengarten 18.1 207 )))
Richard Kreissig 24.1 208 )))|(% colspan="1" style="text-align:center" %)(% colspan="1" style="text-align: center;" %)
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_scg.jpeg]]
213 )))
Alexander Schulz-Rosengarten 18.1 214 )))
Alexander Schulz-Rosengarten 10.1 215
216
Alexander Schulz-Rosengarten 12.1 217 Furthermore the TransformationTree now contains mapping information for the whole transformation chain.
Alexander Schulz-Rosengarten 10.1 218
Alexander Schulz-Rosengarten 12.1 219 Now we can use an additional feature of KTM, the resolving of mappings between arbitary models.
Alexander Schulz-Rosengarten 11.1 220
Alexander Schulz-Rosengarten 12.1 221 The following code has starts with an instance of the initial ABO SCChart and SCG, along with the TranformationTree above.
222
Richard Kreissig 24.1 223 {{code language="java" theme="Eclipse" firstline="1" linenumbers="true" collapse="true" title="
224 resolveMapping"}}
Alexander Schulz-Rosengarten 12.1 225 @Inject
226 extension TransformationTreeExtensions
227
228 //Find nodes of model instances in tree
229 val aboSCCModelWrapper = transformationTree.findModel(aboSCC,"coreSCChart");
230 val aboSCGModelWrapper = transformationTree.findModel(aboSCG,"SCG");
231
232 //resolve
233 val mapping = resolvemapping(aboSCCModelWrapper, aboSCC, aboSCGModelWrapper, aboSCG);
234 {{/code}}
235
236
237 The returned mapping is a multi mapping between all object in aboSCC and their resulting objects in aboSCG.
Alexander Schulz-Rosengarten 13.1 238
Alexander Schulz-Rosengarten 14.1 239 This mapping can now displayed in models or used for various information propagation between elements of the models.
Alexander Schulz-Rosengarten 13.1 240
241 [[image:attach:example_abo_resolved.jpeg]]
242
243
Alexander Schulz-Rosengarten 14.1 244 Also a more detailed view is available, showing all EObjects relation.
Alexander Schulz-Rosengarten 13.1 245
246
247 [[image:attach:example_abo_resolved_elements.jpeg]]
248
Alexander Schulz-Rosengarten 16.1 249 == Visualisation ==
250
251 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//'.
252
253 === Diagram Options ===
254
255 //Model Visualisation//: If enabled tries to visaulize selected models with KLighD else a EObject-represenation is created.
256
257 //EObject Attributes//: If enabled shows Attributes of EObject in EObject-represenation.
258
259 //Selective mapping edges//: If enabled shows only selected mapping edges.
260
261 === Interaction ===
262
263 //CTRL+CLICK//: Selects a Node in TransformationTree as source and displays its represented model.
264
265 //SHIFT+CLICK//: Selects a Node in TransformationTree as target, displays both models and the resolved mapping as edges (currenly only between States/Regions).
266
267 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.
268