Mapping one object to multiple [message #1373915] |
Thu, 22 May 2014 07:31  |
Eclipse User |
|
|
|
Hi, I am new to ATL and MDD and I think I am missing something really important with this problem.
I have an object container which has a reference called group to one or more items.
I'm trying to write an in-place transformation that will insert a new item for every item already in a group so the group has twice as many elements than before the transformation is run.
Here is my current approach.
create OUT: source refining IN: source;
helper context source!item def: doSomething() : source!item =
self.refSetValue('interestingValue', 1)
;
helper context source!container def: generateSequence() : Sequence(source!item) =
self.group->iterate(e; res: Sequence(source!item) = Sequence{} |
res->append(e.doSomething())
)
;
rule putNewThingsThere {
from
s: source!container
to
t: source!container (
group <- s.generateSequence()
)
}
When I run this transformation, the items in group become the new ones, but I would like to retain the old ones as well. Can someone explain how in ATL we create fresh elements for the new model?
Thanks
|
|
|
|
|
Re: Mapping one object to multiple [message #1377755 is a reply to message #1374222] |
Fri, 23 May 2014 21:10   |
Eclipse User |
|
|
|
Hi, I have come across another problem.
I now have the new objects being created within the same container, but I need to be able to control the order.
If I start with a model which has a container with {A, B C}
My transformation results in {A, B, C, A1, B1, C1}
I have been trying to get it to produce {A, A1, B, B1, C, C1} but I am unsuccessful.
Is there a way to specify that the new elements should be inserted straight after their counterpart?
Thank you.
|
|
|
|
Re: Mapping one object to multiple [message #1383878 is a reply to message #1383665] |
Mon, 26 May 2014 11:55  |
Eclipse User |
|
|
|
Hello,
EMF is already providing some support to import XML documents as regular EMF models.
You should take a look to this (cf. the EMF documentation and forum).
If needed, you could of course use an additional ATL transformation to perform an eventually required mapping.
|
|
|
Powered by
FUDForum. Page generated in 0.10344 seconds