Author Topic: How to create connectors in transformation?  (Read 3446 times)

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
How to create connectors in transformation?
« 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:

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  :( :

What am I missing??

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

Günther
« Last Edit: May 17, 2012, 10:34:21 pm by g.makulik »
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: How to create connectors in transformation?
« Reply #1 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.

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: How to create connectors in transformation?
« Reply #2 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
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: How to create connectors in transformation?
« Reply #3 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
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/