forked from amlModeling/caex-workbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
caexMigration.atl
470 lines (426 loc) · 11.3 KB
/
caexMigration.atl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
-- @atlcompiler emftvm
-- @path copy=/caex.caex30/model/CAEX30.ecore
-- @path caex=/caex.caex215/model/CAEX215.ecore
module caexMigration;
create OUT : copy from IN : caex;
helper def: idToElement : Map (String, caex!CAEXObject) =
caex!CAEXObject.allInstancesFrom('IN')
-> select(x|x.oclIsKindOf(caex!SystemUnitClass) or
x.oclIsKindOf(caex!RoleClass))
-> mappedBySingle(e | e.iD);
helper context String def: element : caex!CAEXObject =
thisModule.idToElement.get(self);
--------------------------------------------------------
--operation convertPathToId(path : String) {
-- -- {ae671d03-30ae-4dcc-ba17-f0074fb69199}:Stromanschlussstecker2 --> ae671d03-30ae-4dcc-ba17-f0074fb69200
--------------------------------------------------------
-- @ignore found-in-subtype
helper def : convertPathToId(path : String) : String =
let parts : Sequence(String) = path.split(':') in
let ie_ID : String = parts->first().substring(2, parts->first().size()-1) in
ie_ID.element.externalInterface
-> any(x|x.name = parts->last()).iD;
helper context caex!InternalElement def : hasRole(role : String) : Boolean =
if (not self.roleRequirements.oclIsUndefined())
then
if(not self.roleRequirements.roleClass.oclIsUndefined())
then self.roleRequirements.roleClass.name = role
else false endif
or self.supportedRoleClass -> exists(x|x.roleClass.name = role)
else
false
endif;
rule AttributeNameMapping extends CAEXBasicObject {
from
ine : caex!AttributeNameMapping
to
oute : copy!AttributeNameMapping (
roleAttributeName <- ine.roleAttributeName,
systemUnitAttributeName <- ine.systemUnitAttributeName,
roleAttribute <- ine.roleAttribute,
systemUnitAttribute <- ine.systemUnitAttribute
)
}
rule Attribute extends CAEXObject {
from
ine : caex!Attribute
to
oute : copy!Attribute (
refSemantic <- ine.refSemantic,
constraint <- ine.constraint,
attribute <- ine.attribute,
attributeDataType <- ine.attributeDataType,
unit <- ine.unit,
value <- ine.value,
defaultValue <- ine.defaultValue
)
}
rule AttributeValueRequirement extends CAEXBasicObject {
from
ine : caex!AttributeValueRequirement
to
oute : copy!AttributeValueRequirement (
ordinalScaledType <- ine.ordinalScaledType,
nominalScaledType <- ine.nominalScaledType,
unknownType <- ine.unknownType,
name <- ine.name
)
}
rule CAEXBasicObject {
from
ine : caex!CAEXBasicObject
to
oute : copy!CAEXBasicObject (
description <- ine.description,
version <- ine.version,
revision <- ine.revision,
copyright <- ine.copyright,
changeMode <- ine.changeMode
)
}
-- added new CAEX 3.0 elements
rule CAEXFile extends CAEXBasicObject {
from
ine : caex!CAEXFile
to
oute : copy!CAEXFile (
externalReference <- ine.externalReference,
instanceHierarchy <- ine.instanceHierarchy,
interfaceClassLib <- ine.interfaceClassLib,
roleClassLib <- ine.roleClassLib,
systemUnitClassLib <- ine.systemUnitClassLib,
fileName <- ine.fileName,
-- NEW CAEX 3.0 elements ---------------------------
-- change default value from 2.15 to 3.0
schemaVersion <- '3.0',
-- See Change Table: 7 - Source Document Information
sourceDocumentInformation <- Sequence{sourceinfo},
-- NEW CAEX 3.0 element - to be configured by additional input model
-- See Change Table: row 6 - Superior Standard Version
superiorStandardVersion <- Sequence{'AutomationML 2.0'}--,
),
-- NEW CAEX 3.0 element - to be configured by additional input model
sourceinfo : copy!SourceDocumentInformation(
originID <- 'TODO',
originName <- 'TODO',
originProjectID <- 'TODO',
originProjectTitle <- 'TODO',
originRelease <- 'TODO',
originVendor <- 'TODO',
originVendorURL <- 'TODO',
originVersion <- '3.0',
lastWritingDateTime <- "#native"!"javax.xml.datatype.DatatypeFactory".refInvokeStaticOperation('newInstance' ,Sequence{}).newXMLGregorianCalendar('2015-11-09T14:22:58.670+01:00')
)
}
rule CAEXObject extends CAEXBasicObject {
from
ine : caex!CAEXObject
to
oute : copy!CAEXObject (
iD <- ine.iD,
name <- ine.name
)
}
rule Copyright {
from
ine : caex!Copyright
to
oute : copy!Copyright (
value <- ine.value,
changeMode <- ine.changeMode
)
}
rule Description {
from
ine : caex!Description
to
oute : copy!Description (
value <- ine.value,
changeMode <- ine.changeMode
)
}
rule DocumentRoot {
from
ine : caex!DocumentRoot
to
oute : copy!DocumentRoot (
mixed <- ine.mixed,
xMLNSPrefixMap <- ine.xMLNSPrefixMap,
xSISchemaLocation <- ine.xSISchemaLocation,
cAEXFile <- ine.cAEXFile
)
}
rule ExternalInterface extends InterfaceClass {
from
ine : caex!ExternalInterface
to
oute : copy!ExternalInterface (
attribute <- ine.attribute,
refBaseClassPath <- ine.refBaseClassPath,
baseClass <- ine.baseClass,
interfaceClass <- ine.interfaceClass
)
}
rule ExternalReference extends CAEXBasicObject {
from
ine : caex!ExternalReference
to
oute : copy!ExternalReference (
alias <- ine.alias,
path <- ine.path
)
}
rule InstanceHierarchy extends CAEXObject {
from
ine : caex!InstanceHierarchy
to
oute : copy!InstanceHierarchy (
internalElement <- ine.internalElement
)
}
rule InterfaceClassLib extends CAEXObject {
from
ine : caex!InterfaceClassLib
to
oute : copy!InterfaceClassLib (
interfaceClass <- ine.interfaceClass
)
}
rule InterfaceClass extends CAEXObject {
from
ine : caex!InterfaceClass
to
oute : copy!InterfaceClass (
attribute <- ine.attribute,
refBaseClassPath <- ine.refBaseClassPath,
baseClass <- ine.baseClass,
interfaceClass <- ine.interfaceClass
)
}
rule InterfaceFamily extends InterfaceClass {
from
ine : caex!InterfaceFamily
to
oute : copy!InterfaceFamily (
)
}
rule InterfaceNameMapping extends CAEXBasicObject {
from
ine : caex!InterfaceNameMapping
to
oute : copy!InterfaceIDMapping (
roleInterfaceID <- if not ine.roleInterfaceName.oclIsUndefined() then thisModule.convertPathToId(ine.roleInterfaceName) else OclUndefined endif,
systemUnitInterfaceID <- if not ine.systemUnitInterfaceName.oclIsUndefined() then thisModule.convertPathToId(ine.systemUnitInterfaceName) else OclUndefined endif,
roleInterface <- ine.roleInterface,
systemUnitInterface <- ine.systemUnitInterface
)
}
rule InternalElement extends SystemUnitClass {
from
ine : caex!InternalElement
to
oute : copy!InternalElement (
attribute <- ine.attribute,
externalInterface <- ine.externalInterface,
internalElement <- ine.internalElement,
supportedRoleClass <- ine.supportedRoleClass,
internalLink <- ine.internalLink,
refBaseClassPath <- ine.refBaseClassPath,
baseClass <- ine.baseClass,
systemUnitClass <- ine.systemUnitClass,
roleRequirements <- if ine.roleRequirements.oclIsUndefined() then Sequence{} else Sequence{ine.roleRequirements} endif,
refBaseSystemUnitPath <- ine.refBaseSystemUnitPath,
baseSystemUnit <- ine.baseSystemUnit
)
}
-- CAEX 3.0 specific rules
-- Generate an attribute library if we find a IE
rule IE2AttributeLibrary {
from
ie : caex!InternalElement (ie.hasRole('PropertySet'))
to
lib : copy!AttributeLib(
name <- if ie.name.oclIsUndefined() then 'attribute library' else ie.name.concat('lib') endif
)
}
rule InternalLink extends CAEXObject {
from
ine : caex!InternalLink
to
oute : copy!InternalLink (
refPartnerSideA <- ine.refPartnerSideA,
refPartnerSideB <- ine.refPartnerSideB,
partnerSideA <- ine.partnerSideA,
partnerSideB <- ine.partnerSideB
)
}
rule Mapping extends CAEXBasicObject {
from
ine : caex!Mapping
to
oute : copy!Mapping (
attributeNameMapping <- ine.attributeNameMapping,
interfaceIDMapping <- ine.interfaceNameMapping
)
}
rule NominalScaled {
from
ine : caex!NominalScaled
to
oute : copy!NominalScaled (
requiredValue <- ine.requiredValue
)
}
rule OrdinalScaled {
from
ine : caex!OrdinalScaled
to
oute : copy!OrdinalScaled (
requiredMaxValue <- ine.requiredMaxValue,
requiredValue <- ine.requiredValue,
requiredMinValue <- ine.requiredMinValue
)
}
rule RefSemantic extends CAEXBasicObject {
from
ine : caex!RefSemantic
to
oute : copy!RefSemantic (
correspondingAttributePath <- ine.correspondingAttributePath
)
}
rule Revision extends CAEXBasicObject {
from
ine : caex!Revision
to
oute : copy!Revision (
revisionDate <- ine.revisionDate,
oldVersion <- ine.oldVersion,
newVersion <- ine.newVersion,
authorName <- ine.authorName,
comment <- ine.comment
)
}
rule RoleClassLib extends CAEXObject {
from
ine : caex!RoleClassLib
to
oute : copy!RoleClassLib (
roleClass <- ine.roleClass
)
}
rule RoleClass extends CAEXObject {
from
ine : caex!RoleClass
to
oute : copy!RoleClass (
attribute <- ine.attribute,
externalInterface <- ine.externalInterface,
refBaseClassPath <- ine.refBaseClassPath,
baseClass <- ine.baseClass,
roleClass <- ine.roleClass
)
}
rule RoleFamily extends RoleClass {
from
ine : caex!RoleFamily
to
oute : copy!RoleFamily (
attribute <- ine.attribute,
externalInterface <- ine.externalInterface,
refBaseClassPath <- ine.refBaseClassPath,
baseClass <- ine.baseClass,
roleClass <- ine.roleClass
)
}
rule RoleRequirements extends CAEXBasicObject {
from
ine : caex!RoleRequirements
to
oute : copy!RoleRequirements (
attribute <- ine.attribute,
externalInterface <- ine.externalInterface,
refBaseRoleClassPath <- ine.refBaseRoleClassPath,
roleClass <- ine.roleClass,
-- moving mapping objects from internalelement to its inner rolerequirement
mappingObject <-ine.refImmediateComposite().mappingObject
)
}
rule SupportedRoleClass extends CAEXBasicObject {
from
ine : caex!SupportedRoleClass
to
oute : copy!SupportedRoleClass (
mappingObject <- ine.mappingObject,
refRoleClassPath <- ine.refRoleClassPath,
roleClass <- ine.roleClass
)
}
rule SystemUnitClassLib extends CAEXObject {
from
ine : caex!SystemUnitClassLib
to
oute : copy!SystemUnitClassLib (
systemUnitClass <- ine.systemUnitClass
)
}
rule SystemUnitClass extends CAEXObject {
from
ine : caex!SystemUnitClass
to
oute : copy!SystemUnitClass (
attribute <- ine.attribute,
externalInterface <- ine.externalInterface,
internalElement <- ine.internalElement,
supportedRoleClass <- ine.supportedRoleClass,
internalLink <- ine.internalLink,
refBaseClassPath <- ine.refBaseClassPath,
baseClass <- ine.baseClass,
systemUnitClass <- ine.systemUnitClass
)
}
rule SystemUnitFamily extends SystemUnitClass {
from
ine : caex!SystemUnitFamily
to
oute : copy!SystemUnitFamily (
attribute <- ine.attribute,
externalInterface <- ine.externalInterface,
internalElement <- ine.internalElement,
supportedRoleClass <- ine.supportedRoleClass,
internalLink <- ine.internalLink,
refBaseClassPath <- ine.refBaseClassPath,
baseClass <- ine.baseClass,
systemUnitClass <- ine.systemUnitClass
)
}
rule UnknownType {
from
ine : caex!UnknownType
to
oute : copy!UnknownType (
requirements <- ine.requirements
)
}
rule Version {
from
ine : caex!Version
to
oute : copy!Version (
value <- ine.value,
changeMode <- ine.changeMode
)
}
rule AdditionalInformation {
from
ine : caex!AdditionalInformation
to
oute : copy!AdditionalInformation (
attributeFeatureMap <- ine.attributeFeatureMap,
attributes <- ine.attributes,
elementFeatureMap <- ine.elementFeatureMap,
name <- ine.name,
nestedElements <- ine.nestedElements,
value <- ine.value
)
}