Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: g.makulik on May 17, 2012, 10:27:54 pm

Title: How to create connectors in transformation?
Post by: g.makulik on May 17, 2012, 10:27:54 pm
Hi,

What exact syntax is needed to create a connector in transformation IL?
I have written an AddIn that generates the transformation IL bypassing any transformation templates besides 'File', in this template I'm just calling my function from the AddIn using the %EXEC_ADDIN()% macro to generate the IL.
I'm going to transform a StateMachine to a corresponding class model. Here's a simple example:
(http://img849.imageshack.us/img849/7734/simplestatemachine.png)
The states should be transformed to corresponding classes (which works fine), the transition connector should be transformed to a Dependency between the transformed classes. Here is the transformation IL I'm generating for this:
Code: [Select]
Class
{
      name = "StateMachine"
      language = "C++"
}

Class
{
      name = "State1"
      language = "C++"
      XRef
      {
            source = "{3DC70348-DDA2-40fd-8C97-47FA5AAFF070}"
      }

}

Dependency
{
      source
      {
            XRef
            {
                  source = "{3DC70348-DDA2-40fd-8C97-47FA5AAFF070}"
            }

      }
      target
      {
            XRef
            {
                  source = "{FB4CF134-EBFD-412e-AE83-63EB2DB5E5DA}"
            }

      }
}

Class
{
      name = "State2"
      language = "C++"
      XRef
      {
            source = "{FB4CF134-EBFD-412e-AE83-63EB2DB5E5DA}"
      }

}

Dependency
{
      source
      {
            XRef
            {
                  source = "{3DC70348-DDA2-40fd-8C97-47FA5AAFF070}"
            }

      }
      target
      {
            XRef
            {
                  source = "{FB4CF134-EBFD-412e-AE83-63EB2DB5E5DA}"
            }

      }
}
But the Dependency connector isn't generated in the result  :( :
(http://img195.imageshack.us/img195/1615/simplestatemachinetrans.png)
What am I missing??

Edit:
BTW, specifying name and namespace properties in the XRef elements doesn't help.

Günther
Title: Re: How to create connectors in transformation?
Post by: Eve on May 18, 2012, 08:08:03 am
Well, if I was doing it in the templates I'd have

Class template
Code: [Select]
Class
{
TRANSFORM_REFERENCE("Class");
  name=%qt%%className%%qt%
  language="C++"
}
%list="Connector" @separator="\n"%

Connector template
Code: [Select]
Dependency
{
 %TRANSFORM_REFERENCE("Connector",connectorGUID)%
 Source
 {
   %TRANSFORM_REFERENCE("Class",connectorSourceGUID)%
 }
 Target
 {
   %TRANSFORM_REFERENCE("Class",connectorDestGUID)%
 }
}

Look at what that generates and see what you get.
Title: Re: How to create connectors in transformation?
Post by: g.makulik on May 18, 2012, 08:08:18 am
OK, think I found out myself. Seems that name and namespace properties in the XRef ARE relevant. Also added an XRef to the connector descriptions. Here's the IL code that works as I'm expecting (not sure if the connector direction property is really relevant somehow):
Code: [Select]
Class
{
      name = "StateMachine"
      language = "C++"
}

Class
{
      name = "State1"
      language = "C++"
      XRef
      {
            namespace = "C++STTCL"
            name = "State"
            source = "{3DC70348-DDA2-40fd-8C97-47FA5AAFF070}"
      }

}

Dependency
{
      direction = "Source -> Destination"
      XRef
      {
            namespace = "C++STTCL"
            name = "Connector"
            source = "{8E672976-9E34-4164-BA1D-19DB57986542}"
      }

      source
      {
            XRef
            {
                  namespace = "C++STTCL"
                  name = "State"
                  source = "{3DC70348-DDA2-40fd-8C97-47FA5AAFF070}"
            }

      }
      target
      {
            XRef
            {
                  namespace = "C++STTCL"
                  name = "State"
                  source = "{FB4CF134-EBFD-412e-AE83-63EB2DB5E5DA}"
            }

      }
}

Class
{
      name = "State2"
      language = "C++"
      XRef
      {
            namespace = "C++STTCL"
            name = "State"
            source = "{FB4CF134-EBFD-412e-AE83-63EB2DB5E5DA}"
      }

}

Dependency
{
      direction = "Source -> Destination"
      XRef
      {
            namespace = "C++STTCL"
            name = "Connector"
            source = "{8E672976-9E34-4164-BA1D-19DB57986542}"
      }

      source
      {
            XRef
            {
                  namespace = "C++STTCL"
                  name = "State"
                  source = "{3DC70348-DDA2-40fd-8C97-47FA5AAFF070}"
            }

      }
      target
      {
            XRef
            {
                  namespace = "C++STTCL"
                  name = "State"
                  source = "{FB4CF134-EBFD-412e-AE83-63EB2DB5E5DA}"
            }

      }
}

Thx to anyone who took the time reading this.

Günther
Title: Re: How to create connectors in transformation?
Post by: g.makulik on May 18, 2012, 08:15:36 am
Quote
Look at what that generates and see what you get.

Thanks for your answer Simon, seems we just posted at the same time.
Yes, that was more or less what I did. I've set up a simple example and used the C# standard transformation to inspect the IL output in detail.

WBR
Günther