Visual OCL

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

User Guide for the Eclipse VOCL-Plugin
group 2

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

3.1 Creating a navigation expression


A navigation expression consists of one or more Classifiers (ClassifierRoles and SetClassifierRoles) which are connected by AssociationRoles.
Navigations start at objects (ClassifierRoles or SetClassifierRoles) , go along AssociationEnds (the end roles of AssociationRoles) and end at properties that can be an attribute, a associationend or a operation or mehtod that is a query. You are able to draw different kinds of VOCL diagrams with this editor that are explained below.
The navigation starts with the ClassifierRole that has same context as the underlying Constraint. If no name is given for the context the navigation starts with the ClassifierRole whose name is self and the type corresponds with context type of the Constraint.

Fig. 3.1.1 - Starting the converter in the menu

You can start the converter by selecting the menu entry Convert to OCL string in the Eclipse menu Visual OCL. If the VOCL expression can not be converted then a dialog with an empty message appear otherwise the OCL String corresponding to the VOCL expression is displayed.

In the user handbook you can several examples for navigation expression in appendix B.


In the next subsections several kinds of navigations are presented.

3.1.1 Attribute navigation

An attribute navigation ends at a ClassifierRole / SetClassifiier which has attributes. In the following example we only have one ClassifierRole c:Company with its attributes name:String = GMC and profitPerYear:Integer = x (see Fig. 3.1.2). The first attribute has a constant value and the other one has a variable which is bound to a Condition.
The starting point for the navigation is in that case the ClassifierRole because its rolename and roletype correspond to the context name and context type. It is always necessary to have such a start point.


Fig. 3.1.2 - attribute navigation

Now, the converter can be started. The head of the Constraint is overtaken to the OCL-String exactly. The variable being bound to one attribute is replaced by the operator and the right side of the  Condition.
If there are several attributes, they are connected by a logical "and".


Fig. 3.1.3 - OCL - String of attribute navigation example

3.1.2 Round trip

Another kind of navigations are round trips, that means that you can reach one target ClassifierRole from a source ClassifierRole via different targets. In the example in Fig. 3.1.4 you see the source ClassifierRole (c:Company) and the target ClassifierRole (manager:Person). You can reach the target ClassifierRole either via manager or via the ClassifierRole emp:Person.
In Fig. 3.1.5 you can see this fact also in the OCL-String. Furthermore the attribute navigation of the starting ClassifierRole are shown in the OCL-String.


Fig. 3.1.4- round trip navigation


Fig. 3.1.5- OCL-String of round trip navigation

3.1.3 A more complex example

In Fig. 3.1.6 you can see a more complex example. First the navigation starts with the ClassifierRole c:Company because the context of the Constraint is of the type Company and has as its name c. Then you can navigate to the SetClassifierRole Person via the AssociationRole with the end employee. The ClassifierRole Person has an attribute salary whose variable y is used in sum operation and the result of the this operation is assigned to a variable cost that is used in the condition. The other variable profit is a result of a method call in the ClassifierRole Company.
The resulting OCL-String can be seen in Fig. 3.1.7.



Fig. 3.1.6 - a complex example



Fig. 3.1.7 - OCL-String of the complex example
©2005 TFS