Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] multiple references to an unique target model element
[ATL] multiple references to an unique target model element [message #2801] Tue, 26 December 2006 14:08 Go to next message
Eclipse UserFriend
Originally posted by: fsr.cin.ufpe.br

Hello,

Is it possible to make multiple references to an unique target pattern
element in an ATL matched rule?

For instance, in the following rule, I'd like to have the a_3 target
element as the respective 'att' elements contained as in the o_1 element
as in the o_2 element. However, in the generated target model, only the
o_2 element
contains an appropriate reference to the a_3 element, that, in turn, is
not contained it he o_1 element.

rule C2C{
from
i: SM!ClassA
to
o_1 : TM!ClassB
att <- a3;
name <- 'o_1'),
o_2 : TM!ClassB(
att <- a3;
name <- 'o_2')
a_3 : TM!ClassC(
value <- i.name)
}

Thanks in advance,
Franklin Ramalho.
Re: [ATL] multiple references to an unique target model element [message #2904 is a reply to message #2801] Wed, 27 December 2006 13:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cb.infocity.de

Hello Franklin,


"Franklin Ramalho" <fsr@cin.ufpe.br> schrieb im Newsbeitrag
news:5030f3a834822f0b0100059eddee86e7$1@www.eclipse.org...
> Hello,
>
> Is it possible to make multiple references to an unique target pattern
> element in an ATL matched rule?

I would say yes. But it depends on your metamodel.
In ClassB you got some att attribute. Is this att some reference which can
"save" ClassC ??
Is this reference set to [0..*] ??
Which means that att can save more than one reference of ClassC


> For instance, in the following rule, I'd like to have the a_3 target
> element as the respective 'att' elements contained as in the o_1 element
> as in the o_2 element. However, in the generated target model, only the
> o_2 element
> contains an appropriate reference to the a_3 element, that, in turn, is
> not contained it he o_1 element.
>
> rule C2C{
> from
> i: SM!ClassA
> to
> o_1 : TM!ClassB
> att <- a3;
> name <- 'o_1'),
> o_2 : TM!ClassB(
> att <- a3;
> name <- 'o_2')
> a_3 : TM!ClassC(
> value <- i.name)
> }
>
> Thanks in advance,
> Franklin Ramalho.
>

Regards
Camil
Re: [ATL] multiple references to an unique target model element [message #3065 is a reply to message #2904] Thu, 28 December 2006 18:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fsr.cin.ufpe.br

Hello Camil,

I only would like to generate 3 objects: o_1, o_2 and o_3, where the two
formers have a reference to the latter (att <- a3). However, this does not
work: only o_2 objects has been generated appropriately with
the correct reference to a3. The o_2 object is generated without such
reference.

However, if I do something like the rule below, both objects are generated
with a reference to the ClassC, but for this, as you can see in the rule,
I need to make use of two different instances of the ClassC meta-element.

//works
rule C2C{
from
i: SM!ClassA
to
o1 : TM!ClassB
att <- a3;
name <- 'o_1'),
o2 : TM!ClassB(
att <- a4;
name <- 'o_2')
a3 : TM!ClassC(
value <- i.name),
a4 : TM!ClassC(
value <- i.name)
}

// does not work
rule C2C{
from
i: SM!ClassA
to
o1 : TM!ClassB
att <- a3;
name <- 'o_1'),
o2 : TM!ClassB(
att <- a4;
name <- 'o_2')
a3 : TM!ClassC(
value <- i.name)
}

If anybody can help, I'd be grateful!:)
Regards,
Franklin.
Re: [ATL] multiple references to an unique target model element [message #4224 is a reply to message #3065] Fri, 29 December 2006 00:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cb.infocity.de

Hello Franklin,


"Franklin Ramalho" <fsr@cin.ufpe.br> schrieb im Newsbeitrag
news:b56e753dc7ddce2eb982c3d1aacefdc4$1@www.eclipse.org...
> Hello Camil,
>
> I only would like to generate 3 objects: o_1, o_2 and o_3, where the two
> formers have a reference to the latter (att <- a3). However, this does not
> work: only o_2 objects has been generated appropriately with
> the correct reference to a3. The o_2 object is generated without such
> reference.
>
> However, if I do something like the rule below, both objects are generated
> with a reference to the ClassC, but for this, as you can see in the rule,
> I need to make use of two different instances of the ClassC meta-element.
>
> //works
> rule C2C{
> from
> i: SM!ClassA
> to
> o1 : TM!ClassB
> att <- a3;
> name <- 'o_1'),
> o2 : TM!ClassB(
> att <- a4;
> name <- 'o_2'),
> a3 : TM!ClassC(
> value <- i.name),
> a4 : TM!ClassC(
> value <- i.name)
> }

