Book a Demo

Author Topic: counters during code generation or transformation  (Read 2878 times)

GBeutler

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
counters during code generation or transformation
« on: February 21, 2008, 05:42:56 am »
Hi everybody,

I am generating a apache ojb mapping. In simple words this is a xml file which describe the mapping from at class to a database table.
At the xml file I need a attribute number which is the number of the position of the attribute at the table the attribute belongs to. It is only a counter like 1, 2, 3 etc.
Is there a way to get the position of an attribute at its table during transformation?
Thanks in advance and best regards,

Guido

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: counters during code generation or transformat
« Reply #1 on: February 21, 2008, 08:09:48 am »
The code templates don't have any counting capability.  The best suggestion I can make at the moment is to try using an addin call to get the attributes Pos value.

You can do this using EXEC_ADD_IN.  You can search for examples on this forum.  But I'll include another one here.

Example C#
Code: [Select]
public String AttPos(EA.Repository r, object args)
{
   Array p = (Array)args;
   String attGUID = (String)p.GetValue(0);
   EA.Attribute a = r.GetAttributeByGuid(attGUID);
   return a.Pos.ToString();
}

Example template
Code: [Select]
%EXEC_ADD_IN("MyAddinName", "AttPos", attGUID)%
Hope that helps.