Ontology modelling - universAAL/tools.eclipse-plugins GitHub Wiki
This universAAL Studio tool is intended to be used by developers of services and platform components that need to create or extend an own ontology. The goal of the tool is to simplify the development of ontologies, by generating most of the required Java code based on a more high-level description. Benefits of this approach is simpler and quicker development and maintenance of ontologies, avoiding manually introduced mistakes in the code, and more uniform implementation code.
The Ontology Modelling Tool (OMT) provides a simple user interface that enables ontology developers to focus on the ontology concepts instead of the java representation of it.
The use of this tool is not mandatory, but highly recommended. The alternative to using the tool (in combination with the Model Transformation Tool) is to manually code the ontologies as Java code. The Reference Documentation describes the approach for manual coding of ontologies. Compared to the manual coding, this tool provides the following benefits:
- Simplify the process of creating ontologies for use on universAAL middleware
- Lower learning threshold
- Reduce effort required (time)
- Limit error-prone activities
- Reuse in universAAL and for other platforms (representations)
The universAAL Studio support for ontology modelling enable you to create or extend ontologies by building a model of the ontology and then generating the Java code that represent the model. The tools are built around the open source Eclipse projects Papyrus (for modelling) and MOFScript (for code generation), with extensions that include UML profiles for ontology modelling and transformations that generate the Java code. Also, the tools include the Ontology Project Wizard which help you to quickly set up a new ontology project with a model you can start from.
The current version of this tool has been successfully tested with small example ontologies. More complex ontologies including multiple root packages and multiple levels of packages are supported in the current version, but it is recommended to keep the ontologies at a reasonable size as the tool has not yet been thoroughly tested with complex ontologies.
The UML profiles for OWL and RDF included with the tool are based the Ontology Definition Metamodel (OMD) from OMG, and have been adapted from the implementation of http://code.google.com/p/twouse/ .
The process of creating a new ontology for use in universAAL follows three basic steps:
- Create an ontology project using a wizard (see Ontology Project Wizard for details about the wizard)
- Design a model of the ontology in UML
- Generate the Java representation of the ontology and Maven POM files from the model
The UML metamodel does not provide enough expressiveness to unambiguously model an ontology (subset) using the standard UML language (classes, associations etc). Therefore it is necessary to a UML profile for OWL that extends the UML langauge with OWL concepts, allowing the designer to mark model elements. The OMT hides much of the complexity and required work through the use of template projects and modelling palettes in Eclipse. For specific needs, please refer to the reference document from universAAL Work Package 3.
The modelling approach to ontology design is closely related to the way an ontology is defined in Java. This subsection describes the overall concept mappings
- UML Model: is the topmost modelling level. Using the Ontology Project Wizard will create the model correctly.
- UML Package: represents an Ontology. A package is marked as a "owlOntology" using stereotypes from the OWL UML Library. Using the Ontology Project Wizard the package is created and labeled using the names filled in the wizard
- UML Class: represents a ontology concept. A Class can have properties (attributes) that are typed (datatype or object), and associations that are directed. A class will map to a Java class (and file), and will be included in the Ontology and Activator files.
- UML Properties: this is an attribute of the class or interface and represents a property of the ontology concept. There are two types of properties that can be associated with a class: ObjectProperty and DatatypeProperty. Using the elements found in the Ontology Modelling Tool palette, you the types and required stereotypes settings are automatically set to their default values (e.g. isFunctional="true")
- UML Association: an association is simliar to a property and will result in a property in the owner class (assuming only unidirectional associations).
Note: the name of the property will be the label on the association end (default by tool is the end class name), and this is also where you can set the multiplicity of the relation (0..1, 1, 0..*, 1..*). In Papyrus this member end is shown to the right in the Properties view. - UML Generalization: a generalization is a way to describe inheritance using UML, and will result in a class extend relationship in java.
The wizard will require create a project with the necessary packages and files. The two main model files are:
- <ontologyname></ontologyname>.uml: the model itself, stored as XMI
- <ontologyname></ontologyname>.di: the diagram view of the .uml file
- Naming: org.universaal.ontology + <ontologyname></ontologyname>
- UML Classes are used for ontology classes. The classes can be set as "Abstract" in the properties view
- Generalizations/specializations are used for subclassing
- Enumerations have enumerationliterals. Also found in the palette
- Associations have cardinality and member end names
- Properties
- Name: lowercaseUppercase
- Stereotype describes type
- ObjectProperty: another ontology class
- DatatypeProperty: UML primitive types
- Tagged value: isFunctional can be set true/false. The palette elements have default value true
- Cardinality should be set for each property in the properties view
- The property's default value can used for upper/lower Integers
- name: "values", value: "lower..upper"
- Start universAAL Studio and create a new Ontology modelling project

- Ensure that you're in the Papyrus perspective. Double-click the diagram/model and verify that the diagram is loaded properly. The wizard creates a template ontology with a set of classes that you can rename or replace. A simple ontology is shown below

- To add more concepts and properties, chose elements from the palette.

- To create the java code for your ontology, select the UML file in the package explorer (you may have to switch to the Java perspective), right-click, select universAAL Studio and "Transform UML Ontology to Java" This will create a set of java files in the src packages and update the project's POM file. Example of the java code for the example ontology is shown below.

When modelling ontologies, you will usually reuse elements from existing ontologies, either by generalizing from them (using them as super-classes) or by referring to them in object properties and associations.
To get access to classes from another model, that model must first be imported into your model. The template model that is used when you create an ontology model with the Ontology Wizard, comes with the upper ontologies of universAAL pre-imported. The list of imported models can be seen as Package Import entries in the Model Explorer view of Papyrus.
Elements from imported models can primarily be used in two ways:
- as type for object properties of your own elements. Click on "..." next to the Type field in the Properties view, and navigate to the element from the dialog that appears. If you type in the name of the element, the set of elements in the dialog will be narrowed down.
- as an element to generalize from or draw an association to. To do this, first navigate to the element to import by expanding the package import for the containing package in the model explorer view. Then, drag the element from the model explorer view and into your diagram. You can then add generalizations and associations targeting it.
Note that imported .uml files must be present at the same location as when they were imported whenever you open your ontology model. To ensure they are available, you may want to first copy the .uml files of ontolgies you plan to import into your own project.
The upper ontologies of universAAL are registered packages, and if one of them are missing from your model, they can be imported using the "Import registered package" entry of the Import menu. For the registered packages, you do not have to worry about where they are located, as these are installed with the ontology modelling tool and are always available.
As mentioned in the introduction, the current version of the Ontology Modelling Tool supports ontology projects having more than one root package. The wizard will only generate one root package, hence the designer must manually add more packages to the root diagram from the model palette or context menu in the Model Explorer view.
Having multiple root packages in an ontology project is a special case and should only be used when deemed necessary. When possible, the complex ontologies should be split into several projects and utilize the upcoming "import" functionality.
Having multiple levels of packages can be seen as a way to structure large ontologies. The transformation tool support "unlimited" number of levels. The phWorld ontology is an example of a multilevel multiroot package ontology.
To boost the learning process we provide an example ontology model. The Meal ontology is presented in this powerpoint presentation: Introduction slides on slideshare
The modelling process using the AAL Studio Ontology Modelling tool is shown in this video (password: universAAL): Ontology modelling screencast on Vimeo
- Only some of the upper ontologies are available for import - updates are planned
- Popup error saying "An internal error..." sometimes appear due to bug in Papyrus,
but editor continues to work. Workaround: delete explanation notes from model.