Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » EMFTVM/ATL How to assign the result of a rule matching several elements
EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053440] Sun, 05 May 2013 20:49 Go to next message
EtienneB Mising name is currently offline EtienneB Mising name
Messages: 35
Registered: June 2011
Member
Dear all,

progressing in the implementation of a model transformation with EMFTVM, I am facing a new issue: I wrote a matched rule that matches 2 elements but I didn't find out how to store the result of this rule in my model.

Here is a snippet of code to illustrate what I have in my code (sorry if it is not correct, I wrote it directly on the forum):
rule R1
{
  from
    c: AADL!ComponentInstance
  to
    implImg: AADL!ThreadImplementation
    (
        calls <- c.calls -- list of SubprogramCall
    )
}

rule R2
{
  from
    call: AADL!SubprogramCall
  to
    callImg: AADL!SubprogramCall
}

rule R3
{
  from
    c: AADL!ComponentInstance,
    call: AADL!SubprogramCall
    (c.entryPoint = call)
  to
    callImg: AADL!SubprogramCall
}


Basically, what I would like is that the element created by R1 (implImg) contains in it attribute "calls" the list of SubprogramCall created by R2 or R3. I tried using inheritence (R3 inherits R2) but it did not work. Maybe a "special" resolveTemp could solve my problem...

Any suggestion?
Thanks a lot,
Etienne.

[Updated on: Mon, 06 May 2013 20:34]

Report message to a moderator

Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053510 is a reply to message #1053440] Mon, 06 May 2013 10:59 Go to previous messageGo to next message
Javier García is currently offline Javier García
Messages: 129
Registered: April 2013
Senior Member
Maybe something like this could work:
rule R1
{
from
c: AADL!ComponentInstance
to
implImg: AADL!ThreadImplementation
(
calls <- c.calls, -- list of SubprogramCall
calls <- c.calls -> collect(e | thisModule.resolveTemp(e, 'callImg'))
)
}
Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053537 is a reply to message #1053510] Mon, 06 May 2013 12:44 Go to previous messageGo to next message
EtienneB Mising name is currently offline EtienneB Mising name
Messages: 35
Registered: June 2011
Member
Dear Javier,

I already tried this solution, but to my understanding R3 is matched by tuples (c, call). So it looks like using resolveTemp on a single element of type SubprogramCall does not work: it returns elements created by R2.

So I guess it all depends on the way EMFTVM stores elements in the trace when rules match tuples of elements. I am investigating but if someone has an answer that would be great!

Etienne.
Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053607 is a reply to message #1053537] Mon, 06 May 2013 19:49 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 165
Registered: September 2012
Senior Member

EMFTVM uses a Sequence instead of a Tuple as trace key, which contains the source elements in order.

In your specific case, you don't need to transform the Cartesian product of 'c' and 'call' in R3. Therefore you can use an explicit mapsTo:
rule R3 {
  from 
    c: AADL!ComponentInstance,
    call: AADL!SubprogramCall 
    (c.entryPoint = call)
  to
    callImg: AADL!SubprogramCall mapsTo call
}



Cheers,
Dennis
Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053611 is a reply to message #1053607] Mon, 06 May 2013 20:33 Go to previous messageGo to next message
EtienneB Mising name is currently offline EtienneB Mising name
Messages: 35
Registered: June 2011
Member
Dennis, your solution just works perfectly, this is awesome!

Just for my information, I tried this:

rule R1
{
  from
    c: AADL!ComponentInstance
  to
    implImg: AADL!ThreadImplementation
    (
      calls <- c.calls->collect(e| thisModule.resolveTemp(Sequence{c,e}, 'callImg'))
    )
}


and I get an exception: Cannot resolve default trace target 'callImg' for [the_sender:ComponentInstance, the_call:SubprogramCall]

Is there a mistake in my code? Or do I make a conceptual mistake? Or is it a feature not yet supported?

Thanks again,
Etienne.

[Updated on: Mon, 06 May 2013 20:34]

Report message to a moderator

Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053612 is a reply to message #1053611] Mon, 06 May 2013 20:45 Go to previous messageGo to next message
EtienneB Mising name is currently offline EtienneB Mising name
Messages: 35
Registered: June 2011
Member
I also found (after a rapid googling) this thread on the forum about "what does mapsTo mean":

http://www.eclipse.org/forums/index.php/t/8026/

Considering the answers and the date of the thread, maybe a short refreshment could be good Wink

Dennis, do you have more information to provide on this topic?

Thanks again,
Etienne.
Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053657 is a reply to message #1053612] Tue, 07 May 2013 07:52 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 165
Registered: September 2012
Senior Member

Yes: the semantics of "mapsTo" are slightly more elaborate for EMFTVM, and are currently only described in:

Dennis Wagelaar. A Revised Semantics for Rule Inheritance and Module Superimposition in ATL. Proceedings of the 3rd International Workshop on Model Transformation with ATL (MtATL 2011), pp.63 - 74.


Cheers,
Dennis
Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1057956 is a reply to message #1053657] Fri, 10 May 2013 06:06 Go to previous messageGo to next message
EtienneB Mising name is currently offline EtienneB Mising name
Messages: 35
Registered: June 2011
Member
Dear Dennis,

in some cases I have to use the Cartesian product of my model elements. Let's imagine we withdraw R2 from my previous example; can I write R1 like this then?

rule R1
{
  from
    c: AADL!ComponentInstance
  to
    implImg: AADL!ThreadImplementation
    (
      calls <- c.calls->collect(e| thisModule.resolveTemp(Sequence{c,e}, 'callImg'))
    )
}


I tried but I get an exception: Cannot resolve default trace target 'callImg' for [the_sender:ComponentInstance, the_call:SubprogramCall]. But I know that R3 matches on this sequence of elements...

Is there a mistake in my code? Or do I make a conceptual mistake? Or is it a feature not yet supported?

Thanks,
Etienne.

[Updated on: Fri, 10 May 2013 07:19]

Report message to a moderator

Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1058025 is a reply to message #1057956] Fri, 10 May 2013 13:45 Go to previous message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 165
Registered: September 2012
Senior Member

Op 10-05-13 08:06, EtienneB Mising name schreef:
> I tried but I get an exception: Cannot resolve default trace target 'callImg'
> for [the_sender:ComponentInstance, the_call:SubprogramCall]. But I know that
> R3 matches on this sequence of elements...

You cannot combine "mapsTo" and resolveTemp() on a Sequence of input elements.
Use either one or the other.


Cheers,
Dennis
Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1058029 is a reply to message #1057956] Fri, 10 May 2013 13:45 Go to previous message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 165
Registered: September 2012
Senior Member

Op 10-05-13 08:06, EtienneB Mising name schreef:
> I tried but I get an exception: Cannot resolve default trace target 'callImg'
> for [the_sender:ComponentInstance, the_call:SubprogramCall]. But I know that
> R3 matches on this sequence of elements...

You cannot combine "mapsTo" and resolveTemp() on a Sequence of input elements.
Use either one or the other.


Cheers,
Dennis
Previous Topic:ATL Transformation Order Problem
Next Topic:Running ATL Transformation in java application
Goto Forum:
  


Current Time: Tue Sep 30 11:54:56 GMT 2014

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

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