Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Group elements together in target model
[ATL] Group elements together in target model [message #72427] Thu, 17 January 2008 21:13 Go to next message
Daniel van 't Oever is currently offline Daniel van 't OeverFriend
Messages: 6
Registered: July 2009
Junior Member
I have an ATL rule that create multiple elements in my target model. I
would like to know if there is a way to keep them grouped together.

Suposse I have a rule that creates two elements (say A and 8) in the
target model, each time it is invoked. Now there is another rule that
needs to collect these 'pairs' of A and B. But all As and Bs are no
longer "grouped together".

rule Select
{
from
nqlSelect : nql!Select( nqlSelect.oclIsTypeOf(nql!Select) )
to
acHqlArg : ac!Statement(
name <- 'PUSH',
arguments <- nqlSelect.arguments->collect( a |
thisModule.resolveTemp( a, 'argOut' ) )
),

acQuery : ac!Statement(
name <- 'QUERY'
)
}

Instead of creating acHqlArg and acQuery I would like to output:
Sequence{ acHqlArg, acQuery }

I want my transformation to remain declarative.

How can I do this?

Daniel
Re: [ATL] Group elements together in target model [message #72445 is a reply to message #72427] Fri, 18 January 2008 08:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Hugo.Bruneliere.univ-nantes.fr

Hi Daniel,

Daniel van 't Oever a écrit :
> I have an ATL rule that create multiple elements in my target model. I
> would like to know if there is a way to keep them grouped together.
>
> Suposse I have a rule that creates two elements (say A and 8) in the
> target model, each time it is invoked. Now there is another rule that
> needs to collect these 'pairs' of A and B. But all As and Bs are no
> longer "grouped together".
>
> rule Select
> {
> from
> nqlSelect : nql!Select( nqlSelect.oclIsTypeOf(nql!Select) )
> to
> acHqlArg : ac!Statement(
> name <- 'PUSH',
> arguments <- nqlSelect.arguments->collect( a |
> thisModule.resolveTemp( a, 'argOut' ) )
> ),
>
> acQuery : ac!Statement(
> name <- 'QUERY'
> )
> }
>
> Instead of creating acHqlArg and acQuery I would like to output:
> Sequence{ acHqlArg, acQuery }
>
> I want my transformation to remain declarative.
>
> How can I do this?
>

The output generated model conforms to a given metamodel ("ac" in your
example). So if you want two "ac!Statement" to be grouped in your output
model, you have to add a specific concept allowing to do this in your
"ac" metamodel. Then, you can create such an element (which groups the
two "ac!Statement" elements) in your output model.

> Daniel

Best regards,

Hugo

--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
Re: [ATL] Group elements together in target model [message #72463 is a reply to message #72445] Fri, 18 January 2008 10:01 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hi Daniel,

Hugo suggested to modify your metamodel. Depending on what you precisely
want, this may be a good option.

However, if what you want to achieve is to "interleave" the collection
of pairs of elements (without modifying the metamodel), you could use
the scheme presented below.


Here is a description of what we want to achieve here. Note that the
value of property *elements* is not implemented, but described in this
version:

rule R1 {
from
s : MM1!A
to
t1 : MM2!B,
t2 : MM2!C
}

rule R2 {
from
s : MM1!D
to
t : MM2!E (
elements <- "for each element of s.as, get its B then its C"
)
}


For instance, given model:

d1 {a1, a2, a3, a4}

where d1 is a MM1!D, and a<n> are MM1!As.

We want to obtain:

e1 {b1, c1, b2, c2, b3, c3, b4, c4}



And here is a possible implementation using lazy rules:


unique lazy rule R1_B {
from
s : MM1!A
to
t1 : MM2!B
}

unique lazy rule R1_C {
from
s : MM1!A
to
t2 : MM2!C
}


rule R2 {
from
s : MM1!D
to
t : MM2!E (
elements <- s.as->collect(e |
Sequence {
thisModule.R1_B(e),
thisModule.R1_C(e)
}
)->flatten()
)
}


Regards,

Frédéric Jouault


Hugo Bruneliere wrote:
> Hi Daniel,
>
> Daniel van 't Oever a écrit :
>> I have an ATL rule that create multiple elements in my target model. I
>> would like to know if there is a way to keep them grouped together.
>>
>> Suposse I have a rule that creates two elements (say A and 8) in the
>> target model, each time it is invoked. Now there is another rule that
>> needs to collect these 'pairs' of A and B. But all As and Bs are no
>> longer "grouped together".
>>
>> rule Select
>> {
>> from
>> nqlSelect : nql!Select( nqlSelect.oclIsTypeOf(nql!Select) )
>> to
>> acHqlArg : ac!Statement(
>> name <- 'PUSH',
>> arguments <- nqlSelect.arguments->collect( a |
>> thisModule.resolveTemp( a, 'argOut' ) )
>> ),
>>
>> acQuery : ac!Statement(
>> name <- 'QUERY'
>> )
>> }
>>
>> Instead of creating acHqlArg and acQuery I would like to output:
>> Sequence{ acHqlArg, acQuery }
>>
>> I want my transformation to remain declarative.
>>
>> How can I do this?
>>
>
> The output generated model conforms to a given metamodel ("ac" in your
> example). So if you want two "ac!Statement" to be grouped in your output
> model, you have to add a specific concept allowing to do this in your
> "ac" metamodel. Then, you can create such an element (which groups the
> two "ac!Statement" elements) in your output model.
>
>> Daniel
>
> Best regards,
>
> Hugo
>
Re: [ATL] Group elements together in target model [message #72481 is a reply to message #72445] Fri, 18 January 2008 10:00 Go to previous messageGo to next message
Daniel van 't Oever is currently offline Daniel van 't OeverFriend
Messages: 6
Registered: July 2009
Junior Member
I already thought of this. But my situation is the following, in my
source model I have many select elements. What you suggest is this (in
pseudo code)

nql!Select ->
<ac!GroupingConcept><ac!Statement1><ac!Statement2></ac!GroupingConcept >

I do have some sort of 'acGroupingConcept' element in my target model.
But this element must contain ALL pairs of
<ac!Statement1><ac!Statement2> in a long list.

What you suggest is this

<acMain>
<acGroupingConcept><ac!Statement1><ac!Statement2></acGroupingConcept >
<acGroupingConcept><ac!Statement3><ac!Statement4></acGroupingConcept >
<acGroupingConcept><ac!Statement5><ac!Statement6></acGroupingConcept >
</acMain>

What I want is this:

<acMain>
<ac!Statement1><ac!Statement2>
<ac!Statement3><ac!Statement4>
<ac!Statement5><ac!Statement6>
</acMain>

I need a mechanism to temporarily keep these ac!Statement pairs together
and finally collect all these pairs and put them in ac!Main

Thanks in advance,
Daniel

Hugo Bruneliere wrote:
> Hi Daniel,
>
> Daniel van 't Oever a écrit :
>> I have an ATL rule that create multiple elements in my target model. I
>> would like to know if there is a way to keep them grouped together.
>>
>> Suposse I have a rule that creates two elements (say A and 8) in the
>> target model, each time it is invoked. Now there is another rule that
>> needs to collect these 'pairs' of A and B. But all As and Bs are no
>> longer "grouped together".
>>
>> rule Select
>> {
>> from
>> nqlSelect : nql!Select( nqlSelect.oclIsTypeOf(nql!Select) )
>> to
>> acHqlArg : ac!Statement(
>> name <- 'PUSH',
>> arguments <- nqlSelect.arguments->collect( a |
>> thisModule.resolveTemp( a, 'argOut' ) )
>> ),
>>
>> acQuery : ac!Statement(
>> name <- 'QUERY'
>> )
>> }
>>
>> Instead of creating acHqlArg and acQuery I would like to output:
>> Sequence{ acHqlArg, acQuery }
>>
>> I want my transformation to remain declarative.
>>
>> How can I do this?
>>
>
> The output generated model conforms to a given metamodel ("ac" in your
> example). So if you want two "ac!Statement" to be grouped in your output
> model, you have to add a specific concept allowing to do this in your
> "ac" metamodel. Then, you can create such an element (which groups the
> two "ac!Statement" elements) in your output model.
>
>> Daniel
>
> Best regards,
>
> Hugo
>
Re: [ATL] Group elements together in target model [message #72503 is a reply to message #72463] Fri, 18 January 2008 10:16 Go to previous messageGo to next message
Daniel van 't Oever is currently offline Daniel van 't OeverFriend
Messages: 6
Registered: July 2009
Junior Member
Yes this is exactly what I was looking for. This should work fine for
grouping two elements together. But is doesn't really scale well.
Suppose I have five target elements does that mean I have to create 5 +
1 rules to the same?

I think it will be usefull if rules could be specific like this:

unique lazy rule R1_C {
from
s : MM1!A
to
x : Sequence( MM2!B, MM2!C ) {
t1: MM2!B,
t2: MM2!C
}
}

Then I can do something like this:

rule R2 {
from
s : MM1!D
to
t : MM2!E (
elements <- thisModule.R1_C( s.as )
)
}

What do you think of it?

Frédéric Jouault wrote:
> Hi Daniel,
>
> Hugo suggested to modify your metamodel. Depending on what you precisely
> want, this may be a good option.
>
> However, if what you want to achieve is to "interleave" the collection
> of pairs of elements (without modifying the metamodel), you could use
> the scheme presented below.
>
>
> Here is a description of what we want to achieve here. Note that the
> value of property *elements* is not implemented, but described in this
> version:
>
> rule R1 {
> from
> s : MM1!A
> to
> t1 : MM2!B,
> t2 : MM2!C
> }
>
> rule R2 {
> from
> s : MM1!D
> to
> t : MM2!E (
> elements <- "for each element of s.as, get its B then its C"
> )
> }
>
>
> For instance, given model:
>
> d1 {a1, a2, a3, a4}
>
> where d1 is a MM1!D, and a<n> are MM1!As.
>
> We want to obtain:
>
> e1 {b1, c1, b2, c2, b3, c3, b4, c4}
>
>
>
> And here is a possible implementation using lazy rules:
>
>
> unique lazy rule R1_B {
> from
> s : MM1!A
> to
> t1 : MM2!B
> }
>
> unique lazy rule R1_C {
> from
> s : MM1!A
> to
> t2 : MM2!C
> }
>
>
> rule R2 {
> from
> s : MM1!D
> to
> t : MM2!E (
> elements <- s.as->collect(e |
> Sequence {
> thisModule.R1_B(e),
> thisModule.R1_C(e)
> }
> )->flatten()
> )
> }
>
>
> Regards,
>
> Frédéric Jouault
>
>
> Hugo Bruneliere wrote:
>> Hi Daniel,
>>
>> Daniel van 't Oever a écrit :
>>> I have an ATL rule that create multiple elements in my target model.
>>> I would like to know if there is a way to keep them grouped together.
>>>
>>> Suposse I have a rule that creates two elements (say A and 8) in the
>>> target model, each time it is invoked. Now there is another rule that
>>> needs to collect these 'pairs' of A and B. But all As and Bs are no
>>> longer "grouped together".
>>>
>>> rule Select
>>> {
>>> from
>>> nqlSelect : nql!Select( nqlSelect.oclIsTypeOf(nql!Select) )
>>> to
>>> acHqlArg : ac!Statement(
>>> name <- 'PUSH',
>>> arguments <- nqlSelect.arguments->collect( a |
>>> thisModule.resolveTemp( a, 'argOut' ) )
>>> ),
>>>
>>> acQuery : ac!Statement(
>>> name <- 'QUERY'
>>> )
>>> }
>>>
>>> Instead of creating acHqlArg and acQuery I would like to output:
>>> Sequence{ acHqlArg, acQuery }
>>>
>>> I want my transformation to remain declarative.
>>>
>>> How can I do this?
>>>
>>
>> The output generated model conforms to a given metamodel ("ac" in your
>> example). So if you want two "ac!Statement" to be grouped in your
>> output model, you have to add a specific concept allowing to do this
>> in your "ac" metamodel. Then, you can create such an element (which
>> groups the two "ac!Statement" elements) in your output model.
>>
>>> Daniel
>>
>> Best regards,
>>
>> Hugo
>>
Re: [ATL] Group elements together in target model [message #72520 is a reply to message #72503] Fri, 18 January 2008 12:02 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Well, if you prefer having a single rule, you should be able to do it
using resolveTemp:


rule R1 {
from
s : MM1!A
to
t1 : MM2!B,
t2 : MM2!C
}


rule R2 {
from
s : MM1!D
to
t : MM2!E (
elements <- s.as->collect(e |
Sequence {
e, -- equivalent to: thisModule.resolveTemp(e, 't1')
thisModule.resolveTemp(e, 't2')
}
)->flatten()
)
}


Regards,

Frédéric Jouault


Daniel van 't Oever wrote:
> Yes this is exactly what I was looking for. This should work fine for
> grouping two elements together. But is doesn't really scale well.
> Suppose I have five target elements does that mean I have to create 5 +
> 1 rules to the same?
>
> I think it will be usefull if rules could be specific like this:
>
> unique lazy rule R1_C {
> from
> s : MM1!A
> to
> x : Sequence( MM2!B, MM2!C ) {
> t1: MM2!B,
> t2: MM2!C
> }
> }
>
> Then I can do something like this:
>
> rule R2 {
> from
> s : MM1!D
> to
> t : MM2!E (
> elements <- thisModule.R1_C( s.as )
> )
> }
>
> What do you think of it?
>
> Frédéric Jouault wrote:
>> Hi Daniel,
>>
>> Hugo suggested to modify your metamodel. Depending on what you
>> precisely want, this may be a good option.
>>
>> However, if what you want to achieve is to "interleave" the collection
>> of pairs of elements (without modifying the metamodel), you could use
>> the scheme presented below.
>>
>>
>> Here is a description of what we want to achieve here. Note that the
>> value of property *elements* is not implemented, but described in this
>> version:
>>
>> rule R1 {
>> from
>> s : MM1!A
>> to
>> t1 : MM2!B,
>> t2 : MM2!C
>> }
>>
>> rule R2 {
>> from
>> s : MM1!D
>> to
>> t : MM2!E (
>> elements <- "for each element of s.as, get its B then its C"
>> )
>> }
>>
>>
>> For instance, given model:
>>
>> d1 {a1, a2, a3, a4}
>>
>> where d1 is a MM1!D, and a<n> are MM1!As.
>>
>> We want to obtain:
>>
>> e1 {b1, c1, b2, c2, b3, c3, b4, c4}
>>
>>
>>
>> And here is a possible implementation using lazy rules:
>>
>>
>> unique lazy rule R1_B {
>> from
>> s : MM1!A
>> to
>> t1 : MM2!B
>> }
>>
>> unique lazy rule R1_C {
>> from
>> s : MM1!A
>> to
>> t2 : MM2!C
>> }
>>
>>
>> rule R2 {
>> from
>> s : MM1!D
>> to
>> t : MM2!E (
>> elements <- s.as->collect(e |
>> Sequence {
>> thisModule.R1_B(e),
>> thisModule.R1_C(e)
>> }
>> )->flatten()
>> )
>> }
>>
>>
>> Regards,
>>
>> Frédéric Jouault
>>
>>
>> Hugo Bruneliere wrote:
>>> Hi Daniel,
>>>
>>> Daniel van 't Oever a écrit :
>>>> I have an ATL rule that create multiple elements in my target model.
>>>> I would like to know if there is a way to keep them grouped together.
>>>>
>>>> Suposse I have a rule that creates two elements (say A and 8) in the
>>>> target model, each time it is invoked. Now there is another rule
>>>> that needs to collect these 'pairs' of A and B. But all As and Bs
>>>> are no longer "grouped together".
>>>>
>>>> rule Select
>>>> {
>>>> from
>>>> nqlSelect : nql!Select( nqlSelect.oclIsTypeOf(nql!Select) )
>>>> to
>>>> acHqlArg : ac!Statement(
>>>> name <- 'PUSH',
>>>> arguments <- nqlSelect.arguments->collect( a |
>>>> thisModule.resolveTemp( a, 'argOut' ) )
>>>> ),
>>>>
>>>> acQuery : ac!Statement(
>>>> name <- 'QUERY'
>>>> )
>>>> }
>>>>
>>>> Instead of creating acHqlArg and acQuery I would like to output:
>>>> Sequence{ acHqlArg, acQuery }
>>>>
>>>> I want my transformation to remain declarative.
>>>>
>>>> How can I do this?
>>>>
>>>
>>> The output generated model conforms to a given metamodel ("ac" in
>>> your example). So if you want two "ac!Statement" to be grouped in
>>> your output model, you have to add a specific concept allowing to do
>>> this in your "ac" metamodel. Then, you can create such an element
>>> (which groups the two "ac!Statement" elements) in your output model.
>>>
>>>> Daniel
>>>
>>> Best regards,
>>>
>>> Hugo
>>>
Re: [ATL] Group elements together in target model [message #73174 is a reply to message #72520] Wed, 23 January 2008 11:57 Go to previous messageGo to next message
Daniel van 't Oever is currently offline Daniel van 't OeverFriend
Messages: 6
Registered: July 2009
Junior Member
One more thing,

You assume in rule R2 in the 'to' part that I have an 'elements'
container. What if I do not have this elements collection? It is
possible to generate a bunch of single elements without assigning them.
Is the same possible with a collection? (And that I assign them later)



Frédéric Jouault wrote:
> Well, if you prefer having a single rule, you should be able to do it
> using resolveTemp:
>
>
> rule R1 {
> from
> s : MM1!A
> to
> t1 : MM2!B,
> t2 : MM2!C
> }
>
>
> rule R2 {
> from
> s : MM1!D
> to
> t : MM2!E (
> elements <- s.as->collect(e |
> Sequence {
> e, -- equivalent to: thisModule.resolveTemp(e, 't1')
> thisModule.resolveTemp(e, 't2')
> }
> )->flatten()
> )
> }
>
>
> Regards,
>
> Frédéric Jouault
>
>
> Daniel van 't Oever wrote:
>> Yes this is exactly what I was looking for. This should work fine for
>> grouping two elements together. But is doesn't really scale well.
>> Suppose I have five target elements does that mean I have to create 5
>> + 1 rules to the same?
>>
>> I think it will be usefull if rules could be specific like this:
>>
>> unique lazy rule R1_C {
>> from
>> s : MM1!A
>> to
>> x : Sequence( MM2!B, MM2!C ) {
>> t1: MM2!B,
>> t2: MM2!C
>> }
>> }
>>
>> Then I can do something like this:
>>
>> rule R2 {
>> from
>> s : MM1!D
>> to
>> t : MM2!E (
>> elements <- thisModule.R1_C( s.as )
>> )
>> }
>>
>> What do you think of it?
>>
>> Frédéric Jouault wrote:
>>> Hi Daniel,
>>>
>>> Hugo suggested to modify your metamodel. Depending on what you
>>> precisely want, this may be a good option.
>>>
>>> However, if what you want to achieve is to "interleave" the
>>> collection of pairs of elements (without modifying the metamodel),
>>> you could use the scheme presented below.
>>>
>>>
>>> Here is a description of what we want to achieve here. Note that the
>>> value of property *elements* is not implemented, but described in
>>> this version:
>>>
>>> rule R1 {
>>> from
>>> s : MM1!A
>>> to
>>> t1 : MM2!B,
>>> t2 : MM2!C
>>> }
>>>
>>> rule R2 {
>>> from
>>> s : MM1!D
>>> to
>>> t : MM2!E (
>>> elements <- "for each element of s.as, get its B then its C"
>>> )
>>> }
>>>
>>>
>>> For instance, given model:
>>>
>>> d1 {a1, a2, a3, a4}
>>>
>>> where d1 is a MM1!D, and a<n> are MM1!As.
>>>
>>> We want to obtain:
>>>
>>> e1 {b1, c1, b2, c2, b3, c3, b4, c4}
>>>
>>>
>>>
>>> And here is a possible implementation using lazy rules:
>>>
>>>
>>> unique lazy rule R1_B {
>>> from
>>> s : MM1!A
>>> to
>>> t1 : MM2!B
>>> }
>>>
>>> unique lazy rule R1_C {
>>> from
>>> s : MM1!A
>>> to
>>> t2 : MM2!C
>>> }
>>>
>>>
>>> rule R2 {
>>> from
>>> s : MM1!D
>>> to
>>> t : MM2!E (
>>> elements <- s.as->collect(e |
>>> Sequence {
>>> thisModule.R1_B(e),
>>> thisModule.R1_C(e)
>>> }
>>> )->flatten()
>>> )
>>> }
>>>
>>>
>>> Regards,
>>>
>>> Frédéric Jouault
>>>
>>>
>>> Hugo Bruneliere wrote:
>>>> Hi Daniel,
>>>>
>>>> Daniel van 't Oever a écrit :
>>>>> I have an ATL rule that create multiple elements in my target
>>>>> model. I would like to know if there is a way to keep them grouped
>>>>> together.
>>>>>
>>>>> Suposse I have a rule that creates two elements (say A and 8) in
>>>>> the target model, each time it is invoked. Now there is another
>>>>> rule that needs to collect these 'pairs' of A and B. But all As and
>>>>> Bs are no longer "grouped together".
>>>>>
>>>>> rule Select
>>>>> {
>>>>> from
>>>>> nqlSelect : nql!Select( nqlSelect.oclIsTypeOf(nql!Select) )
>>>>> to
>>>>> acHqlArg : ac!Statement(
>>>>> name <- 'PUSH',
>>>>> arguments <- nqlSelect.arguments->collect( a |
>>>>> thisModule.resolveTemp( a, 'argOut' ) )
>>>>> ),
>>>>>
>>>>> acQuery : ac!Statement(
>>>>> name <- 'QUERY'
>>>>> )
>>>>> }
>>>>>
>>>>> Instead of creating acHqlArg and acQuery I would like to output:
>>>>> Sequence{ acHqlArg, acQuery }
>>>>>
>>>>> I want my transformation to remain declarative.
>>>>>
>>>>> How can I do this?
>>>>>
>>>>
>>>> The output generated model conforms to a given metamodel ("ac" in
>>>> your example). So if you want two "ac!Statement" to be grouped in
>>>> your output model, you have to add a specific concept allowing to do
>>>> this in your "ac" metamodel. Then, you can create such an element
>>>> (which groups the two "ac!Statement" elements) in your output model.
>>>>
>>>>> Daniel
>>>>
>>>> Best regards,
>>>>
>>>> Hugo
>>>>
Re: [ATL] Group elements together in target model [message #73267 is a reply to message #73174] Thu, 24 January 2008 16:35 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> You assume in rule R2 in the 'to' part that I have an 'elements'
> container. What if I do not have this elements collection? It is
> possible to generate a bunch of single elements without assigning them.
> Is the same possible with a collection? (And that I assign them later)

If you do not assign the collection of grouped element to a property,
then it will not exist in the target model.


Regards,

Frédéric Jouault
Previous Topic:[QVTO] Implicit source vs contextless invocation
Next Topic:[ATL] Select and delete ASMModelElement
Goto Forum:
  


Current Time: Sun Apr 11 02:14:58 GMT 2021

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

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

Back to the top