Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » ATL - How to assign a new value to an attribute of type map
ATL - How to assign a new value to an attribute of type map [message #44176] Mon, 04 June 2007 15:01 Go to next message
Eclipse UserFriend
Originally posted by: erik_becker.gmx.de

Hi all,

In my ATL transformation I want to create a Map(Integer, String) that
will be updated and used while the transformation.
Unfortunately the update doesn't work. I always get the same (empty) map.
Here's my code:
------------------------------------------------------------ ----------------
helper def : getNewID(amlID: String) : Integer =
if thisModule.IdMap.getKeys()->size() > 0 then
let
newId : Integer = thisModule.getMaximum(
thisModule.IdMap->getKeys()) + 1
in
let
temp : Map(Integer, String) =
thisModule.IdMap->including(newId, amlID)
in
thisModule.IdMap->getKeys().getMaximum()
else
let
newId : Integer = 1
in
thisModule.IdMap->including(newId,amlID)
.getKeys()->asSequence()->first()
endif;

helper def : IdMap : Map(Integer, String) = Map{};
------------------------------------------------------------ ------------------


The transformation doesn't fail, but it doesn't what I want.

If I make an assignment like
thisModule.IdMap <- thisModule.IdMap->including(...)
I get an problem in the ATL editor

How can I assign a new value to my 'IdMap' to update the attribute and
how to get the update attribute?

Can anyone help?

Regards

Erik
Re: [ATL] - How to assign a new value to an attribute of type map [message #44207 is a reply to message #44176] Mon, 04 June 2007 15:56 Go to previous message
Ã?ric Vépa is currently offline Ã?ric VépaFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Erik,

The including operation on a Map has a return type. This is why the
transformation works but does not behave as expected.

A Map can be filled in an imperative block (e.g "do" clause of a rule)
following the syntax you proposed:

....
do {
...
thisModule.IdMap <- thisModule.IdMap->including(...)
...
}
)

Helpers can be used for accessing the values (or keys) of a Map.

See the ATL User Manual for more details.

Erik Becker wrote:
> Hi all,
>
> In my ATL transformation I want to create a Map(Integer, String) that
> will be updated and used while the transformation.
> Unfortunately the update doesn't work. I always get the same (empty) map.
> Here's my code:
> ------------------------------------------------------------ ----------------
>
> helper def : getNewID(amlID: String) : Integer =
> if thisModule.IdMap.getKeys()->size() > 0 then
> let
> newId : Integer = thisModule.getMaximum(
> thisModule.IdMap->getKeys()) + 1
> in
> let
> temp : Map(Integer, String) =
> thisModule.IdMap->including(newId, amlID)
> in
> thisModule.IdMap->getKeys().getMaximum()
> else
> let
> newId : Integer = 1
> in
> thisModule.IdMap->including(newId,amlID)
> .getKeys()->asSequence()->first()
> endif;
>
> helper def : IdMap : Map(Integer, String) = Map{};
> ------------------------------------------------------------ ------------------
>
>
> The transformation doesn't fail, but it doesn't what I want.
>
> If I make an assignment like
> thisModule.IdMap <- thisModule.IdMap->including(...)
> I get an problem in the ATL editor
>
> How can I assign a new value to my 'IdMap' to update the attribute and
> how to get the update attribute?
>
> Can anyone help?
>
> Regards
>
> Erik


--
Éric Vépa

SODIUS
6, rue de la Cornouaille - BP 91941
44319 Nantes, France
Email: evepa@sodius.com

www.mdworkbench.com
Draw more value from your models
Previous Topic:[ATL] Proper nesting
Next Topic:[TCS] Where is km3.tcs file ?
Goto Forum:
  


Current Time: Tue Jan 19 22:56:22 GMT 2021

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

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

Back to the top