Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL]Rule Transformation
[ATL]Rule Transformation [message #73232] Thu, 24 January 2008 14:35 Go to next message
Eclipse UserFriend
Originally posted by: adib58.yahoo.fr

Hello,

In my target Metamodel YY I have a class that corresponds to the Class
B this class contains an attribute "value" of String type, the problem
is I must put in the attribute "value" the value of references "a"
(references "a" were contains in class A in the source Meta Model)?

Here is an example:
Source Metamodel:
I have three class A, B, C:
* Class B contains "a" to refer Class A
* Class A contains "c" which refer Class C
* Class C contains two awarded "e" and "v"

Target Metamodel:
Class BB contains attribute "value"


Result:
I want to retrieve in "value", the reference "a" because i want to have
the value of "e" and "v" in my Target Model after transformation.


Basically, how to get the value of a reference to put in an attribute
String type?

How to write this transformation?
Re: [ATL]Rule Transformation [message #73336 is a reply to message #73232] Fri, 25 January 2008 14:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

This is a multi-part message in MIME format.
--------------080302070808080607040502
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit


Hi,

This first point is to be sure that you do not mix up different things.
In ATL, the navigation uses OCL. As a consequence, from the an object of
class B, when you follow the reference a, you get directly the objects a
(of class A) that are related to b by the given link. Therefore,
references cannot be handled. The string value of a reference is a
concept of the serialization (XMI). It is not accessible when model are
in memory.

What I suggest you (because it seems the nearest from your needs) is to
define a helper on the refered class.

helper context XX!A def toMyString() : String =
(define either an attribute which can act as a identifier or a function
returning a String that differs at each call)

Then in the ATL rule,

from ib: XX!B

to ob: YY!BB (
value <- ib.a->collect(e|e.toMyString())->sum
)


Hope this help

Quentin GLINEUR

SEGHAIER a
Re: [ATL]Rule Transformation [message #74129 is a reply to message #73336] Thu, 31 January 2008 22:54 Go to previous message
Eclipse UserFriend
Originally posted by: adib58.yahoo.fr

I have the same problem!!
I would simplify the exemple:

I have two metamodel MM1 and MM2:

In MM1 which represent the source metamodel: I have a class XX which
contain a reference "x"

In MM2 which represent the target metamodel: I have a class YY which
contain a String attribute "y"

I want to put "x" in "y" after transformation.

I create a helper:

helper context MM1!XX def : myString() : String =
if not self.oclIsUndefined() then
self.myString.x
else
''
endif ;

Then in the rule i wrote:
rule XX2YY{
from e : MM1!XX
to out : MM2!YY(
y<-e.myString()
)
}
Previous Topic:[ATL] Multiple metamodel for the model "OUT"
Next Topic:RE: Using ATL to validate models
Goto Forum:
  


Current Time: Sun Apr 11 01:57:12 GMT 2021

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

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

Back to the top