Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » UML2 change type of a transformed property
icon5.gif  UML2 change type of a transformed property [message #1044696] Fri, 19 April 2013 08:13 Go to next message
Javier García is currently offline Javier GarcíaFriend
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 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
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 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
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
Re: UML2 change type of a transformed property [message #1046747 is a reply to message #1044696] Mon, 22 April 2013 10:08 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
In case anyone is wondering, I finally did it like this:
type<-UML2!Type.allInstances()->select(e | e.name='Grid').first()

It was really simple in the end!
Re: UML2 change type of a transformed property [message #1046756 is a reply to message #1046747] Mon, 22 April 2013 10:25 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Normally you shouldn't navigate the target model.
It would be safer to reference the 'Composite' class which is then transformed into the 'Grid' class by the transformation.
Re: UML2 change type of a transformed property [message #1046764 is a reply to message #1046756] Mon, 22 April 2013 10:37 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
You mean this?:
type<-UML2!Type.allInstances()->select(e | e.name='Composite').first()


I was wondering if that would be a better choice, and since it works too I can do it this way, thanks!
Prolem with types [message #1046869 is a reply to message #1046764] Mon, 22 April 2013 13:31 Go to previous message
samar sousou is currently offline samar sousouFriend
Messages: 63
Registered: March 2013
Member
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.
Previous Topic:[ATL] EMF VMException: Cannot create OUT!...
Next Topic:How to combine ATL project with java project
Goto Forum:
  


Current Time: Tue Apr 16 13:41:10 GMT 2024

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

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

Back to the top