Refactoring UML!Property [message #556668] |
Thu, 02 September 2010 09:37 |
Aur 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 #556695 is a reply to message #556668] |
Thu, 02 September 2010 11:16 |
Aur 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03259 seconds