Book a Demo

Author Topic: Add-In needed for use in transformation  (Read 4038 times)

gwieser

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Add-In needed for use in transformation
« on: May 09, 2007, 12:16:31 am »
hi,

we contacted EA support a few days ago to get some info on how to access information that is specific to the Database Model used in EA.

here's the mail we received:
Quote
Hello günther,

Unfortunately these properties are not exposed in the Code Template Framework (including the transformation templates).  You can still retrieve these values however by calling an Add-In with the EXEC_ADD_IN function.

For your reference, the following shows the common table 'column' fields and their equivalent field in the Automation Interface:

Attribute.IsOrdered        = Primary Key
Attribute.IsCollection     = Foreign Key
Attribute.AllowDuplicates  = Not Null
Attribute.IsStatic         = Unique
Attribute.Length           = Length
Attribute.Precision        = Precision
Attribute.Scale            = Scale

Additional information on authoring Add-Ins can be found in the EA Help file under the "Automation and Scripting" chapter, and additional code samples (including a basic C# Add-In) can be found on the following resources page:
http://www.sparxsystems.com.au/resources/developers/autint.html

For information on the method signature required for an EXEC_ADD_IN call, please see the following forum post:
http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=Automation;action=display;num=1153231946;start=6#6

Tagged Values can be accessed directly from the transformation templates:
http://www.sparxsystems.com.au/EAUserGuide/taggedvaluemacros.htm
Or if you prefer, you can also easily access tagged values from your Add-In by using the Attribute.TaggedValues collection.

I hope this helps.  If you have any further questions, please feel free to ask.

Best regards,

Aaron Bell
Sparx Systems Pty Ltd
[email protected]
http://www.sparxsystems.com.au
 

-----Original Message-----
From: Wieser Guenther AFD SD [mailto:[email protected]]
Sent: Wednesday, 2 May 2007 7:21 PM
To: sparxsupport
Subject: questions regarding model-to-model transformation

hi,

currently we're evaluatin EA for our planned MDSD projects (using openArchitectureWare). we started to use EA-internal model to model transformations, but now we're stuck when we try to convert our reverse engineered database model into a class model (that we afterwards can use with oAW). what we want to do inside the EA model-to-model-transformation is getting access to some specific attributes of a "column" wihtin a table class (as mentioned, reverese engineered by EA from an oracle db).

the following attributes of a column are of interest for us (expecting to use field substitution macros to access the values within the transformation code):
stereotype "column":
- primary key
- not null
- precision
- scale
- length

we want to put these values into a stereotype of the new attribute in the new class, or into tagged values.

the two questions are:
1.) how can we access the mentioned attributes of a column within model transformation code?
2.) how can we set a tagged value of an attribute within model transformation code?

thanks in advance for your help,
günther wieser


this was valueable information, but we're so far from coding C# or VisualBasic that we're more or less stuck and lost.

what we wonder is if anyone here ever built such an add-in to access these fields, or if anyone can offer us help with coding such an add-in? any help appreciated!

br,
günther

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Add-In needed for use in transformation
« Reply #1 on: May 09, 2007, 04:05:00 am »
Hi Gunther,

While I can't help with the Add-in, you should be careful with the supplied definitions.  Important information is often left out.

Primary Key ACTUALLY means Column in Primary Key.  If your key has only one column, then the terms are synonymous, but if not...

I suspect Foreign Key also means Column in a Foreign Key Constraint, but I haven't verified that yet. Also, it doesn't indicate which (of possibly many) Foreign Key Constraints the column is participating in - you'll have to get that via the «FK» operations.

Perhaps the Sparxians could confirm/deny both.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

gwieser

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Add-In needed for use in transformation
« Reply #2 on: May 09, 2007, 05:16:01 am »
hi paolo,

thanx for your hints! luckily we don't have FK with more than one column, and for PK we're already aware of that situation.

still hoping somebody's better in writing add-ins than we are.....

cheers,
g.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Add-In needed for use in transformation
« Reply #3 on: May 09, 2007, 01:48:27 pm »
There are example addins on the website, and given by users.  If you add the following to one of those you'll be able to call these functions from your templates.

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

public String AttForeignKey(EA.Repository r, object args)
{
   Array p = (Array)args;
   String attGUID = (String)p.GetValue(0);
   EA.Attribute a = r.GetAttributeByGuid(attGUID);
   return a.IsCollection.ToString();
}

public String AttNotNull(EA.Repository r, object args)
{
   Array p = (Array)args;
   String attGUID = (String)p.GetValue(0);
   EA.Attribute a = r.GetAttributeByGuid(attGUID);
   return a.AllowDuplicates.ToString();
}

public String AttUnique(EA.Repository r, object args)
{
   Array p = (Array)args;
   String attGUID = (String)p.GetValue(0);
   EA.Attribute a = r.GetAttributeByGuid(attGUID);
   return a.IsStatic.ToString();
}

public String AttLength(EA.Repository r, object args)
{
   Array p = (Array)args;
   String attGUID = (String)p.GetValue(0);
   EA.Attribute a = r.GetAttributeByGuid(attGUID);
   return a.Length.ToString();
}

public String AttPrecision(EA.Repository r, object args)
{
   Array p = (Array)args;
   String attGUID = (String)p.GetValue(0);
   EA.Attribute a = r.GetAttributeByGuid(attGUID);
   return a.Precision.ToString();
}

public String AttScale(EA.Repository r, object args)
{
   Array p = (Array)args;
   String attGUID = (String)p.GetValue(0);
   EA.Attribute a = r.GetAttributeByGuid(attGUID);
   return a.Scale.ToString();
}

Call these as follows.

Code: [Select]
%EXEC_ADD_IN("MyAddinName", "AttPrimaryKey", attGUID)%
%EXEC_ADD_IN("MyAddinName", "AttForeignKey", attGUID)%
%EXEC_ADD_IN("MyAddinName", "AttNotNull", attGUID)%
%EXEC_ADD_IN("MyAddinName", "AttUnique", attGUID)%
%EXEC_ADD_IN("MyAddinName", "AttLength", attGUID)%
%EXEC_ADD_IN("MyAddinName", "AttPrecision", attGUID)%
%EXEC_ADD_IN("MyAddinName", "AttScale", attGUID)%
where MyAddinName is the name of the registry key telling EA about your addin.

It's also worth noting that there are attAllowDuplicates and attStatic macros that you can use.

gwieser

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Add-In needed for use in transformation
« Reply #4 on: May 09, 2007, 10:53:56 pm »
hi simon,

thanks a lot for the code snippets, this helps us a lot!!! now we can bother the guys from the ms-related departments with helping us generating the dll. this is a good day!

ps: we already use attStatic and attAllowDuplicates, forunately we found that (by the way, attAllowDuplicates is called "attenableDuplicates" in the EA help, which I guess is wrong).

thanks again, cheers,
günther