As a first step, start a new project in Together and create a class Person
with two attributes age (integer) and isMarried (boolean).
For creating some OCL constraints on this admittedly simplistic model process through the following steps:
Person on the diagram pane.
button and enter any legal constraint.
Constraints will be stored as Javadoc tags directly in the source code.
You can either instrument a single class or mark a number of classes for instrumentation first (using the 'for instrumentation' checkbox in the 'Properties' tab of the Inspector) and instrument several classes in one go. Here we will simply instrument the one class that we have created before.
Person on the diagram pane.ocl-together.jar that resides in
{TOGETHER-BASE-DIR}/modules/com/togethersoft/modules/dresden-ocl if you have
followed the step-by-step guide at installation
to your current project's class path ('Project' --> 'Project Properties' --> 'Search/Classpath' -->
'Add Path, Library or Archive').Now that you know in principle how to instrument classes with OCL constraints go ahead
and add a constructor for the Person class, create a main method and
construct a couple of Person instances, some of them adhering to, some of
them violating your OCL constraints. Then instrument the class, compile and run it.
Watch the console output for notifications about constraint violations.
Note: Please be aware that the integration of the Dresden OCL Toolkit into Together is prototypical. A major shortcoming in the usage of the Injector from within Together is that the injection process still needs some information that it gathers via reflection instead of purely from the model in Together. In effect, when you use types in your constraints that stem from the model you have created the injection will fail as the reflection engine will normally fail as 'your' model will not be in Together's classpath.
As a workaround you can alter Together's start script manually and add your project's output directory to the classpath. Also make sure you compile your project before using injection.
It is also possible, using the Toolkit and Together to generate SQL code from the UML/OCL model. This function is not explained in this example but mentioned, to ensure that you know the SQL code generation is possible.