To create the First End Of Association operation for coloring Associations between a Block and a Use Case

  1. Create an Opaque Behavior named 'First End Of Association'.
  2. Right-click the Opaque Behavior element and open its Specification window. Do one of the following:
    1. Click the plus sign next to the Owned Parameter property to edit it.

      If you cannot see the Owned Parameter property, make sure the Expert mode is enabled.

    2. On the left side menu, select Parameters > Create.
  3. In the Specification of Parameter window, set Name to AssociationType to Association, and Direction to in. Click Back.
  4. In the Opaque Behavior Specification window, click three dots  next to the Body and Language property to edit it.
  5. In the Body and Language dialog, select Language > StructuredExpression.
  6. Click Create operation > Script.

  7. Set the Operation Name to ‘First End’.
  8. From the Language drop-down list, select Javascript Rhino.
  9. Insert the following script as the Body:

    Javascript Rhino
    arg1.size() > 0 ? arg1.iterator().next() : null

  10. Select First End > arg1 > Reset.
  11. Select First End > arg1 > Metachain Navigation.
  12. Click Insert.
  13. Under Metaclass or Stereotype, select Association, and under Property, select End Type.
  14. Click OK.

Sample model

The model used in these examples is the Case Studies for Querying the Model sample model. To open this model, you need to download case studies for querying the model.mdzip