| Home » Archived » M2M (model-to-model transformation) » resolve duplicate elements of the target model
 Goto Forum:| 
| resolve duplicate elements of the target model [message #54906] | Thu, 26 July 2007 08:07  |  | 
| Eclipse User  |  |  |  |  | hi all, 
 ATL do not allow to navigate over the target model. But if i created
 multiple different  target elements (A1, .. ,Ai, .. An)from one source
 element (S), i need to set correct references to this elements, so how
 it can be done?
 When i define the reference with the type to the S then it is always
 transformed to one specific Ai. It is not possible to use
 resolveTemp()-method because all Ai are constructed using one target
 pattern. I thought to create my own tracing within the transformation,
 but perhaps there is "better" solution.
 
 thanks
 
 regars,
 Yury Kornev
 |  |  |  |  |  |  | 
| Re: [ATL] Re: resolve duplicate elements of the target model [message #55014 is a reply to message #54987] | Fri, 27 July 2007 06:17   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: y_kornev.gmail.com 
 hi,
 
 Quentin Glineur schrieb:
 > Please prefix you post subject with [ATL], thanks !
 sorry, next time i will be more carefully
 
 > I may have not understood everything but:
 > resolveTemp() is the function to use to get the reference to a
 > particular (i.e. not the first) target element when it has been created
 > by a multi-target rule.
 
 the question is how to get the reference to the one specific target
 element (that was created through the lazy rule or distinct-foreach)
 from the set of elements matched to one source element,e.g
 
 from ob : MOF!EClass
 to t1 : MOF!EClass(...)
 do {
 for (iterate in sequence) {
 Lazyrule(ob);
 }
 }
 Lazyrule{
 to t : MOF!EClass (...)
 
 }
 
 if i undestood right, ATL engine traces all target elements,  in this
 case it provides only one reference (to t1)
 but what happens to the elements initialized through the Lazyrule?
 
 regards,
 yury
 
 >
 > So, what do you mean by "constructed using one target pattern" ?
 > (I understand a rule whose target is defined as follows :
 >
 > to
 >     t1 : Persons!Man, t2 : Persons!Man, t3 : Persons!Man (
 >         fullName <- s.firstName + ' ' + s.family.lastName
 >     )
 > for wich only the last element will be initialised)
 >
 > HTH,
 >
 > Quentin GLINEUR
 >
 > kornev a écrit :
 >> hi all,
 >>
 >> ATL do not allow to navigate over the target model. But if i created
 >> multiple different  target elements (A1, .. ,Ai, .. An)from one source
 >> element (S), i need to set correct references to this elements, so how
 >> it can be done?
 >> When i define the reference with the type to the S then it is always
 >> transformed to one specific Ai. It is not possible to use
 >> resolveTemp()-method because all Ai are constructed using one target
 >> pattern. I thought to create my own tracing within the transformation,
 >> but perhaps there is "better" solution.
 >>
 >> thanks
 >>
 >> regars,
 >> Yury Kornev
 |  |  |  |  | 
| Re: [ATL] Re: resolve duplicate elements of the target model [message #55040 is a reply to message #55014] | Fri, 27 July 2007 06:55   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: matt.mcgill.gmail.com 
 Yury Kornev wrote:
 > hi,
 >
 > Quentin Glineur schrieb:
 >> Please prefix you post subject with [ATL], thanks !
 > sorry, next time i will be more carefully
 >
 >> I may have not understood everything but:
 >> resolveTemp() is the function to use to get the reference to a
 >> particular (i.e. not the first) target element when it has been
 >> created by a multi-target rule.
 >
 > the question is how to get the reference to the one specific target
 > element (that was created through the lazy rule or distinct-foreach)
 > from the set of elements matched to one source element,e.g
 >
 > from ob : MOF!EClass
 > to t1 : MOF!EClass(...)
 > do {
 >  for (iterate in sequence) {
 >     Lazyrule(ob);
 >  }
 > }
 > Lazyrule{
 >  to t : MOF!EClass (...)
 >
 > }
 >
 
 Are you sure you didn't meed Lazyrule(iterate)? Or did you really want
 to create |sequence| number of EClasses from ob?
 
 Anyway, you can do this by decorating the source model with the target
 elements you're creating, using a combination of helper and called rule.
 Like this: (using your example, creating many target elements from same
 source element)
 
 helper context MOF!EClass def:
 derived : Sequence(MOF!EClass) =
 self.sequence->collect(i |
 thisModule.CalledRule(self)
 );
 
 rule CalledRule(source : MOF!EClass) {
 to t : MOF!EClass (...)
 }
 
 Then any time you need to get any of the created objects, you can just
 access the derived collection.
 
 Did I understand your problem correctly?
 
 -Matt McGill
 
 > if i undestood right, ATL engine traces all target elements,  in this
 > case it provides only one reference (to t1)
 > but what happens to the elements initialized through the Lazyrule?
 >
 > regards,
 > yury
 >
 >>
 >> So, what do you mean by "constructed using one target pattern" ?
 >> (I understand a rule whose target is defined as follows :
 >>
 >> to
 >>     t1 : Persons!Man, t2 : Persons!Man, t3 : Persons!Man (
 >>         fullName <- s.firstName + ' ' + s.family.lastName       )
 >> for wich only the last element will be initialised)
 >>
 >> HTH,
 >>
 >> Quentin GLINEUR
 >>
 >> kornev a écrit :
 >>> hi all,
 >>>
 >>> ATL do not allow to navigate over the target model. But if i created
 >>> multiple different  target elements (A1, .. ,Ai, .. An)from one
 >>> source element (S), i need to set correct references to this
 >>> elements, so how it can be done?
 >>> When i define the reference with the type to the S then it is always
 >>> transformed to one specific Ai. It is not possible to use
 >>> resolveTemp()-method because all Ai are constructed using one target
 >>> pattern. I thought to create my own tracing within the
 >>> transformation, but perhaps there is "better" solution.
 >>>
 >>> thanks
 >>>
 >>> regars,
 >>> Yury Kornev
 |  |  |  |  | 
| Re: [ATL] Re: resolve duplicate elements of the target model [message #55317 is a reply to message #55040] | Mon, 30 July 2007 09:48  |  | 
| Eclipse User  |  |  |  |  | hi Matt, 
 i got your idea, thanks a lot
 
 regards
 yury kornev
 
 Matt McGill schrieb:
 > Yury Kornev wrote:
 >> hi,
 >>
 >> Quentin Glineur schrieb:
 >>> Please prefix you post subject with [ATL], thanks !
 >> sorry, next time i will be more carefully
 >>
 >>> I may have not understood everything but:
 >>> resolveTemp() is the function to use to get the reference to a
 >>> particular (i.e. not the first) target element when it has been
 >>> created by a multi-target rule.
 >>
 >> the question is how to get the reference to the one specific target
 >> element (that was created through the lazy rule or distinct-foreach)
 >> from the set of elements matched to one source element,e.g
 >>
 >> from ob : MOF!EClass
 >> to t1 : MOF!EClass(...)
 >> do {
 >>  for (iterate in sequence) {
 >>     Lazyrule(ob);
 >>  }
 >> }
 >> Lazyrule{
 >>  to t : MOF!EClass (...)
 >> }
 >>
 >
 > Are you sure you didn't meed Lazyrule(iterate)? Or did you really want
 > to create |sequence| number of EClasses from ob?
 >
 > Anyway, you can do this by decorating the source model with the target
 > elements you're creating, using a combination of helper and called rule.
 > Like this: (using your example, creating many target elements from same
 > source element)
 >
 > helper context MOF!EClass def:
 >   derived : Sequence(MOF!EClass) =
 >     self.sequence->collect(i |
 >       thisModule.CalledRule(self)
 >     );
 >
 > rule CalledRule(source : MOF!EClass) {
 >   to t : MOF!EClass (...)
 > }
 >
 > Then any time you need to get any of the created objects, you can just
 > access the derived collection.
 >
 > Did I understand your problem correctly?
 >
 > -Matt McGill
 >
 >> if i undestood right, ATL engine traces all target elements,  in this
 >> case it provides only one reference (to t1)
 >> but what happens to the elements initialized through the Lazyrule?
 >>
 >> regards,
 >> yury
 >>
 >>>
 >>> So, what do you mean by "constructed using one target pattern" ?
 >>> (I understand a rule whose target is defined as follows :
 >>>
 >>> to
 >>>     t1 : Persons!Man, t2 : Persons!Man, t3 : Persons!Man (
 >>>         fullName <- s.firstName + ' ' + s.family.lastName       )
 >>> for wich only the last element will be initialised)
 >>>
 >>> HTH,
 >>>
 >>> Quentin GLINEUR
 >>>
 >>> kornev a écrit :
 >>>> hi all,
 >>>>
 >>>> ATL do not allow to navigate over the target model. But if i created
 >>>> multiple different  target elements (A1, .. ,Ai, .. An)from one
 >>>> source element (S), i need to set correct references to this
 >>>> elements, so how it can be done?
 >>>> When i define the reference with the type to the S then it is always
 >>>> transformed to one specific Ai. It is not possible to use
 >>>> resolveTemp()-method because all Ai are constructed using one target
 >>>> pattern. I thought to create my own tracing within the
 >>>> transformation, but perhaps there is "better" solution.
 >>>>
 >>>> thanks
 >>>>
 >>>> regars,
 >>>> Yury Kornev
 |  |  |  | 
 
 
 Current Time: Thu Oct 30 22:16:26 EDT 2025 
 Powered by FUDForum . Page generated in 0.03688 seconds |