Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Set boolean flag if object is referenced
[ATL] Set boolean flag if object is referenced [message #521429] Wed, 17 March 2010 15:07 Go to next message
Bernhard Lutzmann is currently offline Bernhard LutzmannFriend
Messages: 9
Registered: March 2010
Junior Member
Hello,

I have been playing around with ATL a little bit and am trying to solve the following:

My input model contains a collection (0...*) of classes and a reference to one of these classes.

My output model contains the same collection, but instead of the reference to one of the classes, every class contains a boolean flag.

What I want is that the transformation sets the boolean flag to "true" in the class that is referenced in the input model.

Any ideas how to accomplish this?


I tried something like the following:
module In2Out;
create OUT : OutModel from IN : InModel;

helper def : isFinishStation(station : InModel!Station) : Boolean =
   if (station = self.finishStation) then
      true
   else
      false
   endif;

rule Level2Level {
   from
      s : InModel!Level
   to
      t : OutModel!Level (
         stations <- s.stations
      )
}

rule Station2Station {
   from
      s : InModel!Station
   to
      t : OutModel!Station (
         name <- s.name,
         isFinishStation <- thisModule.isFinishStation(s)
   )
}


If I run the transformation then it produces an output model without any errors on the console.
But the boolean flag is never set to true.

Thanks for the help,
Bernhard
Re: [ATL] Set boolean flag if object is referenced [message #521450 is a reply to message #521429] Wed, 17 March 2010 15:50 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
Bernhard L. a écrit :
> Hello,
>
> I have been playing around with ATL a little bit and am trying to solve
> the following:
>
> My input model contains a collection (0...*) of classes and a reference
> to one of these classes.
>
> My output model contains the same collection, but instead of the
> reference to one of the classes, every class contains a boolean flag.
>
> What I want is that the transformation sets the boolean flag to "true"
> in the class that is referenced in the input model.
>
> Any ideas how to accomplish this?
>
>
> I tried something like the following:
>
> module In2Out;
> create OUT : OutModel from IN : InModel;
>
> helper def : isFinishStation(station : InModel!Station) : Boolean =
> if (station = self.finishStation) then

Here "self" refers to the current station.... (if I'm correct).
You need to refer to the input "model" (or anything else) which have the
reference.
You may try to get "station" container [container] and see its
"finishStation" property ...

> true
> else
> false
> endif;
>
> rule Level2Level {
> from
> s : InModel!Level
> to
> t : OutModel!Level (
> stations <- s.stations
> )
> }
>
> rule Station2Station {
> from
> s : InModel!Station
> to
> t : OutModel!Station (
> name <- s.name,
> isFinishStation <- thisModule.isFinishStation(s)
> )
> }
>
>
> If I run the transformation then it produces an output model without any
> errors on the console.
> But the boolean flag is never set to true.
>
> Thanks for the help,
> Bernhard


--
Cordialement

Vincent MAHÉ

Ingénieur plate-forme - Cesar/Artemisia - Équipe Espresso
IRISA-INRIA, Campus de Beaulieu, 35042 Rennes cedex, France
Tél: +33 (0) 2 99 84 71 00, Fax: +33 (0) 2 99 84 71 71
Re: [ATL] Set boolean flag if object is referenced [message #521578 is a reply to message #521450] Thu, 18 March 2010 07:26 Go to previous messageGo to next message
Bernhard Lutzmann is currently offline Bernhard LutzmannFriend
Messages: 9
Registered: March 2010
Junior Member
Vincent MAHE wrote on Wed, 17 March 2010 11:50

> helper def : isFinishStation(station : InModel!Station) : Boolean =
> if (station = self.finishStation) then

Here "self" refers to the current station.... (if I'm correct).
You need to refer to the input "model" (or anything else) which have the
reference.
You may try to get "station" container [container] and see its
"finishStation" property ...



Thanks Vincent. If I change "self.finishStation" to "station.eContainer().finishStation" then it works as expected.

Greetings,
Bernhard
Re: [ATL] Set boolean flag if object is referenced [message #521590 is a reply to message #521429] Thu, 18 March 2010 08:55 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
That's a bad way to define a helper; use the context :

helper context InModel!Station def : isFinishStation : Boolean =
if (station = self.eContainer().finishStation) then

and then just use it like that : s.isFinishStation
Re: [ATL] Set boolean flag if object is referenced [message #521598 is a reply to message #521590] Thu, 18 March 2010 09:24 Go to previous messageGo to next message
Bernhard Lutzmann is currently offline Bernhard LutzmannFriend
Messages: 9
Registered: March 2010
Junior Member
Sylvain EVEILLARD wrote on Thu, 18 March 2010 04:55

if (station = self.eContainer().finishStation) then



Thanks for the tip. It seems you ment the following:
self = self.eContainer().finishStation


Greetings,
Bernhard
Re: [ATL] Set boolean flag if object is referenced [message #521600 is a reply to message #521429] Thu, 18 March 2010 09:39 Go to previous message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
yep, copy/paste gone wrong Wink
Previous Topic:[ATL] Running ATL programmatically example?
Next Topic:how to use xtext before M2M transformation
Goto Forum:
  


Current Time: Tue Oct 15 12:25:40 GMT 2019

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

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

Back to the top