Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL]Hierarchical structure not preserved with called/lazy rules
[ATL]Hierarchical structure not preserved with called/lazy rules [message #97998] Wed, 21 January 2009 12:43 Go to next message
Eclipse UserFriend
Hello,

I am using ATL to produce a target UML2 Sequence model.

Therefore; I need to create two "uml::MessageOccurrenceSpecification" for
each source model element.

So I am using Called/Lazy Rules to achieve multiple target element
generation. Unfortunately, "uml:MessageOccurrenceSpecification" elements
created with the Called/Lazy Rule will not be nested within the
uml:Interaction.

If I create an equivalent Matched Rule, the target element
"uml:MessageOccurrenceSpecification" will be nested correctly. But it will
only create one "uml:MessageOccurrenceSpecification" for each source
element but I need two for each source element.

How can I solve this issue ?


Regards,


Thomas
Re: [ATL]Hierarchical structure not preserved with called/lazy rules [message #98045 is a reply to message #97998] Thu, 22 January 2009 07:52 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
many solutions to your problem but I suggest :
you can do for example in your top level rule (model or package)

....
from s : UML!Model
to t : UML!Model (
packagedElements <-
s.packagedElements->union(UML!Element.allInstances()->collect(e |
thisModule.myLazyRule(e))),
packagedElements <-
s.packagedElements->union(UML!Element.allInstances()->collect(e |
thisModule.myLazyRule2(e)))
)
....

lazy rule myLazyRule {
from s : UML!Element
to t1 : UML!MessageOccurenceSpecification (
)
}

lazy rule myLazyRule2 {
from s : UML!Element
to t1 : UML!MessageOccurenceSpecification (
)
}

you can optimize and remember the allInstances in using section. And you
can store the messageSpecification in other place.

you can also create a called rule with parameter for name for example to
not create 2 rules similarly

as you want ;)

Thomas Winkler a écrit :
> Hello,
>
> I am using ATL to produce a target UML2 Sequence model.
>
> Therefore; I need to create two "uml::MessageOccurrenceSpecification"
> for each source model element.
>
> So I am using Called/Lazy Rules to achieve multiple target element
> generation. Unfortunately, "uml:MessageOccurrenceSpecification" elements
> created with the Called/Lazy Rule will not be nested within the
> uml:Interaction.
>
> If I create an equivalent Matched Rule, the target element
> "uml:MessageOccurrenceSpecification" will be nested correctly. But it
> will only create one "uml:MessageOccurrenceSpecification" for each
> source element but I need two for each source element.
>
> How can I solve this issue ?
>
>
> Regards,
>
>
> Thomas
>
>
>
>
>
>
>




Re: [ATL]Hierarchical structure not preserved with called/lazy rules [message #98131 is a reply to message #98045] Fri, 23 January 2009 00:31 Go to previous messageGo to next message
Eclipse UserFriend
Thank you very much, Tristan !

I am using the called rule with parameter and it works like a charm.
Unfortunately, ATL doesn't support polymorphic calls then the expressions
would more elegant.

> you can optimize and remember the allInstances in using section. And you
> can store the messageSpecification in other place.

I placed the allInstances Rule in the using section but where can I place
the messageSpecification rule ? You mean a helper?

Regards,

Thomas
Re: [ATL]Hierarchical structure not preserved with called/lazy rules [message #98146 is a reply to message #98131] Fri, 23 January 2009 08:25 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
you save the result of allinstances in the using

sorry for the syntax :(

using {
myvar = UML!Element.allInstances() ;
}
to t : UML!Model (
packagedElements <- s.packagedElements->union(myvar->collect(e
| thisModule.myCallRule(e,1))),
packagedElements <- s.packagedElements->union(myvar->collect(e
| thisModule.myCallRule2(e,2)))
)
)

I don't know how exactly work ATL but I hope it saves the result of
allInstances in myvar ;)

and the messageSpecification rule stay at the same place


Thomas Winkler a écrit :
> Thank you very much, Tristan !
>
> I am using the called rule with parameter and it works like a charm.
> Unfortunately, ATL doesn't support polymorphic calls then the
> expressions would more elegant.
>
>> you can optimize and remember the allInstances in using section. And
>> you can store the messageSpecification in other place.
>
> I placed the allInstances Rule in the using section but where can I
> place the messageSpecification rule ? You mean a helper?
>
> Regards,
>
> Thomas
>
>
>
>




Re: [ATL]Hierarchical structure not preserved with called/lazy rules [message #98309 is a reply to message #98146] Sun, 25 January 2009 14:58 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Tristan !!!

Just one more question. Maybe you or anyone else can help me.

Sequence diagram needs uml:CallEvent. But I can't get it done that
uml:CallEvent is a child of Package AND it referenced by MessageOccurence.

I achieve only one of the targets (either uml:CallEvent is packagedElement
or uml:CallEvent is referenced by MessageOccurence)

The structure of sequence diagram is the following:

Model
Package
CallEvent
Collaboration
Interaction
Lifeline
MessageOccurenceSpecification
MessageOccurenceSpecification
Message


Each Message has two MessageOccurenceSpecification. Each
MessageOccurenceSpecification has the property "event" which points to
CallEvent.


Preserving the package structure for uml:CallEvent, I have the lazy rule:

from s : UML2!"uml::Package"
to out: UML2!"uml::Package" (
packagedElement<-s.packagedElement->select....->thisModule.addCallEvent(e))

This is the lazy rule:

lazy rule addCallEvent {
from s : UML2!"uml::NamedElement"
to out: UML2!"uml::CallEvent"
}

The uml:CallEvent will be correctly nested into uml:Package.


Achieving a reference by MessageOccurenceSpecification, I do the following:

--creating the 2nd MessageOccurenceSpecification
lazy rule CallOp2MessOcurSpec0 {
from s: UML2!"uml::NamedElement"
to out: UML2!"uml::MessageOccurrenceSpecification"(
name<-s.name)
do {
out.event<-thisModule.addCallEvent(s);
}

Obviously, this lazy rule will damage the hierarchical structure since the
uml:CallEvent will be placed at the top level and not within uml:Package.

How can I achieve that uml:CallEvent will be created within uml:Package
and later it will be referenced by uml:MessageOccurenceSpecification ?

Do I need a second transformation with refining mode ? If so, how would it
look like ? I didn't manage creating such a transformation with refining
mode.

Any help will be highly appreciated !


Regards,


Thomas
Re: [ATL]Hierarchical structure not preserved with called/lazy rules [message #98338 is a reply to message #98309] Mon, 26 January 2009 07:59 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hi
comments below

Thomas Winkler a écrit :
> Thanks Tristan !!!

you're welcome

>
> Just one more question. Maybe you or anyone else can help me.
>
> Sequence diagram needs uml:CallEvent. But I can't get it done that
> uml:CallEvent is a child of Package AND it referenced by MessageOccurence.
>
> I achieve only one of the targets (either uml:CallEvent is
> packagedElement or uml:CallEvent is referenced by MessageOccurence)
>
> The structure of sequence diagram is the following:
>
> Model
> Package
> CallEvent
> Collaboration
> Interaction
> Lifeline
> MessageOccurenceSpecification
> MessageOccurenceSpecification
> Message
>
>
> Each Message has two MessageOccurenceSpecification. Each
> MessageOccurenceSpecification has the property "event" which points to
> CallEvent.
>
>
> Preserving the package structure for uml:CallEvent, I have the lazy rule:
>
> from s : UML2!"uml::Package"
> to out: UML2!"uml::Package" (
>
> packagedElement<-s.packagedElement->select....->thisModule.addCallEvent(e))
>
> This is the lazy rule:
>
> lazy rule addCallEvent {
> from s : UML2!"uml::NamedElement"
> to out: UML2!"uml::CallEvent"
> }
>
> The uml:CallEvent will be correctly nested into uml:Package.
>
>
> Achieving a reference by MessageOccurenceSpecification, I do the following:
>
> --creating the 2nd MessageOccurenceSpecification
> lazy rule CallOp2MessOcurSpec0 {
> from s: UML2!"uml::NamedElement"
> to out: UML2!"uml::MessageOccurrenceSpecification"(
> name<-s.name)
> do {
> out.event<-thisModule.addCallEvent(s);
> }

with out.event<-thisModule.addCallEvent(s); you specify to create a new
call Event. Maybe you should use "unique" key word (i've never used it :( )

unique lazy rule addCallEvent {
from s : UML2!"uml::NamedElement"
to out: UML2!"uml::CallEvent"
}

it seems that this keyword means only one object will be created for an
input element and should referenced your objects already created

if this solution doesn't work maybe we should reconsider your rules and
explore other solutions (called rules with global variables ...)



>
> Obviously, this lazy rule will damage the hierarchical structure since
> the uml:CallEvent will be placed at the top level and not within
> uml:Package.
>
> How can I achieve that uml:CallEvent will be created within uml:Package
> and later it will be referenced by uml:MessageOccurenceSpecification ?
>
> Do I need a second transformation with refining mode ? If so, how would
> it look like ? I didn't manage creating such a transformation with
> refining mode.
>
> Any help will be highly appreciated !
>
>
> Regards,
>
>
> Thomas
>




Re: [ATL]Hierarchical structure not preserved with called/lazy rules [message #98367 is a reply to message #98338] Mon, 26 January 2009 14:34 Go to previous messageGo to next message
Eclipse UserFriend
Tristan FAURE wrote:

>Maybe you should use "unique" key word (i've never used it :( )
> unique lazy rule addCallEvent {
> from s : UML2!"uml::NamedElement"
> to out: UML2!"uml::CallEvent"
> }

> it seems that this keyword means only one object will be created for an
> input element and should referenced your objects already created

That's it !! Thanks again !

The keyword "unique" is doing exactly what you described and exactly what
I want :-)

I should have read the User guide more carefully...

Cheers,

Thomas
Re: [ATL]Hierarchical structure not preserved with called/lazy rules [message #98396 is a reply to message #98367] Mon, 26 January 2009 16:02 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Okay i'm glad to know it's the correct feature you avoid me to check it :)

Thomas Winkler a écrit :
> Tristan FAURE wrote:
>
>> Maybe you should use "unique" key word (i've never used it :( )
>> unique lazy rule addCallEvent {
>> from s : UML2!"uml::NamedElement"
>> to out: UML2!"uml::CallEvent"
>> }
>
>> it seems that this keyword means only one object will be created for
>> an input element and should referenced your objects already created
>
> That's it !! Thanks again !
>
> The keyword "unique" is doing exactly what you described and exactly
> what I want :-)
>
> I should have read the User guide more carefully...
>
> Cheers,
>
> Thomas
>
>
>
>
>




Re: [ATL]Hierarchical structure not preserved with called/lazy rules [message #98411 is a reply to message #98396] Mon, 26 January 2009 16:41 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 301
Registered: July 2009
Senior Member
Hello,

A wiki section exists about unique lazy rules:
http://wiki.eclipse.org/ATL/User_Guide#Unique_Lazy_Rules

.... I don't blame you as I created it 2 weeks ago! ;-)

Anyway, feel free to improve it if you think there is a need (you just
need a bugzilla account to modify the wiki), as for other sections.

William

Tristan FAURE a écrit :
> Okay i'm glad to know it's the correct feature you avoid me to check it :)
>
> Thomas Winkler a écrit :
>> Tristan FAURE wrote:
>>
>>> Maybe you should use "unique" key word (i've never used it :( )
>>> unique lazy rule addCallEvent {
>>> from s : UML2!"uml::NamedElement"
>>> to out: UML2!"uml::CallEvent"
>>> }
>>
>>> it seems that this keyword means only one object will be created for
>>> an input element and should referenced your objects already created
>>
>> That's it !! Thanks again !
>>
>> The keyword "unique" is doing exactly what you described and exactly
>> what I want :-)
>>
>> I should have read the User guide more carefully...
>>
>> Cheers,
>>
>> Thomas
>>
>>
>>
>>
>>
Re: [ATL]Hierarchical structure not preserved with called/lazy rules [message #98483 is a reply to message #98411] Tue, 27 January 2009 10:26 Go to previous message
Eclipse UserFriend
Hi William,
> A wiki section exists about unique lazy rules:
> http://wiki.eclipse.org/ATL/User_Guide#Unique_Lazy_Rules
> .... I don't blame you as I created it 2 weeks ago! ;-)

Thank you very much. That's a huge relief for me :-)

> Anyway, feel free to improve it if you think there is a need (you just
> need a bugzilla account to modify the wiki), as for other sections.

Yes, I will add an example (with screenshots)concerning the Unique Lazy
Rule soon.

Regards,

Thomas
Previous Topic:[ATL] Documentation on semantics
Next Topic:[QVTO] Trace of transformation execution
Goto Forum:
  


Current Time: Fri Apr 26 16:49:24 GMT 2024

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

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

Back to the top