Although OCL is a complex language, at its core is an elegant sublanguage of Relational Algebra, written in an OO syntax, with special names for right-semijoins (a.k.a. association traversals). This reduced language is Aocl, which can be implemented in pure Java 8.0. Given a textual specification of a class diagram, a tool generates the Aocl package for that class diagram to write metamodel constraints or to write model transformations. This example previews the Aocl toolset. A class diagram is given with its generated Aocl Java package, and with Java programs that illustrate/execute Aocl expressions. |
> set CLASSPATH=%CLASSPATH%;DIR\dist\MDELite9.1.jar;DIR\dist\Meta4.0.jarOn Macs, try:
> export CLASSPATH=$CLASSPATH:DIR\MDELite9.1.jar:DIR\Meta4.0.jar
Dir> java *.java
Please note: by doing the above, you have installed the binary version of Aocl.![]() |
|
> java M4.Meta4 alleg
or
> java M4.Meta4 alleg.cdspec.pl
The contents of directiory Allegory/Alleg will be generated. (I've already given it to you in this distribution, so you can skip this step. Note: the first letter of a package name is capitalized by Meta4). There is a Java class file for:Of course, you'll need a database (a relational database encoding of an object-diagram) on which you are to execute your queries. I've provided one x.alleg.pl (x is the name of the database whose schema is alleg.schema.pl).
> java DriverAll output is to Standard.out. A bash script to clean the directory is clean.script.