ATL dynamic creation and referencing [message #1226482] |
Wed, 01 January 2014 22:31 |
Chris Bailey Messages: 11 Registered: January 2014 |
Junior Member |
|
|
Hi all,
I'm very new to ATL, i've read through the user guide and completed a few exercises. I was pointed to ATL as I was told it may be a suitable solution to a problem.
I have a model in xmi that needs to be transformed into a UML model with a bespoke profile. A tool exists for the UML model that can validate the model which I need to use. Both represent implementations of the Role Based Access Control model.
I'm trying to find out if it is possible to dynamically create packagedElements that can exist in a uml:Model.
For example, the structure of the output needs to look like this (as required by the validation tool):
<xmi>
<uml:Model>
<packagedElement xmi:type="uml:Class" xmi:id="_G9m0MKsoEeKCpaBuCpEQoA" name="Doe ">
<ownedAttribute xmi:id="_j4LtIKsoEeKCpaBuCpEQoA" name="student" type="_a1bTMKsoEeKCpaBuCpEQoA"/>
</packagedElement>
<packagedElement xmi:type="uml:Class" xmi:id="_a1bTMKsoEeKCpaBuCpEQoA" name="Student ">
<ownedAttribute xmi:id="_j4YhcKsoEeKCpaBuCpEQoA" name="doe" type="_G9m0MKsoEeKCpaBuCpEQoA"/>
</packagedElement>
</uml:Model>
<rbacDSML:User xmi:id="_G_lKIKsoEeKCpaBuCpEQoA" base_Class="_G9m0MKsoEeKCpaBuCpEQoA"/>
<rbacDSML:rbacRole xmi:id="_a1gLsKsoEeKCpaBuCpEQoA" base_Class="_a1bTMKsoEeKCpaBuCpEQoA"/>
</xmi>
Essentially, I have to create several uml class references in the model. Notice that the xmi:id of 'Doe' matches the type of the ownedAttribute in Student. In addition, the rbacDSML elements need to be created and reference packagedElements in the uml:Model. So for 'Doe' it references as a rbacDSML:User (check base_Class).
Question: If I have a list of roles and users in my input model, can I dynamically create these packagedElements using ATL, embed them into a created <uml:Model>, and be able to reference created packagedElements (or update existing ones)? I've been able to do part of it statically, but I need to be able to do it dynamically.
My first attempt at the rules (the static route):
rule policy562rbacDSML {
from
s: policy56!X509PMIRBACPolicy
to
m: UML!Model(
name <- thisModule.policyIdType,
packagedElement <- OrderedSet {r1},
packagedElement <- OrderedSet {r2}
),
r1: UML!Class(
name <- thisModule.roles.get(0)
),
r2: UML!Class(
name <- thisModule.roles.get(1)
),
rd1: rbacDSML!rbacRole(
base_Class <- r1
),
rd2: rbacDSML!rbacRole(
base_Class <- r2
)
}
This creates two separate model files, but creates my packagedElements within uml:Model (which I want), but no idea how to get the rbacDSML elements to appear below the <uml:Model/> element, and to be created dynamically. The required output structure to me doesn't seem proper, but I could be wrong, i'm new to this .
The other way I've tried to do this is with these types of rules:
--Create uml:Model
rule policy562umlModel{
from
s: policy56!X509PMIRBACPolicy
to
m: UML!Model(
name <- thisModule.policyIdType
)
}
--Create rbac roles from p56roles
rule p56role2rbac {
from
s: policy56!SupRole
to
r: UML!Class(
name <- s.Value
),
rd: rbacDSML!rbacRole(
base_Class <- r
)
}
This dynamically creates all the role elements in the output model for me, but not as packagedElements, and I'm not sure how I could package this into the uml:Model.
Look forward to any help/advice/links to documentation that could help me out. If someone is able to tell me what I'm trying to achieve is not possible (or is), then even better!
Many thanks!
|
|
|
|
|
Re: ATL dynamic creation and referencing [message #1227029 is a reply to message #1227026] |
Fri, 03 January 2014 10:37 |
|
In order for the UML Model to contain the Class instances, you'll need to assign a value to Model::packagedElement like you did in the static example. ATL provides the implicit tracing mechanism, which automatically replaces source values by target values in a '<-' binding. Something like this:
rule policy562umlModel{
from
s: policy56!X509PMIRBACPolicy
to
m: UML!Model(
name <- thisModule.policyIdType,
packagedElement <- s.supRoles
)
}
...where s.supRoles would be a collection of policy56!SupRole, which are then replaced by the implicit tracing mechanism by the UML Class instances created in the p56role2rbac rule.
Cheers,
Dennis
[Updated on: Fri, 03 January 2014 10:38] Report message to a moderator
|
|
|
|
|
Re: ATL dynamic creation and referencing [message #1228942 is a reply to message #1227500] |
Wed, 08 January 2014 11:47 |
Chris Bailey Messages: 11 Registered: January 2014 |
Junior Member |
|
|
For folks interested in the solution (probably more relevant for those new to the language, like myself):
To create a UML model with an applied UML profile.
OUT uses a UML metamodel
IN takes my own ecore model I want to transform from
PRO takes the UML profile as input, but uses the same UML metamodel.
In your launch configuration you should have 2 metamodels (the UML and your input metamodel), 2 inputs (the model conforming to your input metamodel, and the uml profile).
I create the model and use t.applyProfile() to apply the uml profile. To use stereotypes that exist in my profile I use t.applyStereotypes().
create OUT: UML from IN: saafABAC, PRO : UML ;
----HELPER Methods
--Get Stereotype that matches String
helper def: getStereotype(s : String) : UML!Stereotype =
UML!Stereotype.allInstancesFrom('PRO')->select(e | e.name = s)->first();
----TRANSFORMATION Rules
rule createModel {
from
s: saafABAC!AbacModel
to
t: UML!Model(
name <- 'rbacDSMLmodel',
packagedElement <- saafABAC!Subject.allInstancesFrom('IN')
->collect(e | thisModule.createSubjects(e))
)
do{
t.applyProfile(UML!Profile.allInstancesFrom('PRO')->select(p | p.name = 'rbacDSML')->first());
}
}
lazy rule createSubjects{
from
s: saafABAC!Subject
to
t: UML!Class(
name <- s.ID
)
do{
t.applyStereotype(thisModule.getStereotype('User'));
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04319 seconds