Book a Demo

Author Topic: custom DDL transformation  question  (Read 2700 times)

Kaneda

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
custom DDL transformation  question
« on: July 27, 2005, 12:55:31 am »
Hey everyone,

in my PIM class diagramm I have a couple of classes with a "dataType" stereotype.

In the C# transformation, all of them will be created as structs.
But in the DDL transformation, some of them should end up as tables of their own, others as attributes in another table.
To be more concrete:

I have a class Firm and a class FirmDetails with stereotype datatype.
FirmDetails includes a long list of attributes (name, address etc).
Firm has an attribute firmDetails: FirmDetails.
I assigend a tagged value to the class FirmDetails which is call "include".

What I want to achieve is, that upon DDL transformation, the value is read, and the transformation does not create a separat table for FirmDetails, but puts all of its attributs as attributes of Firm. ( I don't see any point in having two tables for that in the DB, in the application code however its kinda useful to have all data "packed" in a struct).

Since I have tow more cases like this, I need a general template, which gets the tagged value of class A, and if it is "include", takes all the attributes of class A, and adds it as attributs to the target table of that class B, in which A is the type of an attribute.

I am not quite sure about this "add attributes of A to B-thing", so is this at all possible?

Thanks for any help!
« Last Edit: July 27, 2005, 05:39:57 am by Kaneda »
There are 10 types of people in this world. Those who understand binaries and those who don't...

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: custom DDL transformation  question
« Reply #1 on: July 27, 2005, 05:43:27 pm »
At the moment there's no way to get access to the tagged values and attributes/operations of a class at the other end of a connector.

So, currently it's not possible to do it in the way you want to do it.

However, you could start with a single class in your PIM, give the attributes a stereotype (or tagged value) to say that they belong in a different class.  So, your C# class templates splits a template into two different classes as necessary.  It would look something very vaguely like this. (I haven't thought everything through and have cut some stuff out)

Code: [Select]
%elemType%
{
 %TRANSFORM_REFERENCE("Class")%
 %TRANSFORM_CURRENT("language")%
 language="C#"
%list="Attribute" @separator="\n" @indent="  " attStereotype!="Detail"%
}

$detailAtts = %list="Attribute" @separator="\n" @indent="  " attStereotype=="Detail"%
%if $detailAtts != ""%
%elemType%
{
 %TRANSFORM_REFERENCE("ClassDetail")%
 %TRANSFORM_CURRENT("language","name","stereotype")%
 language="C#"
 stereotype="struct"
 name=%qt%%className%Detail%qt%
$detailAtts
}
%endIf%

Hope it helps.

Simon

Kaneda

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: custom DDL transformation  question
« Reply #2 on: July 28, 2005, 12:19:16 am »
So you mean, instead of creating a class "Firm" and "FirmDetails", and place a stereotype or tag on all attributes, that *should* be in FirmDetails.

From there on, I can alter the DDl transformation and the C# transformation to extract two classes out of this one.

Well, sounds like an option. Though this way is not exactly perfect for keeping the PIM as platform independent and easily readable as possible. However, if its the only way ...

thanks for the hint!
There are 10 types of people in this world. Those who understand binaries and those who don't...