Home » Archived » M2M (model-to-model transformation) » [ATL] how to find an already generated element in non-declarative rules ?
[ATL] how to find an already generated element in non-declarative rules ? [message #37805] |
Tue, 15 May 2007 04:46  |
Eclipse User |
|
|
|
Originally posted by: sylvain.maillard.univ-nantes.fr
Hi All,
I'm stuck with a simple (?) problem: I want to transform a model (MA)
that conforms to a home-made metamodel (MMA) into another model that
conforms to eCore.
In my MMA, I have an element that can be combined with itself (i.e.
Element has a collection of <Element> called 'elements').
I want to transform these elements into EClass, so I have a declarative
rule that takes a Element in its 'from' clause and produce a EClass in
its 'to' clause.
But now I want the collection 'elements' to become a EReference in the
target model.
Because there is no corresponding entity in my source model, I can not
create a declarative rule for this transformation.
So I have added a called rule that create the new EReference, but I
can't see how to find the target of my EReference, which must be an
already generated EClass...
I understand that ATL can find target elements from the input elements,
but I think this can work only for declarative rules ??
Please Help !
Thanks in advance,
Sylvain
--
Sylvain
|
|
|
Re: [ATL] how to find an already generated element in non-declarative rules ? [message #37935 is a reply to message #37805] |
Tue, 15 May 2007 09:58   |
Eclipse User |
|
|
|
Originally posted by: sylvain.maillard.univ-nantes.fr
Ok forget it,
In my called rule that create EReference, I'have added a parameter that
is the eType of eReference. As the rule is called from a declarative
rule, ATL is able to find the correct target element.
> Hi All,
>
> I'm stuck with a simple (?) problem: I want to transform a model (MA) that
> conforms to a home-made metamodel (MMA) into another model that conforms to
> eCore.
> In my MMA, I have an element that can be combined with itself (i.e. Element
> has a collection of <Element> called 'elements').
> I want to transform these elements into EClass, so I have a declarative rule
> that takes a Element in its 'from' clause and produce a EClass in its 'to'
> clause.
> But now I want the collection 'elements' to become a EReference in the target
> model.
> Because there is no corresponding entity in my source model, I can not create
> a declarative rule for this transformation.
> So I have added a called rule that create the new EReference, but I can't see
> how to find the target of my EReference, which must be an already generated
> EClass...
> I understand that ATL can find target elements from the input elements, but I
> think this can work only for declarative rules ??
>
> Please Help !
>
> Thanks in advance,
> Sylvain
--
Sylvain
|
|
| | | | |
Re: [ATL] how to find an already generated element in non-declarative rules ? [message #38157 is a reply to message #38125] |
Tue, 15 May 2007 12:30   |
Eclipse User |
|
|
|
Originally posted by: sylvain.maillard.univ-nantes.fr
Hi again,
> Hello Sylvain,
>
> >> rule elements {
> >> from
> >> -- you match a relation
> >> e1 : MMa!Element,
> >> e2 : MMA!Element (
> >> e1.elements->includes(e2)
> >> )
> >> to
> >> out_elm1 : ECore!EReference (
> >> -- you attach this element with its parent
> >> eContainer <- e1
> >
> > Unfortunately this doesn't work as eContainingClass from MOF is not
> > modifiable. It seems that a newly created EReference cannot be attached
> > to another EClassifier like that. I must explicitly add it to
> > eStructuralFeatures features of the EClass :-(
>
> Being able to navigate and set references in both directions is *very* useful
> in model transformation, especially when using a declarative style.
>
> Here is an excerpt of a slide on metamodeling hints that I give to students:
>
> * Define bidirectional associations (i.e., pairs of references)
> => Makes the model easier to navigate and populate
>
>
> It seems that Ecore was not designed by model transformation developers :-).
>
I agree with you on that point ;-)
>
> A quick and dirty (i.e., imperative) way to solve your problem would be to
> add an action block to rule "elements" to perform the setting in the opposite
> direction:
>
> do {
> e1.eStructuralFeatures <- out_elm1;
> }
well, I dont understand that: e1 refers to my input model, so it
doesn't have the eStructuralFeatures ! In order to do this I must get
the generated target eClass and I think it's bad ;-)
do
{
giveMeTheGeneratedEClassFor(e1).eStructuralFeatures <- out_elm1;
}
should solve my problem ;-)
>
>
> Best regards,
>
> Frédéric Jouault
--
Sylvain
|
|
| | | |
Re: [ATL] how to find an already generated element in non-declarative rules ? [message #38488 is a reply to message #38422] |
Tue, 15 May 2007 16:35  |
Eclipse User |
|
|
|
Hello,
> OK my mistake: the second parameter of resolveTemp should be set to the
> same name as the one specified in the rule used to create the parent
> element ! in my case it was 'class' rather than 'out_elm1'.
Well, the example was confusing because both rules used the same target
element name in Régis' original example (note that I do not blame him: I
would have done exactly the same thing ;-)).
> Thanks for your help Frédéric ;-)
You are welcome.
Best regards,
Frédéric Jouault
|
|
|
Goto Forum:
Current Time: Tue May 13 18:10:43 EDT 2025
Powered by FUDForum. Page generated in 0.10694 seconds
|