Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Simple way to copy refrences?
[ATL] Simple way to copy refrences? [message #74020] Wed, 30 January 2008 18:57 Go to next message
Eclipse UserFriend
Originally posted by: m_lehmeier.gmx.de

I have a number of classes in an ecore model. One class has several
references to its sibling classes.

The ATL transformation I intend copies the features of the model to
another without many changes. For the sake of testing the target
metamodel is identical to the soure metamodel.

I have no trouble at all copying all attributes. Even sets of
attributes. But I have no idea how to copy references. Meaning the
target model should have the same references pointing to the same
classes than the original.

It seems that either I have to recreate them on the target side, which
I also don't know how to do, or get rid of references altogether, and
use custom made ids instead. But that would make manual modeling in
Eclipse very difficult.

A minor other problem I have is that I wonder if attributes of
superclasses can be copied automatically. It seems to me that I have to
include their transition into every child.
I tried refining, but don't have any successes yet.


Here is the km3 file of both the source and target model:

package ClassContainerPackage {

class Environment {
reference allClasses [*] container : Object oppositeOf environment;
}

abstract class Object {
attribute id: String;
reference environment [0-1] : Environment oppositeOf allClasses;
}

class Book extends Object {
attribute title: String;
attribute authors [0-*] : String;
reference pages [*] ordered : Page;
}

class Page extends Object {
attribute number: Integer;
attribute content: String;
}

}

package PrimitiveTypes {
datatype String;
}


This is my first try at an ATL file:

module ExampleModule;
create OUT : OutMM refining IN : InMM;

rule Environment {
from
ki : InMM!Environment
to
ko : OutMM!Environment (
allClasses <- ki.allClasses
)
}

rule Object {
from
ki : InMM!Object
to
ko : OutMM!Object (
id <- ki.id,
environment <- ki.environment
)
}


rule Book {
from
ki : InMM!Book
to
ko : OutMM!Book (
title <- ki.title,
authors <- ki.authors,
pages <- ki.pages
)
}

rule Page {
from
ki : InMM!Page
to
ko : OutMM!Page (
number <- ki.number,
content <- ki.content
)
}


What I would have expected is:
- The id from every "Object" should be transfered. It isn't. I guess
because the Object class only exists in the metamodel and not in the
actual model.
- The id from every "Object" should be transfered because of the
"refining" keyword in the header. It isn't although every child object
of "Object" has an id string in the model.
I have no idea why.
BTW, the ATL User Manual says the keyword is "refines", but Eclipse
only accepts "refining". I found that out by trying.
- I would like that all "pages" references in the target model should
still point to the according pages there.
But the simple way I used doesn't work and I have no idea how to make
it work. That's my biggest question right now.

All examples I have found so far seem to be for containment references,
which are not an option here. (only in that oversimplified example)

If this problem is addressed in the User Manual I haven't found it yet.

--
Lehmeier Michael (Nightshade Dragon UDIC)

8:00 - 12:00 : Frohlocken!
12:00 - 20:00 : Hosianna singen!
Re: [ATL] Simple way to copy refrences? [message #74040 is a reply to message #74020] Wed, 30 January 2008 21:56 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello.

Search this group for "thisModule.resolveTemp". That is used for creating
refrence for me.

Wong
Re: [ATL] Simple way to copy refrences? [message #74437 is a reply to message #74020] Tue, 05 February 2008 16:06 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

Because the Object class is abstract, the Object rule is either
superfluous (1) or should also be abstract (2).

Either you duplicate initialization bindings in all rules (e.g., id
<-... in Book and Page), which corresponds to (1); or you use rule
inheritance (then you can have an abstract Object rule like in (2)).


Regards,

Frédéric Jouault


Michael Lehmeier wrote:
> I have a number of classes in an ecore model. One class has several
> references to its sibling classes.
>
> The ATL transformation I intend copies the features of the model to
> another without many changes. For the sake of testing the target
> metamodel is identical to the soure metamodel.
>
> I have no trouble at all copying all attributes. Even sets of
> attributes. But I have no idea how to copy references. Meaning the
> target model should have the same references pointing to the same
> classes than the original.
>
> It seems that either I have to recreate them on the target side, which
> I also don't know how to do, or get rid of references altogether, and
> use custom made ids instead. But that would make manual modeling in
> Eclipse very difficult.
>
> A minor other problem I have is that I wonder if attributes of
> superclasses can be copied automatically. It seems to me that I have to
> include their transition into every child.
> I tried refining, but don't have any successes yet.
>
>
> Here is the km3 file of both the source and target model:
>
> package ClassContainerPackage {
>
> class Environment {
> reference allClasses [*] container : Object oppositeOf environment;
> }
>
> abstract class Object {
> attribute id: String;
> reference environment [0-1] : Environment oppositeOf allClasses;
> }
>
> class Book extends Object {
> attribute title: String;
> attribute authors [0-*] : String;
> reference pages [*] ordered : Page;
> }
>
> class Page extends Object {
> attribute number: Integer;
> attribute content: String;
> }
>
> }
>
> package PrimitiveTypes {
> datatype String;
> }
>
>
> This is my first try at an ATL file:
>
> module ExampleModule;
> create OUT : OutMM refining IN : InMM;
>
> rule Environment {
> from
> ki : InMM!Environment
> to
> ko : OutMM!Environment (
> allClasses <- ki.allClasses
> )
> }
>
> rule Object {
> from
> ki : InMM!Object
> to
> ko : OutMM!Object (
> id <- ki.id,
> environment <- ki.environment
> )
> }
>
>
> rule Book {
> from
> ki : InMM!Book
> to
> ko : OutMM!Book (
> title <- ki.title,
> authors <- ki.authors,
> pages <- ki.pages
> )
> }
>
> rule Page {
> from
> ki : InMM!Page
> to
> ko : OutMM!Page (
> number <- ki.number,
> content <- ki.content
> )
> }
>
>
> What I would have expected is:
> - The id from every "Object" should be transfered. It isn't. I guess
> because the Object class only exists in the metamodel and not in the
> actual model.
> - The id from every "Object" should be transfered because of the
> "refining" keyword in the header. It isn't although every child object
> of "Object" has an id string in the model.
> I have no idea why.
> BTW, the ATL User Manual says the keyword is "refines", but Eclipse
> only accepts "refining". I found that out by trying.
> - I would like that all "pages" references in the target model should
> still point to the according pages there.
> But the simple way I used doesn't work and I have no idea how to make
> it work. That's my biggest question right now.
>
> All examples I have found so far seem to be for containment references,
> which are not an option here. (only in that oversimplified example)
>
> If this problem is addressed in the User Manual I haven't found it yet.
>
Previous Topic:[ATL] can i defined a transformation without specifiy explicitly the number of input models
Next Topic:Modeling Map<>
Goto Forum:
  


Current Time: Sat Apr 10 15:31:31 GMT 2021

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

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

Back to the top