Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] unique lazy rule
[ATL] unique lazy rule [message #100628] Wed, 25 February 2009 02:08 Go to next message
Matt Fomr is currently offline Matt FomrFriend
Messages: 8
Registered: July 2009
Junior Member
Hi

I'm trying to convert UML!Class generalizations to properties with
following simple transformation:

module GeneralizationTest;
create output : UML from input : UML;

rule p2p
{
from iP:UML!Package
to oP:UML!Package
(
name <- iP.name,
packagedElement <- iP.packagedElement->collect(c|thisModule.c2c(c))
)
}

unique lazy rule c2c
{
from iC:UML!Class
to oC:UML!Class
(
name <- iC.name
)
do
{
('iC.name = '+iC.name).println();
oC.ownedAttribute <- iC.superClass->collect(sc|thisModule.sc2p(sc));
}
}

unique lazy rule sc2p
{
from c:UML!Class
to p:UML!Property
(
name <- 'base',
type <- thisModule.c2c(c)
)
}


But for a model input with one Base and one Derived class i get following
output:

<uml:Package xmi:id="_2TkbgALdEd6Xf7QB_xMJXw" name="input">
<packagedElement xmi:type="uml:Class" xmi:id="_2TkbgQLdEd6Xf7QB_xMJXw"
name="Base"/>
<packagedElement xmi:type="uml:Class" xmi:id="_2TkbggLdEd6Xf7QB_xMJXw"
name="Derived">
<ownedAttribute xmi:id="_2TkbgwLdEd6Xf7QB_xMJXw" name="base"
type="_2TkbhALdEd6Xf7QB_xMJXw"/>
</packagedElement>
</uml:Package>
<uml:Class xmi:id="_2TkbhALdEd6Xf7QB_xMJXw" name="Base"/>

(Base class is dubled, one is where it should be, and one outside package,
type od 'base' property of 'Derived' class is set to the one outside of
package)

Also executing transformation gives following console output:

iC.name = Base
iC.name = Derived
iC.name = Base

isn't 'unique lazy rule c2c' supposed to be executed only once for a given
input model element?

Am I missing something?

Regards
Matt
Re: [ATL] unique lazy rule [message #100657 is a reply to message #100628] Wed, 25 February 2009 08:07 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hi Matt
why do you use call rule in your rule c2c ?

you cand o do :
unique lazy rule c2c
{
from iC:UML!Class
to oC:UML!Class
(
name <- iC.name,
ownedAttribute <-
iC.superClass->collect(sc|thisModule.sc2p(sc));
)
do
{
('iC.name = '+iC.name).println();
}
}

maybe this is the cause of your problem. we never know when do section
are performed it's not very recommended to use it

Matt Fomr a écrit :
> Hi
>
> I'm trying to convert UML!Class generalizations to properties with
> following simple transformation:
>
> module GeneralizationTest;
> create output : UML from input : UML;
>
> rule p2p
> {
> from iP:UML!Package
> to oP:UML!Package
> (
> name <- iP.name,
> packagedElement <- iP.packagedElement->collect(c|thisModule.c2c(c))
> )
> }
>
> unique lazy rule c2c
> {
> from iC:UML!Class
> to oC:UML!Class
> (
> name <- iC.name
> )
> do
> {
> ('iC.name = '+iC.name).println();
> oC.ownedAttribute <-
> iC.superClass->collect(sc|thisModule.sc2p(sc));
> }
> }
>
> unique lazy rule sc2p
> {
> from c:UML!Class
> to p:UML!Property
> (
> name <- 'base',
> type <- thisModule.c2c(c)
> )
> }
>
>
> But for a model input with one Base and one Derived class i get
> following output:
>
> <uml:Package xmi:id="_2TkbgALdEd6Xf7QB_xMJXw" name="input">
> <packagedElement xmi:type="uml:Class"
> xmi:id="_2TkbgQLdEd6Xf7QB_xMJXw" name="Base"/>
> <packagedElement xmi:type="uml:Class"
> xmi:id="_2TkbggLdEd6Xf7QB_xMJXw" name="Derived">
> <ownedAttribute xmi:id="_2TkbgwLdEd6Xf7QB_xMJXw" name="base"
> type="_2TkbhALdEd6Xf7QB_xMJXw"/>
> </packagedElement>
> </uml:Package>
> <uml:Class xmi:id="_2TkbhALdEd6Xf7QB_xMJXw" name="Base"/>
>
> (Base class is dubled, one is where it should be, and one outside
> package, type od 'base' property of 'Derived' class is set to the one
> outside of package)
>
> Also executing transformation gives following console output:
>
> iC.name = Base
> iC.name = Derived
> iC.name = Base
>
> isn't 'unique lazy rule c2c' supposed to be executed only once for a
> given input model element?
>
> Am I missing something?
>
> Regards
> Matt
>




Re: [ATL] unique lazy rule [message #100671 is a reply to message #100657] Wed, 25 February 2009 10:30 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 want to say "call rule" but

why do you use a do section in your rule c2c ?
:)

Tristan FAURE a écrit :
> Hi Matt
> why do you use call rule in your rule c2c ?
>
> you cand o do :
> unique lazy rule c2c
> {
> from iC:UML!Class
> to oC:UML!Class
> (
> name <- iC.name,
> ownedAttribute <-
> iC.superClass->collect(sc|thisModule.sc2p(sc));
> )
> do
> {
> ('iC.name = '+iC.name).println();
> }
> }
>
> maybe this is the cause of your problem. we never know when do section
> are performed it's not very recommended to use it
>
> Matt Fomr a écrit :
>> Hi
>>
>> I'm trying to convert UML!Class generalizations to properties with
>> following simple transformation:
>>
>> module GeneralizationTest;
>> create output : UML from input : UML;
>>
>> rule p2p
>> {
>> from iP:UML!Package
>> to oP:UML!Package
>> (
>> name <- iP.name,
>> packagedElement <-
>> iP.packagedElement->collect(c|thisModule.c2c(c))
>> )
>> }
>>
>> unique lazy rule c2c
>> {
>> from iC:UML!Class
>> to oC:UML!Class
>> (
>> name <- iC.name
>> )
>> do
>> {
>> ('iC.name = '+iC.name).println();
>> oC.ownedAttribute <-
>> iC.superClass->collect(sc|thisModule.sc2p(sc));
>> }
>> }
>>
>> unique lazy rule sc2p
>> {
>> from c:UML!Class
>> to p:UML!Property
>> (
>> name <- 'base',
>> type <- thisModule.c2c(c)
>> )
>> }
>>
>>
>> But for a model input with one Base and one Derived class i get
>> following output:
>>
>> <uml:Package xmi:id="_2TkbgALdEd6Xf7QB_xMJXw" name="input">
>> <packagedElement xmi:type="uml:Class"
>> xmi:id="_2TkbgQLdEd6Xf7QB_xMJXw" name="Base"/>
>> <packagedElement xmi:type="uml:Class"
>> xmi:id="_2TkbggLdEd6Xf7QB_xMJXw" name="Derived">
>> <ownedAttribute xmi:id="_2TkbgwLdEd6Xf7QB_xMJXw" name="base"
>> type="_2TkbhALdEd6Xf7QB_xMJXw"/>
>> </packagedElement>
>> </uml:Package>
>> <uml:Class xmi:id="_2TkbhALdEd6Xf7QB_xMJXw" name="Base"/>
>>
>> (Base class is dubled, one is where it should be, and one outside
>> package, type od 'base' property of 'Derived' class is set to the one
>> outside of package)
>>
>> Also executing transformation gives following console output:
>>
>> iC.name = Base
>> iC.name = Derived
>> iC.name = Base
>>
>> isn't 'unique lazy rule c2c' supposed to be executed only once for a
>> given input model element?
>>
>> Am I missing something?
>>
>> Regards
>> Matt
>>




Re: [ATL] unique lazy rule [message #100685 is a reply to message #100657] Wed, 25 February 2009 10:33 Go to previous message
Matt Fomr is currently offline Matt FomrFriend
Messages: 8
Registered: July 2009
Junior Member
Hi

I use call rule in c2c because i want result of sc2p to stay accesible for
later use (not part of sample transformation), so sc2p has to be 'unique
lazy'.

Moving assignment to ownedAttribute from 'do' section to 'bindings'
section chanches only console output:
iC.name = Base
iC.name = Base
iC.name = Derived

Output model is the same..
Previous Topic:MtATL2009 CfP
Next Topic:[ATL] Progress monitor
Goto Forum:
  


Current Time: Wed Jan 15 08:16:01 GMT 2025

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

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

Back to the top