Book a Demo

Author Topic: Conditional Model Transformation  (Read 2287 times)

ralf_e

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Conditional Model Transformation
« on: November 03, 2006, 03:08:22 pm »
Hi.

I've tried to create model transformation templates to transform a platform independent model (PIM) into a platform specific one (PSM).

The PIM contains classes with some attributes tagged with a specific stereotype <<audited>>. If a class contains at least one of this attributes,  the PSM should consist of two classes (base and audit).

I had a look into the available transformation templates but had no idea how to decide if generation if audit class is required.

Any help ?

Is there any good introduction to the code template framework and model transformations of EA besides the online help documentation ?


thomaskilian

  • Guest
Re: Conditional Model Transformation
« Reply #1 on: November 04, 2006, 11:10:17 am »
At the time I started there wan't much. Not sure whether that has improved much?

Currently I'm using EXEC_ADDIN (not sure about the name since I'm currently just using and not programming it) in the transformation. So I actually don't use the transformatio but the COM interface. In contrast to these macro expanders, my way of doing it is more like programming. Using the native macro expansion only works in simple transforms (my opinion).

I posted something some time ago. Sorry, but I'm very busy at the moment  :-[

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Conditional Model Transformation
« Reply #2 on: November 05, 2006, 01:21:04 pm »
You can do something like the following.

Code: [Select]
Class
{
 %TRANSFORM_REFERENCE("Base")%
# Add the rest of what's required in the base class.
}
$list=%list="Attribute" @separator="\n" attStereotype=="audited"%
%if $list != ""%
Class
{
 %TRANSFORM_REFERENCE("Audit")%
# Add the rest of what's required in the audit class.
}
%endIf%

Oh, and regarding complex transformations.  My opinion is that it is much easier to do as much as possible in the transform templates.

The function name Thomas wanted was EXEC_ADD_IN, and examples of its use can be found by doing a forum search.