[ATL] how to keep reference to source Model in target model [message #37903] |
Tue, 15 May 2007 13:44 |
Eclipse User |
|
|
|
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 |
Frédéric Jouault 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 |
Eclipse User |
|
|
|
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 #38455 is a reply to message #38190] |
Tue, 15 May 2007 17:38 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02069 seconds