Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ATL dynamic creation and referencing(Dynamic creation of packagedElements within a UML:MODEL with cross referencing)
ATL dynamic creation and referencing [message #1226482] Wed, 01 January 2014 22:31 Go to next message
Chris BaileyFriend
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 Smile.

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 #1227018 is a reply to message #1226482] Fri, 03 January 2014 09:59 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi Chris,
So basically you want a UML Model element that contains two UML Classes. Each of these UML Classes has a UMl Stereotype applied. This is all pretty standard stuff in ATL/UML.

As you have noted the stereotype information is stored outside the model definition but in the XMI. This is also normal.

So I think what you have looks fine. But the best way to find out is to open and validate the .uml file in the default UML Editor in Eclipse.
Regards,
Ronan
Re: ATL dynamic creation and referencing [message #1227026 is a reply to message #1227018] Fri, 03 January 2014 10:27 Go to previous messageGo to next message
Chris BaileyFriend
Messages: 11
Registered: January 2014
Junior Member
Thanks Ronan,

Are you aware of any examples I could learn from? Specifically transformations to UML and ones that load a uml profile for the stereotypes? I found one example of 2uml transformation in http://www.eclipse.org/atl/atlTransformations/ however this does not demonstrate the use of a uml profile.

Currently I take my source model which conforms to an ecore mm, and output this as a UML model.

Many thanks,
Chris
Re: ATL dynamic creation and referencing [message #1227029 is a reply to message #1227026] Fri, 03 January 2014 10:37 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

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 #1227032 is a reply to message #1227026] Fri, 03 January 2014 10:42 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
Yep take a look at the forum posts like http://www.eclipse.org/forums/index.php/t/440416/ for some inspiration. But as Denis says be sure to assign your classes to the model via the packageElements. If you don't you will get the error the guy in the linked post gets.
Regards,
Ronan
Re: ATL dynamic creation and referencing [message #1227500 is a reply to message #1227032] Sat, 04 January 2014 18:17 Go to previous messageGo to next message
Chris BaileyFriend
Messages: 11
Registered: January 2014
Junior Member
Thanks all Smile Making some progress now!

Cheers,
Chris
Re: ATL dynamic creation and referencing [message #1228942 is a reply to message #1227500] Wed, 08 January 2014 11:47 Go to previous message
Chris BaileyFriend
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'));
	}
}
Previous Topic:How to create a UML!Type entity and access XSD elements inside WSDLfile
Next Topic:Getting elements from a XSD Complex Type - ATL
Goto Forum:
  


Current Time: Tue Mar 19 11:55:20 GMT 2024

Powered by FUDForum. Page generated in 0.03853 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top