Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Refactoring UML!Property
Refactoring UML!Property [message #556668] Thu, 02 September 2010 09:37 Go to next message
Aur is currently offline AurFriend
Messages: 29
Registered: August 2010
Junior Member
Hi,

I work on a UML to UML transformation and I'd like to know if there's a way to copy classes' ownedAttributes?
I saw in UMLCopy something like:
from f: UML!Class
to t:UML!Class(
   ownedAttribute <- f.ownedAttribute
)

But when I tried it, that does not work:

Cannot set feature ownedAttribute to value ... , containment references cannot span across models.

If I'm right, it's due to UML!Property.class value, but I can't change it and I don't know how to create a instance of UML!Property and then fill it with values of the source item.
Maybe it's because I think in OO concepts ...
I tried something like :
from f: UML!Class
to t:UML!Class(
   name<- f.name
),
tmp: UML!Property
do{
   for (e in d.ownedAttribute){
      tmp = UML!Property.newInstance();
      tmp.name <- e.name;
       t.ownedAttribute<-t.ownedAttribute->append(tmp);
   }
}

But Property instances are not included in the class.

Thanks for your help and advices

[Updated on: Thu, 02 September 2010 09:48]

Report message to a moderator

Re: Refactoring UML!Property [message #556689 is a reply to message #556668] Thu, 02 September 2010 10:48 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 523
Registered: July 2009
Senior Member
Just add a rule to transform UML!Property.

from f: UML!Property
to t:UML!Property(
name<- f.name
)

You may want to give a try to the ATL refining mode which does all that copy rules for you.
You can't delete or move elements for the moment though.
Re: Refactoring UML!Property [message #556695 is a reply to message #556668] Thu, 02 September 2010 11:16 Go to previous messageGo to next message
Aur is currently offline AurFriend
Messages: 29
Registered: August 2010
Junior Member
Thank you very much for you help.

I manage do to what I want thanks to :
lazy rule copyAttribute{
	from f : UML!Property
	to t : UML!Property(
		name <- f.name,
		visibility <- f.visibility,
		...
	)
}

rule ClassToClass{
	from 
		f : TB_Profile!Class(f.hasStereotype('Agent'))
	to
		t : UML!Class(
			name <- f.name	
		)
	do{
		-- copy source's attributes 
		for (e in f.ownedAttribute){
			if (e.association.oclIsUndefined()) {
				t.ownedAttribute<-t.ownedAttribute.append(thisModule.copyAttribute(e));
			}
		}		
	}
}

[Updated on: Thu, 02 September 2010 13:17]

Report message to a moderator

Re: Refactoring UML!Property [message #556699 is a reply to message #556695] Thu, 02 September 2010 11:36 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 523
Registered: July 2009
Senior Member
No imperative code is needed :
helper context UML!Property def : filter : Boolean =
	self.association.oclIsUndefined()
;

rule copyAttribute{
	from f : UML!Property (f.filter)
	to t : UML!Property(
		name <- f.name,
		visibility <- f.visibility,
		...
	)
}

rule ClassToClass{
	from 
		f : TB_Profile!Class(d.hasStereotype('Agent'))
	to
		t : UML!Class(
			name <- d.name,
			package <- e_module,
			ownedAttribute <- f.ownedAttribute->select(e | e.filter)
		)
}

This way, only the properties passing the filter are transformed and assigned in ownedAttribute.
Re: Refactoring UML!Property [message #556728 is a reply to message #556668] Thu, 02 September 2010 13:14 Go to previous message
Aur is currently offline AurFriend
Messages: 29
Registered: August 2010
Junior Member
Many thanks for your help. As I wrote, I certainly think too much in OO and imperative language.
Previous Topic:[QVTo] integrate a QVTo file into a GMF Editor
Next Topic:[QVTo] Truncate output file / do not append results
Goto Forum:
  


Current Time: Fri Dec 19 22:47:21 GMT 2014

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

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