ATL - How to assign a new value to an attribute of type map [message #44176] |
Mon, 04 June 2007 15:01 |
Eclipse User |
|
|
|
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 |
�ric Vépa 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
|
|
|
Powered by
FUDForum. Page generated in 0.03435 seconds