Skip to content

Transformation OWL UML Java

Carsten Stocklöw edited this page Mar 24, 2017 · 6 revisions

Table of Contents

Role and benefits of this tool

The role of the Model Transformation Tool is to be a common component for all model transformations in AAL Studio. Currently only one transformation is available on UML files, namely the Ontology to Java transformation

The purpose of this AAL Studio tool is to make it easy to generate implementation resources (such as Java source code) from models created in UML or EMF, and to give a good integration with the Eclipse development work.

Currently, the primary example of this the transformation that generates full Java source code and Maven POM files from UML ontology models created using the Ontology Project Wizard and modelled using our Ontology Modelling approach.

The main benefit of using this tool is that it automates (part of) the implementation work. The alternative for the user would usually be to hand-code the implementation based on the model or some equivalent design. The modelling and transformation approach also have the benefit that maintenance is simplified. E.g., if there are changes in the target platform (e.g. the Java representation of the ontologies), then correct code can quickly be re-generated once the transformation have been updated.

Overview of functionality

The model transformation tool makes its functionality available through menus in the AAL Studio.

When a transformation have been selected from a menu, it will start working in the background. Feedback from the transformation will be output to the console view of Eclipse, including any error messages and warnings. When the transformation has completed, the generated code (or other artefacts) will appear in the output folders (see preferences below for how to change the default).

Please note that the transformation in general will overwrite (without warning) any classes that already exist in the output folders. Therefore, it is recommended that any errors are corrected in the source model (instead of the generated code or artefact) so that the corrections will be present in the code each time you run the generation.

Transformation UML to Java

Currently, the only transformation available is for generating Java code from an UML ontology ontology model. To perform this transformation, select the .uml file of the UML model in the Eclipse "Package Explorer", and select "Transform UML ontology to Java" from the AAL Studio menu.

The default output location for Java files from this transformation is the src/main/java folder. Also, the pom.xml file of the project will be updated in the transformation.

The transformation will generate the following files in a Java package named after the UML package name:

  • Activator.java
  • Factory.java, where is the name of your ontology
In the .owl sub-package of the same package:
  • Ontology.java, where is the name of your ontology
  • 0..X .java classes, where is a class or enumeration in your model
For further description of the purpose and structure of the ontology classes, see the ontology documentation in the Developer Handbook.

Transformation Java to OWL

There is also a basic support to transform an existing Java ontology to an RDF/OWL file. Since the middleware itself already support the transformation from Java to Turtle serialized Strings this can be easily done. Therefore we need to load the ontology, using the Turtle-Serializer to get a valid String representing the ontology and transform this String to the RDF/OWL syntax by using the freely available OWL API (owlapi.sourceforge.net). Following to this idea the Model Transformation Tool is able to create a class containing a main-method that exactly doing all of this for you. All you need to do is to execute the main-method. For this there is also an entry in the AAL Suite Eclipse menu, but this is doing nothing more then to create and run a configuration to start the main-method of the created class (if there is someone).
If you are using the Ontology Project Wizard you need to make sure that the check-button like shown below is selected:

Then after performing a transformation from UML to Java there will be also a class available called like "Creator.java" in the "creator" package of your ontology root. The needed OWL API library is already included in the project using a Maven-Dependency. So all you need to do is to execute the main of the Creator.java and an according file will be created in the root of the project.

Transformation OWL to UML

This AAL Studio tool is intended to simplify the usage of ontologies while developing uAAL services, applications and/or platform components. The tool offers the ability to transform any OWL ontology file in RDF/XML format into UML2 file (without the UML graphical representation part). The supported format and the expected output is compatible with Protege 3.x that uses the Protege OWL-API (Stanford). The generated UML file describes clearly the existing associations between Classes – Subclasses while the object and data properties may contain the range of values (Enumerations). In addition, some extra universAAL information such as types of Classes, useful comments and versions, regarding the ontologies, are added to the generated UML file. The main benefit of this transformation would be a better realization and representation of the ontologies structure -by the developers- while offering them options such as editing and/or extending them; according to one’s needs (requirements).

The OWL2UML Transformation Tool transforms any OWL file using the Jena-API for parsing, into UML file format. To perform this transformation, select any OWL file in the workspace (most likely a file of a project that contains OWL models) in the Eclipse "Package Explorer", right-click on it and select the "Transform2UML" option (NOTICE: Right-click only on OWL files to make this option visible) from the pop-up menu.

The default output location of the generated UML files of this transformation is the same folder of the selected OWL file. In the "Console" View, the user/developer can find a detailed representation of the parsing process and the creation of the new model containing all the required properties. Additionally, the user is required to define specific universAAL properties and some extra information , such as Class types, helpful comments and ontology versions to be added to the output file by completing an XML file which follows a predefined schema. NOTICE: The XML file should be contained under the same folder and use the same name with the OWL file that will be transformed in order be recognized by the parser of the tool.

Before the transformation takes place, an XML validator checks the provided XML file against the defined XSD Schema and proceeds to the transformation, including the additional information of the XML file. The XSD Schema can be found here. Additionally, samples of OWL and XML files for tests and/or understanding the structure of the files as well as how this tool actually works, are available here.

The generated UML file can be opened (or edited) by the Eclipse in order all the necessary Classes, Associations, Properties, Enumerations etc. as well as all the universAAL ontology properties to be visible. Moreover, a more detailed view of the UML defined properties is visible by clicking on any property in the UML file and selecting the "Properties" View.

UML ontology validation

The transformation tool also contains a validation feature which checks the UML ontology model for errors. The tool will reports on errors that will cause problems for the code generation provided by the UML ontology to Java transformation, such as:

  • Classes and properties without names
  • Classes and properties using the same name
  • Circular derivation/generalization
  • Classes without a direct or indirect derivation from an upper ontology class
Also, it gives warning for issues that might be problems, such as:
  • No properties defined for a class
  • Multiple derivation/generalization
To run the validation, select "Validate UML ontology" from the AAL Studio menu.

Preferences

By default, the result of the transformation is saved into the currently selected project, with the Java files put in the path /src/main/java. This can be changed by selecting Window -> Preferences in Eclipse, and then expanding AAL Studio and selecting the relevant transformation from the list. On this page, the user can select whether they want to give an absolute path where the result of the transformation will be saved, for example C:/Transformations/, or if they want a relative path relative to the current project. For both cases, the relative sub-path for the Java files can be specified. The following figure shows the preferences dialog:

Known remaining limitations and problems

  • POM files are not updated by transformation - not essential, as Ontology Wizard generates initial
  • Wizard/form for creating XML file metadata not implemented - low return on effort

Transformation Tool Video

Model Transformation Video

OWL2UML Transformation Video