Visual OCL

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

A converter to OCL for the Eclipse VOCL-Editor

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

A simple example conversion

We presume that you are familiar with the basics of Visual OCL as for example equivalent and attribute navigations or equations for circles and naturally with OCL itself.

If one would like to specify that every person’s wife is the mother of his child it could be expressed with this OCL constraint:

"context Person inv test: self.wife = self.child.mother"

In Visual OCL that constraint can be represented like this:

The context can be easily read out of the diagram. The equations and expressions are the tricky part. Let us follow the converter on its ways through the diagram. The ways already taken by the converter are marked red.

First, the start classifier role is being located:

Now the converter has to follow all possible navigations until their ends and remember each to compare the terminal classifier roles.

The converter chooses an arbitrary navigable association end role and stores the reached classifier role:

Now the converter knows the classifier role at the end of the navigation along “self.child”. As described above our converter uses a breadth first strategy. So it queues this navigation for further processing and follows the next and last navigable path from the start classifier role:

“self.wife” will not be queued because the converter notices that there are no navigable association end roles attached to this classifier role. Therefore the navigation stops at this point and could eventually be part of an equation if there will be found another path to this classifier role.

Now the converter knows both classifier roles at the ends of “self.child” and “self.wife”. Because they do not match there is nothing else to do but to continue traversing with the path “self.child” which is now in front of the queue:

Now the path “self.child.mother” has reached a not further navigable classifier role, too. The converter succeeds in checking the equality of the terminal classifier roles and builds up an OCL meta-model instance representing “self.wife = self.child.mother”.

The navigation queue is empty, so the traversing has completed and the converter finishes the OCL meta-model instance of “context Person inv test: self.wife = self.child.mother”:

The MOclConstraint object is the root node of the acyclic graph. The body consists only of a MOperationCallExp which refers to the Boolean operation “=” with two arguments. These arguments are two navigations with variables named “self”, both of type “Person”. The rest of this picture should be easy to understand.


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