Connectors

Return to Introduction  Previous page  Next page

Creating connectors in a transformation can be complex, but the process has the same form as creating elements.  The difference is that you must also specify each end.

The different connectors that can be created are as follows.

·Aggregation
·Assembly
·Association
·Collaboration
·ControlFlow
·Connector
·Delegate
·Dependency
·Deployment
·ForeignKey
·Generalization
·Instantiation
·Interface
·InterruptFlow
·Manifest
·Nesting
·NoteLink
·ObjectFlow
·Package
·Realisation
·Sequence
·Transition
·Uses

Note: ForeignKey is a special case where not just a connector is created; you must also list the columns involved in the transformation. In addition, tags specified on the connector are actually created on the foreign key operation in the source class, and a cascade property can be added; for example, cascade="update","delete".

There are two different types of class that you can use as a connector end: one created by a transformation, and one for which you already know the GUID.

Connecting to a class created by a transformation

The most common connection is to connect to a class created by a transformation.  To do this you must have three items of information:

· The original class GUID. 
· The name of the transformation.
· The name of the transformed class.

This type of link is created using the TRANSFORM_REFERENCE function macro.  When the element is in the current transformation, it can be safely omitted from the transformation. The simplest 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 synchronization 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 have to specify the transformation because the two references are referencing something in the current transformation. Each of them then only has 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 have to worry about only generating it once, because if you have created a TRANSFORM_REFERENCE for the connector then Enterprise Architect automatically synchronizes 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")%

}

}

Connecting to a class for which you know the GUID

The second type of class that you can use as a connector end is one for which you know the current GUID.  To do this, specify the GUID of the target class in either the Source or Target end.  The following example creates a dependency from a class created in a transformation, to the class it was transformed from.

Dependency

{

  %TRANSFORM_REFERENCE("SourceDependency",classGUID)%

  stereotype="transformedFrom"

  Source

  {

    %TRANSFORM_REFERENCE("Class",classGUID)%

  }

  Target

  {

    GUID=%qt%%classGUID%%qt%

  }

}