Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Uffe on December 03, 2007, 12:17:12 am

Title: Model Transformation: referencing new class
Post by: Uffe on December 03, 2007, 12:17:12 am
Hi everyone,


I'm trying to create a model transform which, for each package, creates a new class which all transformed classes in that package have an association to.

I can create a class in the Namespace transform, and the respective classes in the Class transform. In the Class transform, I can create the association... almost. What's missing is the reference to the class created in the Namespace transform.

I can't seem to get my head around how to get hold of that reference.
Basically, the structure looks like this:

Namespace
Code: [Select]
Package
{
 %TRANSFORM_CURRENT()%
 class
 {
   name="NewClass"
 }
%list "Class"%
}


Class
Code: [Select]
Class
{
%TRANSFORM_CURRENT()%
}
Association
{
Source
{
%TRANSFORM_REFERENCE()%
}
Target
{
  -- Here's where I need the GUID for "NewClass" created in Namespace.
}
}


Any good ideas?

Cheers,


/Uffe\
Title: Re: Model Transformation: referencing new class
Post by: Eve on December 03, 2007, 01:06:56 am
The following should do it.  Note that I've made the transform references in the class and association source explicit.

Namespace
Code: [Select]
Package
{
 %TRANSFORM_CURRENT()%
 class
 {
   name="NewClass"
   %TRANSFORM_REFERENCE("PackageClass", packageGUID)%
 }
%list "Class"%
}


Class
Code: [Select]
Class
{
%TRANSFORM_CURRENT()%

%TRANSFORM_REFERENCE("Class", classGUID)%
}
Association
{
Source
{
%TRANSFORM_REFERENCE("Class", classGUID)%
}
Target
{
   %TRANSFORM_REFERENCE("PackageClass", packageGUID)%
}
}
Title: Re: Model Transformation: referencing new class
Post by: Uffe on December 03, 2007, 03:13:04 pm
Like a charm. Thanks for that!

\Uffe/