Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] how to keep reference to source Model in target model
[ATL] how to keep reference to source Model in target model [message #37903] Tue, 15 May 2007 13:44 Go to next message
Eclipse UserFriend
Originally posted by: sylvain.maillard.univ-nantes.fr

Hi all,

I have another question: in my generated eCore model I want to create
EAnnotation attached to EClass, that reference the source model.
I have added a called rule like:

rule createAnnotation(elem: mma!Element)
{
to a: MOF!EAnnotation (
source <- elem.eClass().name,
-- problem here: how to force the selection of element from source
model ???
references <- Sequence {elem}
)
do
{
a;
}
}

This work, but I get a reference to the generated Element, not the
source one. Is there a tips to avoid the automatic mapping from source
to target ?

Please help !

thanks
Sylvain

--
Sylvain
Re: [ATL] how to keep reference to source Model in target model [message #38028 is a reply to message #37903] Tue, 15 May 2007 15:22 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> I have another question: in my generated eCore model I want to create
> EAnnotation attached to EClass, that reference the source model.
> I have added a called rule like:
>
> rule createAnnotation(elem: mma!Element)
> {
> to a: MOF!EAnnotation (
> source <- elem.eClass().name,
> -- problem here: how to force the selection of element from
> source model ???
> references <- Sequence {elem}
> )
> do
> {
> a;
> }
> }

Why not simply create the EAnnotation as an additional target element of
the rule that creates the EClass?


> This work, but I get a reference to the generated Element, not the
> source one. Is there a tips to avoid the automatic mapping from source
> to target ?

This issue is discussed in [1] at the end of section 2.2.

In your case, this would look like:

do {
a.refSetValue('references', Sequence {elem});
}

You may use this "do" block in the rule that creates both the EClass and
the EAnnotation. If you still want to use a called rule, you will need
to add "a;" after the assignment.


Regards,

Frédéric Jouault

[1] Jouault, F : Loosely Coupled Traceability for ATL. In: Proceedings
of the European Conference on Model Driven Architecture (ECMDA) workshop
on traceability, Nuremberg, Germany.
http://www.sciences.univ-nantes.fr/lina/atl/bibliography/ECM DA_05
Re: [ATL] how to keep reference to source Model in target model [message #38092 is a reply to message #38028] Tue, 15 May 2007 16:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sylvain.maillard.univ-nantes.fr

Hi,
thanks for your reply,

I've tried this solution but no elements seems to be returned after
refSetValue. I have added a debug like this:
a.refSetValue('references', Sequence {elem}).debug('refers to: ');
but the result is always:

refers to: OUT!<unnamed>

I also tried to put the creation of annotation in the main rule but
I'have the same result.


> Hello,
>
> > I have another question: in my generated eCore model I want to create
> > EAnnotation attached to EClass, that reference the source model.
> > I have added a called rule like:
> >
> > rule createAnnotation(elem: mma!Element)
> > {
> > to a: MOF!EAnnotation (
> > source <- elem.eClass().name,
> > -- problem here: how to force the selection of element from
> > source model ???
> > references <- Sequence {elem}
> > )
> > do
> > {
> > a;
> > }
> > }
>
> Why not simply create the EAnnotation as an additional target element of the
> rule that creates the EClass?
>
>
> > This work, but I get a reference to the generated Element, not the
> > source one. Is there a tips to avoid the automatic mapping from source
> > to target ?
>
> This issue is discussed in [1] at the end of section 2.2.
>
> In your case, this would look like:
>
> do {
> a.refSetValue('references', Sequence {elem});
> }
>
> You may use this "do" block in the rule that creates both the EClass and the
> EAnnotation. If you still want to use a called rule, you will need to add
> "a;" after the assignment.
>
>
> Regards,
>
> Frédéric Jouault
>
> [1] Jouault, F : Loosely Coupled Traceability for ATL. In: Proceedings of the
> European Conference on Model Driven Architecture (ECMDA) workshop on
> traceability, Nuremberg, Germany.
> http://www.sciences.univ-nantes.fr/lina/atl/bibliography/ECM DA_05

--
Sylvain
Re: [ATL] how to keep reference to source Model in target model [message #38190 is a reply to message #38092] Tue, 15 May 2007 16:42 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> I've tried this solution but no elements seems to be returned after
> refSetValue. I have added a debug like this:
> a.refSetValue('references', Sequence {elem}).debug('refers to: ');
> but the result is always:
>
> refers to: OUT!<unnamed>
>
> I also tried to put the creation of annotation in the main rule but
> I'have the same result.

I forgot to tell you that you have to enable cross-model references in
the advanced tab of the launch config :-).


Best regards,

Frédéric Jouault
Re: [ATL] how to keep reference to source Model in target model [message #38455 is a reply to message #38190] Tue, 15 May 2007 17:38 Go to previous message
Eclipse UserFriend
Originally posted by: sylvain.maillard.univ-nantes.fr

> Hello,
>
> > I've tried this solution but no elements seems to be returned after
> > refSetValue. I have added a debug like this:
> > a.refSetValue('references', Sequence {elem}).debug('refers to: ');
> > but the result is always:
> >
> > refers to: OUT!<unnamed>
> >
> > I also tried to put the creation of annotation in the main rule but
> > I'have the same result.
>
> I forgot to tell you that you have to enable cross-model references in the
> advanced tab of the launch config :-).
>
It was a good advice ;-))
now It works..
thanks
Sylvain
>
> Best regards,
>
> Frédéric Jouault

--
Sylvain
Previous Topic:Re: [ATL] problems to reference remote rules
Next Topic:[ATL] how to find an already generated element in non-declarative rules ?
Goto Forum:
  


Current Time: Tue Jan 19 22:21:27 GMT 2021

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

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

Back to the top