Visual OCL

TU-Berlin | Faculty IV | Institute ISTI | Research group TFS

User Guide for the Eclipse VOCL-Plugin
goup 1

small logo
section: < previous | next >
| |
chapter: << previous | next >>



3.5 Associations

This chapter discusses, how to create associations between classifiers of arbitrary type. They are, together with classifiers, the main building blocks used to define constraints. Associations are used to navigate from one classifier to another, whereas only one navigatable direction can be specified. Connecting classifiers in this way is the main task when creating navigation expressions, which are discussed in a later chapter. These expressions then form the basis for those, which combine existing ones to more complex expressions.

a) Creating an association

If an association should be created, at least one classifier (normal or set classifier) has to be in place. Although connecting a classifier with itself makes no real sense, it is possible to do so (it makes no sense for an object to have a reference on itself too, but it should be possible). To connect two classifiers with an association, follow these steps:
  1. First make sure, the two classifiers, which should be connected via an association, exist. In this example, there is a classifier called Company, and another one called Employee. The associaton between them should navigate from the Company to the Employee and will be called is_employed_in (see fig. 3.5.1 for the classifiers).
  2. Select the Association Role-Button, and click on one of the classifiers, e.g. the Company-classifier. Note, that the mouse cursor is displayed with a plug and a disabled icon, which will disappear, when the mouse is located over a classifier.
  3. Now move the mouse-cursor to the other classifier. Depending on its position, the editor chooses one of the available connection points, the figure provides. Moving the mouse-cursor around the figure will change the used connection point (also called anchor point).
  4. To add the association, click the mouse-button, when a desired anchor-point is selected. Then a dialog appears (fig. 3.5.2), in which the navigation direction is set and the association end is named.
  5. The dialog is splitted into two parts. The left refers to the classifier first selected, the right to the other one (source and target of the association). In order to define the navigation direction, enable the radio-button of the classifier, which should be reachable from the other one. For example, when the association should be navigatable from the Company to the Employee, then activate the button on the Employee-side.
  6. Now, enter the name for the associations end on that side, which is navigatable, here on the employee side. The associations end is named is_employed_in. See fig. 3.5.2 for used settings.
  7. Click the enter-Button to close the dialog.
The new association drawn consists of a connecting line and a string for the associations end name. The line is layouted in manhatten-style, always following orthogonal directions. The name is located near the connection point of the navigatable classifier. This position may not be very good. Therefor it can be moved as usual to any position on the constraint. See fig 3.5.3 for the resulting figures.

Fig. 3.5.1 - Two classifiers without association


Fig. 3.5.2 - Dialog in which the association is specified


Fig. 3.5.3 - Constraint after layouting

b) Reconnecting Associations to other anchor points

When developing an expression incrementally, the layout of the figures may change. Therefor, the associations connection points may be altered after creation. To do this, select the association. Note, that the associations ends become highlighted by black points. Moving the mouse-cursor over one of them, will cause it to change its appearance to a cross. Now, the associations end can be dragged by keeping the mouse-button pressed, to another anchor-point. Releasing the mouse-button at the desired position will update the figure. See fig. 3.5.4 for another layout after reconnecting the association.

Fig. 3.5.4 - Constraint after layouting

c) Hints working with associations

Associations are quite simple to edit, but some aspects should be mentioned, which will help to reduce confusions when creating expressions.
  • First of all, be careful when deleting a classifier, which is connected with associations. These will also be deleted, because associations have to be connected on both sides to classifiers. Deleting an association brings no risk.
  • If a classifier has a method,, the anchor points for connecting associations on the top of the figure are no longer usable. Avoid connecting associations at the top when you already know, that the corresponding classifier is extended to have a method.
  • The name of the associations end is, up to now, not alterable after creation, as is the navgation direction (there does not exist a property dialog, which is reachable via the context - menu). After all, creation of an association goes quite fast, so that not much time is spend by deleting and recreating an association.

  section: < previous | next >
| |
chapter: << previous | next >>
©2005 TFS