Writing Transformations - Transforming Connectors


Creating connectors in a transformation can be complex, but it follows the same form as creating elements. The difference is that you also need to specify each end.

The different connectors that can be created are as follows.

  • Aggregation
  • Assembly
  • Association
  • Collaboration
  • ControlFlow
  • Connector
  • Delegate
  • Dependency
  • Deployment
  • ERLink
  • ForeignKey
  • Generalization
  • Instantiation
  • Interface
  • InteruptFlow
  • Manifest
  • Nesting
  • NoteLink
  • ObjectFlow
  • Package
  • Realisation
  • Sequence
  • StateFlow
  • Uses

Note: ForeignKey is a special case where not just a connector is created: you also need to list the columns involved in the transformation.

Connectors can be created between any two classes that have previously been created by a transformation (it does not need to be the same transformation). All you need to know is:

  • The original Class GUID.
  • The name of the transformation
  • The name of the transformed class.

The easiest example of this is when you have created multiple classes from a single class in a transformation and want a link between them. Consider this example from the EJB Entity transformation:

Dependency  
{  
%TRANSFORM_REFERENCE("EJBRealizeHome",classGUID)%  
stereotype="EJBRealizeHome"  
Source  
{  
%TRANSFORM_REFERENCE("EJBEntityBean",classGUID)%  
}  
Target  
{  
%TRANSFORM_REFERENCE("EJBHomeInterface",classGUID)%  
}  
}  

There are three uses of the TRANSFORM_REFERENCE macro, one to identify this connector for synchronisation purposes and the other two to identify the ends. All three use the same source GUID, because they all come from the one original class. None of the three need to specify the transformation because the two references are referencing something in the current transformation. Each of them then only needs to identify the transform name.

Of course it is also possible to create a connector from another connector.

You can create a connector template and list over all connectors connected to a class from the class level templates. You don't need to worry about only generating it once, as if you have created a TRANSFORM_REFERENCE for the connector then EA will automatically synchronise them. The following copies the source connector.

%connectorType%  
{  
%TRANSFORM_CURRENT()%  
%TRANSFORM_REFERENCE("Connector",connectorGUID)%  
Source  
{  
%TRANSFORM_REFERENCE("Class",connectorSourceGUID)%  
%TRANSFORM_CURRENT("Source")%  
}  
Target  
{  
%TRANSFORM_REFERENCE("Class",connectorDestGUID)%  
%TRANSFORM_CURRENT("Target")%  
}  
}