Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Create a children for an element
Create a children for an element [message #536040] Wed, 26 May 2010 18:23 Go to next message
ayoub is currently offline ayoubFriend
Messages: 25
Registered: March 2010
Junior Member
Hi all,
Help me please. I have 2 metamodel MMs and MMt, and I want make the following transformation:

1- MMt!father.name = MMs!objA.name
2- MMt!children = List of MMt!child where child.name = MMs!objB.name

* for the first transformation I use de following rule:
rule r1 {
from
s : MMs!objA
to
d : MMt!father(
name <- s.name
)
}

* for the second I don't know how can I do it !!!

my source metamodel MMs is like:
<objA name="1"> </objA>
<objB name="21"> </objB>
<objB name="22"> </objB>

my target metamodel MMt is like:
<father name="..">
<children>
<child name="..."> </child>
<child name="..."> </child>
.....
.....
</children>
</father>
Re: Create a children for an element [message #536075 is a reply to message #536040] Wed, 26 May 2010 21:32 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
hope this works, u forgot to include the child in rule1

guess

rule A{
from a : mms!ObjA

to b :mmt:father(
name <- a.name,
children <- a.ObjB
)
}


rule B{
from a: mms:ObjB
to b : mmt:child(

name <- a.name
)

}
Re: Create a children for an element [message #536143 is a reply to message #536075] Thu, 27 May 2010 08:57 Go to previous messageGo to next message
ayoub is currently offline ayoubFriend
Messages: 25
Registered: March 2010
Junior Member
Wafaa,
In rule A the ObjB does not exist on ObjA:
a.ObjB means mms!ObjA.ObjB but ObjB belongs to mms directly.
I tested the code and it is not work Crying or Very Sad
forgive my poor english
Re: Create a children for an element [message #536196 is a reply to message #536143] Thu, 27 May 2010 11:07 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
yes I c,

so u have to tell the transformation that children of father are objB,
i do not know how as i do not know ur metamodel

rule A{
from a : mms!ObjA

to b :mmt:father(
name <- a.name,
children <- objB.allInstancesFrom(MMs)
)
}

is it what u want!!

also some thing I learned u have to check spelling, because an error cause transformation to be wrong


we will wait for some one to reply

good luck ayoub

[Updated on: Thu, 27 May 2010 11:12]

Report message to a moderator

Re: Create a children for an element [message #536298 is a reply to message #536196] Thu, 27 May 2010 14:58 Go to previous message
ayoub is currently offline ayoubFriend
Messages: 25
Registered: March 2010
Junior Member
Hi,
Here is a code that I use but does not work.

helper context mms!ObjB def : getObj(): Set(mms!ObjB) =
self->select(p | p.type = 'Class');
--- ObjB has an attribute named type

rule mms2mmt {
from c : mms!ObjB
to out : mmt!father(
nam <- 'mon pere',
children <- cList
),
cList : distinct mmt!child foreach(p in c.getObj())(
name <- p.name
)
}


--previous message
Hi all,
Help me please. I have 2 metamodel MMs and MMt, and I want make the following transformation:

1- MMt!father.name = MMs!objA.name
2- MMt!children = List of MMt!child where child.name = MMs!objB.name

* for the first transformation I use de following rule:
rule r1 {
from
s : MMs!objA
to
d : MMt!father(
name <- s.name
)
}

* for the second I don't know how can I do it !!!

my source metamodel MMs is like:
<objA name="1"> </objA>
<objB name="21"> </objB>
<objB name="22"> </objB>

my target metamodel MMt is like:
<father name="..">
<children>
<child name="..."> </child>
<child name="..."> </child>
.....
.....
</children>
</father>
Previous Topic:counter
Next Topic:create UML association using ownedEnd, ownedMEmber
Goto Forum:
  


Current Time: Fri Apr 26 13:17:12 GMT 2024

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

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

Back to the top