[great-users] How to model: no. of created objects dependsonsrcmodel-attribute

Simon Görke simon.goerke at ils.uni-stuttgart.de
Tue Jun 19 03:00:08 CDT 2012


Daniel,

Thanks for the hint, this solves my issue here. 
The only disadvantage is that objects generated within the AttributeMapping
cannot be passed to the next rule.
Anyway this is not necessary in my case (it is the final rule) - thanks.

Simon

> -----Original Message-----
> From: great-users-bounces at list.isis.vanderbilt.edu 
> [mailto:great-users-bounces at list.isis.vanderbilt.edu] On 
> Behalf Of Daniel Balasubramanian
> Sent: Monday, June 18, 2012 4:38 PM
> To: great-users
> Subject: Re: [great-users] How to model: no. of created 
> objects dependsonsrcmodel-attribute
> 
> Hi Simon,
> 
> > Question is: is there a more direct solution to this?
> 
> Yes.  You can insert an "AttributeMapping" element and use 
> the generated UDM API directly inside this element.  It would 
> look something like this:
> 
> 
> int count = A.count();
> for (int i = 0; i < count; i++)
>   B b = B.Create(bParentObject);
> // bParentObject now contains count number of B objects
> 
> 
> HTH,
> Daniel
> 
> -----Original Message-----
> From: great-users-bounces at list.isis.vanderbilt.edu 
> [mailto:great-users-bounces at list.isis.vanderbilt.edu] On 
> Behalf Of Simon Görke
> Sent: Monday, June 18, 2012 6:41 AM
> To: great-users
> Subject: [great-users] How to model: no. of created objects 
> depends onsrcmodel-attribute
> 
> Hi there,
> 
> I intend to realize the following GREAT transformation:
> - the source model contains a number of objects (GME atoms) 
> of type A with an integer-type attribute "count"
> - the number of objects (type B atoms) to be instantiated in 
> the destination model depends on the number of a-type objects 
> (no problem), but (problem) also on the value of the 
> "count"-attribute:
> 
> Considering one of the a-type objects found in the source 
> model, this means
> (a.count==1):  instantiate   1 type-B atom
> (a.count==2):  instantiate   2 type-B atoms
>                .
>                .
>                .
> (a.count==x):  instantiate   x type-B atoms
> 
> 
> Being a GREAT-newbie, I am not sure how to model this kind of 
> transformation. One idea might be recursion using an 
> ExpressionRef-rule and a (temporary) counter object in the 
> "Global Container".
> Question is: is there a more direct solution to this? I guess 
> this class of problem (attribute does not restrict the search 
> pattern but induces multiple (variable number of) 
> instantiations) is not restricted to my task.
> 
> Regards
> Simon
> 
> _______________________________________________
> great-users mailing list
> great-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/great-users
> _______________________________________________
> great-users mailing list
> great-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/great-users
> 



More information about the great-users mailing list