UML2 change type of a transformed property [message #1044696] |
Fri, 19 April 2013 04:13  |
Eclipse User |
|
|
|
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 04:13] by Moderator
|
|
|
Re: UML2 change type of a transformed property [message #1044717 is a reply to message #1044696] |
Fri, 19 April 2013 04:42   |
Eclipse User |
|
|
|
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
|
|
|
Re: UML2 change type of a transformed property [message #1044742 is a reply to message #1044717] |
Fri, 19 April 2013 05:17   |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
Prolem with types [message #1046869 is a reply to message #1046764] |
Mon, 22 April 2013 09:31  |
Eclipse User |
|
|
|
Hi,
I want to know how can I do the transformation if in mymetamodel I have just 4 datatypes (String, Boolean, Real, Integer) or in th target metamodel i have more and some don't exist in the first one like BigDecimal.....
and an other question about the heritation I want to use a result of a rule in an other one.
thank you very much.
|
|
|
Powered by
FUDForum. Page generated in 0.05187 seconds