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

Daniel Balasubramanian daniel at isis.vanderbilt.edu
Mon Jun 18 09:38:11 CDT 2012


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


More information about the great-users mailing list