Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Problem when copying association
[ATL] Problem when copying association [message #94769] Mon, 10 November 2008 04:01 Go to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
Hi all,

I’m trying to copy the associations between selected classes from the
source model to the target one. The metamodels for both the source and
target are UML2. I selected first the classes to be copied according to
their stereotypes then I need to select the associations according to the
stereotype of their member ends. Since I couldn’t navigate the target
model to copy only the associations of its classes, I have to repeat the
same condition in the association rule.

I use these rules to copy the classes and their associations, but I get
this error “could not find operation hasStereotype on Sequence(OclAny)
having supertypes: [Collection(OclAny)] “ . A helper called hasStereotype
is defined and works fine only with the rule CopyClass. I get the same
error if I use isStereotypeApplied()

rule CopyAssociation{
from
s : UML!Association (s.memberEnd.hasStereotype(' myStereotype'))
to
t : UML!Association (
name <- s.name,
ownedEnd <- s.ownedEnd,
memberEnd <- s.memberEnd
)
}

rule CopyClass{
from
s : UML!Class (s.hasStereotype('myStereotype'))
to
t : UML!Class (
name <- s.name,
ownedAttribute <- s.ownedAttribute,
ownedOperation <- s.ownedOperation,
generalization <- s.generalization
)
)

How can I access this helper through the association?

Do I need to use a lazy rule to call it when I need to copy a specific
association or just a condition in a matched rule is enough?

Is the order of these two rules matter? If the CopyClass rule executed
first, then the selected classes are moved from the source model to the
target model and the second CopyAssociation rule will not find these
classes in the source model. Or we don’t modify the source model so the
order doesn’t matter.

Any help would be appreciated!

Rasha
Re: [ATL] Problem when copying association [message #94793 is a reply to message #94769] Mon, 10 November 2008 10:15 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hi Rasha

When i worked with ATL on UML2 I had some problems too with stereotypes

some solutions to try
1) try UML2 handler
2) instead of using s.hasStereotype
make an helper which will execute this (sorry for helper syntax i don't
remember):
helper personnalHasStereotype(name :String) .... =
s.getAppliedStereotypes()->select(s | s.name = name)
and try to put a debug on s.getAppliedStereotypes
I really have this problem and it seems the stereotypes methods with
Strings doesn't work

Rasha a écrit :
> Hi all,
>
> I�m trying to copy the associations between selected classes from the
> source model to the target one. The metamodels for both the source and
> target are UML2. I selected first the classes to be copied according to
> their stereotypes then I need to select the associations according to
> the stereotype of their member ends. Since I couldn�t navigate the
> target model to copy only the associations of its classes, I have to
> repeat the same condition in the association rule.
>
> I use these rules to copy the classes and their associations, but I get
> this error �could not find operation hasStereotype on Sequence(OclAny)
> having supertypes: [Collection(OclAny)] � . A helper called
> hasStereotype is defined and works fine only with the rule CopyClass. I
> get the same error if I use isStereotypeApplied()
> rule CopyAssociation{
> from
> s : UML!Association (s.memberEnd.hasStereotype(' myStereotype'))
> to t : UML!Association ( name <- s.name,
> ownedEnd <- s.ownedEnd,
> memberEnd <- s.memberEnd
> )
> }
> rule CopyClass{
> from
> s : UML!Class (s.hasStereotype('myStereotype'))
> to t : UML!Class ( name <- s.name,
> ownedAttribute <- s.ownedAttribute,
> ownedOperation <- s.ownedOperation,
> generalization <- s.generalization
> )
> )
>
> How can I access this helper through the association?
>
> Do I need to use a lazy rule to call it when I need to copy a specific
> association or just a condition in a matched rule is enough?
>
> Is the order of these two rules matter? If the CopyClass rule executed
> first, then the selected classes are moved from the source model to the
> target model and the second CopyAssociation rule will not find these
> classes in the source model. Or we don�t modify the source model so the
> order doesn�t matter.
>
> Any help would be appreciated!
>
> Rasha
>
>