for sure this works.:-)) because you have created two ClassC "Objects"
(instances) and you also have two "references" to every of them.
In java you would say:
Object ref1 = new ClassC;
Object ref2 = new ClassC;
so now ref1 can save "obejcts" of type ClassC and ref2 also can save
"objects" of type ClassC

OK
so what kind of "type" is 'att' able to save.?? if you say
att <- a3;
that means that att must be able to "store" objects of ClassC

OK now what i mean is that att must be set as some reference which can
"store" objects of ClassC
And that you need to specify in your metamodel TM

Imagine that a3 : TM!ClassC() is in some "other" rule. Then you need the
resolveTemp() function if you want to say
att <- a3;
this will not work then. Because the a3: TM!ClassC() is "somewhere" you need
to say ATL where he can find this "somewhere"
so you need to say atl the reference. :-))


hmmmm well have you copied this code out of your eclipse.??
Becaue there is some ',' missing.
But the atl-compiler must have seen this error also.??:-)) hmm
I mean after your o2: TM!ClassB(att <- a4; name <- 'o_2') there is no ','
I have added it right now to your posting. So please checkt it ;-)

Hmmmm well i guess att <- will get overwrite that's why you only can save
one reference.

maybe you can try something like that.

o1: TM!ClassB(
att <- a3;
name <- 'blabla'),

o2: TM!ClassB(
att <- a3 -> including(o1.att);
name <- 'blublub'),

.....

or try
att <- a3 -> union(o1.att);


But this only works if att can save "more" than one reference. And this you
must set in your metamodel
Thats what i think.;-))
Maybe someone else.?;-)


> // does not work
> rule C2C{
> from
> i: SM!ClassA
> to
> o1 : TM!ClassB
> att <- a3;
> name <- 'o_1'),
> o2 : TM!ClassB(
> att <- a4;
> name <- 'o_2'),
> a3 : TM!ClassC(
> value <- i.name)
> }
>
> If anybody can help, I'd be grateful!:)
> Regards,
> Franklin.
>

Regards
Camil
Re: [ATL] multiple references to an unique target model element [message #4736 is a reply to message #4224] Fri, 29 December 2006 14:34 Go to previous message
Eclipse UserFriend
Originally posted by: fsr.cin.ufpe.br

Hello Camil,

Firstly, thanks for your effort in understanding my problem and helping
me:)

In fact there was an error as you said (missing a comma), but I was only
trying to simplify my rule that is more complex than that I've posted
here. So, the error is provenient from the adaptation done directly at the
text editor:)

Unfortunately, yours suggestions do not solve my problem because att is a
mono-valued reference, i.e.,it cannot have more than one reference.

I just would like that the same target element (a3) could be used
as reference value in two others different target elements (o1, o2), as
shown below. However, as I said, only the last one (o2) is generated with
the referred value (a3) as contained element (a3 is absent
from the generated o1 element structure).

rule C2C{
from
i: SM!ClassA
to
o1 : TM!ClassB
att <- a3;
name <- 'o_1'),
o2 : TM!ClassB(
att <- a3;
name <- 'o_2'),
a3 : TM!ClassC(
value <- i.name)
}

On the other hand, when I use two different target elements as reference
value of att for o1 and o2, as shown in the rule below, these two objects
are generated apropriately. Note that a3 and a4 have the same content
(what takes me to try use only a single object a3 (as done in the above
rule) instead of these two different objects.

rule C2C{
from
i: SM!ClassA
to
o1 : TM!ClassB
att <- a3;
name <- 'o_1'),
o2 : TM!ClassB(
att <- a4;
name <- 'o_2'),
a3 : TM!ClassC(
value <- i.name),
a4 : TM!ClassC(
value <- i.name)
}

Regards,
Franklin.
Previous Topic:Getting value from a reference
Next Topic:[ATL] ERROR: cannot find ASMEMFModel for...
Goto Forum:
  


Current Time: Tue Mar 19 09:53:11 GMT 2024

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

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

Back to the top