Home » Modeling » ATL » UML2 change type of a transformed property
UML2 change type of a transformed property [message #1044696] |
Fri, 19 April 2013 08:13 |
Javier García Messages: 129 Registered: April 2013 |
Senior Member |
|
|
Hi,
I'm doing an UML2 to UML2 transformation, and I got the following rule:
rule Group2CaptionAndGrid {
from
src: UML2!Property (src.type.name = 'Group')
to
grp: UML2!Property (
name <- src.name -> debug('Property'),
visibility <- src.visibility,
lower <- src.lower,
upper <- src.upper,
type <- src.type,
aggregation <- src.aggregation,
association <- src.association,
isStatic <- src.isStatic,
ownedComment <- src.ownedComment
),
grd: UML2!Property (
name <- src.name +'Grid' -> debug('Property'),
visibility <- src.visibility,
lower <- src.lower,
upper <- src.upper,
type <- src.type,
aggregation <- src.aggregation,
association <- src.association,
isStatic <- src.isStatic,
ownedComment <- src.ownedComment
)
}
What I want to do is on the second element I create (grd) set it to a different type called Grid. The type 'Grid' is another class that gets transformed in this transformation, so is there any way to reference this class?
I tried doing OUT!Grid and other similar things, but nothing seems to work.
Thanks in advance,
regards
Javier
[Updated on: Fri, 19 April 2013 08:13] Report message to a moderator
|
|
|
Re: UML2 change type of a transformed property [message #1044717 is a reply to message #1044696] |
Fri, 19 April 2013 08:42 |
Hugo Bruneliere Messages: 674 Registered: July 2009 |
Senior Member |
|
|
Hello,
ATL as an automated resolution mechanism that has to be used as much as possible: by default, when indicating an input model element, ATL automatically replaces it by the first output model element created from it according to corresponding (other) matched rule in the transformation.
For instance, in your case, in another rule you could do something like:
from
oldGrid: UML2!Grid
to
newGrid: UML2!Grid (
properties <- oldGrid.properties
)
And newGrid.properties will actually contain the set of grp:UML2!Property elements as created by your rule Group2CaptionAndGrid.
If you explicitly need to refer to the second, third, etc. element created in a given rule, you can use the resolveTemp method:
from
oldGrid: UML2!Grid
to
newGrid: UML2!Grid (
properties <- oldGrid.properties->collect(p | thisModule.resolveTemp(p,'grd'))
)
And newGrid.properties will actually contain the set of grd:UML2!Property elements as created by your rule Group2CaptionAndGrid.
Best regards,
Hugo
--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
|
|
|
Re: UML2 change type of a transformed property [message #1044742 is a reply to message #1044717] |
Fri, 19 April 2013 09:17 |
Javier García Messages: 129 Registered: April 2013 |
Senior Member |
|
|
Hi Hugo,
thanks once again for your help.
I'm not sure that would solve my problem, I think I might have explained myself poorly so I will try to explain better now:
I do this transformation:
rule Composite {
from
s: UML2!Class (
s.name = 'Composite'
)
to
r: UML2!Class (
name <- 'Grid',
ownedComment <- s.ownedComment
)
}
And then another class (MainClass) I transform contains several properties that were of the type 'Composite' and once transformed are of the type 'Grid'.
So MainClass also contains some properties of the type Group, so then I want to transform the property Group to two different properties: one of the type CaptionPanel and one of the type Grid, and thanks to the resolveTemp method you commented I get to include both properties in my class, but the problem is that when I use the rule I wrote on my first message the properties of the type 'Group' gets transformed to two different properties of the type 'CaptionPanel', and I want one of those transformed properties (the one called grd) to be transformed to a property of the type Grid.
Is this possible?
And if so, how?
If there's something that needs further explanation, please let me know.
Thank again for your help!
regards,
Javier
|
|
| | | | |
Goto Forum:
Current Time: Tue Apr 16 13:41:10 GMT 2024
Powered by FUDForum. Page generated in 0.06730 seconds
|