Re: [ATL] Problem when copying association [message #94890 is a reply to message #94793] Mon, 10 November 2008 12:35 Go to previous messageGo to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
Thanks Tristan. I’m already using UML2 handler and a helper for
s.hasStereotype which works fine when I call it from the CopyClass rule.

I think my problem is with this syntax when I call this helper through the
association
s.memberEnd.hasStereotype('myStereotype')
Re: [ATL] Problem when copying association [message #94919 is a reply to message #94890] Mon, 10 November 2008 12:58 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Sorry
i didn't well understand the problem
I think your helper is matching on UML!Element ?

and when you do : s.memberEnd.hasStereotype(' myStereotype')

memberEnd is a collection

so maybe you should rewrite your condition (s.memberEnd->select(s |
s.hasStereotype(' myStereotype')->size() > 0) or matching the properties
owning or referenced by the association

Rasha a écrit :
> Thanks Tristan. I�m already using UML2 handler and a helper for
> s.hasStereotype which works fine when I call it from the CopyClass rule.
> I think my problem is with this syntax when I call this helper through
> the association s.memberEnd.hasStereotype('myStereotype')
>




Re: [ATL] Problem when copying association [message #95026 is a reply to message #94919] Tue, 11 November 2008 05:10 Go to previous messageGo to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
I modified a little bit the condition to get the class as the memberEnd
returns type property and the class is the one which has the stereotype

(s.memberEnd->select
(c|c.class.oclIsTypeOf(UML!Class))->select(p|p.hasStereotype('myStereotype'))- >
notEmpty())

I didn’t get an error, but the target model contains only the classes
stereotyped with 'myStereotype’. Because the evaluation of this condition
is an empty set, then it executes the second rule and copies only the
stereotyped classes.
However if I cut the condition at (s.memberEnd->select
(c|c.class.oclIsTypeOf(UML!Class))-> notEmpty()), it copies all the
association of the source model as the set now contains all the classes.

I think the problem is when I access the class through its association it
couldn’t see the stereotype. I got the same problem when I access a class
through its owned property.

I couldn’t do it by matching the properties owning or referenced by the
association as I need to copy only the association between stereotyped
classes.

Any hint Tristan will be great.

Rasha
Re: [ATL] Problem when copying association [message #95104 is a reply to message #95026] Wed, 12 November 2008 08:23 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hi rasha
sorry i didn't understand well what's your problem and the differences
of result but what i can see is i think your ocl rule doesn't return the
good result

(s.memberEnd->select(c|c.class.oclIsTypeOf(UML!Class))
-- you select all the properties names c having c.class of type
UML!Class but the result is a collection of property
so when you do the rest of the request
->select(p|p.hasStereotype('myStereotype'))->
notEmpty())
-- you select the properties stereotyped 'myStereotype' and you wanted
classes stereotyped

maybe it's this kind of rule you should use :
(s.memberEnd->collect(currentProperty|currentProperty.class) -- we have
a class collection
-> select(currentClass|currentClass.hasStereotype('myStereotype '))- >
> notEmpty())

what do you think about ?



Rasha a écrit :
> I modified a little bit the condition to get the class as the memberEnd
> returns type property and the class is the one which has the stereotype
>
> (s.memberEnd->select
> (c|c.class.oclIsTypeOf(UML!Class))->select(p|p.hasStereotype('myStereotype'))- >
> notEmpty())
>
> I didn�t get an error, but the target model contains only the classes
> stereotyped with 'myStereotype�. Because the evaluation of this
> condition is an empty set, then it executes the second rule and copies
> only the stereotyped classes. However if I cut the condition at
> (s.memberEnd->select (c|c.class.oclIsTypeOf(UML!Class))-> notEmpty()),
> it copies all the association of the source model as the set now
> contains all the classes.
>
> I think the problem is when I access the class through its association
> it couldn�t see the stereotype. I got the same problem when I access a
> class through its owned property.
>
> I couldn�t do it by matching the properties owning or referenced by the
> association as I need to copy only the association between stereotyped
> classes.
>
> Any hint Tristan will be great.
>
> Rasha
>
>




Re: [ATL] Problem when copying association [message #95299 is a reply to message #95104] Fri, 14 November 2008 12:38 Go to previous messageGo to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
I'm so thankful Tristan. You condition syntax works fine with me.

Rasha
Re: [ATL] Problem when copying association [message #95948 is a reply to message #95299] Mon, 24 November 2008 06:01 Go to previous messageGo to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
Hi Tristan,

It's me again but this time I try to copy a class according to the value
of the property of the stereotype. I got a NullPointerException error.
I use this helper

helper context UML!"uml::Class" def: getTagValue(stereotype :
String ,tag : String) : String=
self.getValue(self.getAppliedStereotype(stereotype),tag);

I call this helper with the fully qualifed name of the stereotype.

rule Copyclass{
from
s : UML!"uml::Class"
(s.getTagValue('sample::myStereotype','myProperty')='value_1 ')
to
t : UML!"uml::Class" (
name <- s.name
)
}
Any hints will be great.

Rasha
Re: [ATL] Problem when copying association [message #95962 is a reply to message #95948] Mon, 24 November 2008 12:22 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hi Rasha

Did you try to put some debug instructions on :
self.getAppliedStereotype(stereotype).debug('applied :')
to see if the stereotype is correctly get

maybe you shouldn't use the fully qualified name of the stereotype :?



Rasha a écrit :
> Hi Tristan,
>
> It's me again but this time I try to copy a class according to the value
> of the property of the stereotype. I got a NullPointerException error.
> I use this helper
>
> helper context UML!"uml::Class" def: getTagValue(stereotype :
> String ,tag : String) : String=
> self.getValue(self.getAppliedStereotype(stereotype),tag);
>
> I call this helper with the fully qualifed name of the stereotype.
>
> rule Copyclass{
> from
> s : UML!"uml::Class"
> (s.getTagValue('sample::myStereotype','myProperty')='value_1 ')
> to t : UML!"uml::Class" ( name <- s.name
> )
> }
> Any hints will be great.
>
> Rasha
>




Re: [ATL] Problem when copying association [message #96048 is a reply to message #95962] Tue, 25 November 2008 12:26 Go to previous messageGo to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
For getAppliedStereotype(stereotype), I have to use the fully qualified
name of the stereotype, otherwise it doesn’t work.
I tested getAppliedStereotype(stereotype) in different helper and it works
fine.

I have a problem with the debug. When I put a debug instruction, I got only
INFO: Trying to connect to remote debuggee
INFO: Connected.

I have org.atl.eclipse.adt.debug as a plug in. Do I need something else?
Re: [ATL] Problem when copying association [message #96076 is a reply to message #96048] Tue, 25 November 2008 23:03 Go to previous message
Eclipse UserFriend
Hi Rasha,

After getting that connected info message you have to switch to the
Debug perspective.





Rasha schrieb:
> For getAppliedStereotype(stereotype), I have to use the fully qualified
> name of the stereotype, otherwise it doesn�t work.
> I tested getAppliedStereotype(stereotype) in different helper and it
> works fine.
>
> I have a problem with the debug. When I put a debug instruction, I got only
> INFO: Trying to connect to remote debuggee
> INFO: Connected.
>
> I have org.atl.eclipse.adt.debug as a plug in. Do I need something else?
>
>
Previous Topic:[ATL] Referencing DataTypes-library elements.
Next Topic:problem with am3
Goto Forum:
  


Current Time: Fri Apr 26 16:10:25 GMT 2024

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

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

Back to the top