org.universAAL.middleware.owl
Class Ontology

Package class diagram package Ontology
java.lang.Object
  extended by org.universAAL.middleware.owl.Ontology
Direct Known Subclasses:
ActivityHubOntology, AVOntology, ContactOntology, ContextBusOntology, ContextHistoryOntology, ContinuaHealthManagerOntology, DataRepOntology, DependabilityOntology, DeviceOntology, DeviceOntology, DiseaseOntology, DroolsReasoningOntology, FurnitureOntology, HandgesturesOntology, HealthMeasurementOntology, HealthProfileOntology, ImpairmentOntology, LanguageOntology, LightingOntology, LocationOntology, MeasurementOntology, MenuProfileOntology, MultimediaOntology, PersonalHealthDeviceOntology, PhThingOntology, ProfileOntology, QuestionnaireOntology, ReasoningOntology, RecommendationsOntology, SecurityOntology, ServiceBusOntology, ShapeOntology, SimpleOntology, SpaceOntology, TutorialOntology, UIBusOntology, UIPreferencesProfileOntology, UnitOntology, VCardOntology, X73Ontology

public abstract class Ontology
extends Object

The implementation of an OWL ontology. Basically, an ontology is a model of a part of the real world. From a programming point of view, the ontology is a group of ontological classes where each ontology class represents a concept of the real world. An ontology is typically accompanied by a ResourceFactory to create new instances of the ontological classes.

For example, one might want to model multimedia devices and creates the ontology multimedia with the classes TV, LoudSpeaker, VideoCamera and Microphone. Each of these classes might have some properties, e.g. LoudSpeaker could have a volume which is given as an integer value (since integer is a datatype, it is defined as a DatatypeProperty). Also, a TV typically itself has a LoudSpeaker, so it could have a property where all values of that property are instances of LoudSpeaker (since LoudSpeaker is a class, the property would be an ObjectProperty).

Each ontology class corresponds to a Java class that must be a subclass of ManagedIndividual. This class is then responsible to provide getter and setter methods for its properties as a convenience for programmers. These methods will internally realize an RDF structure to store the knowledge of that class using the methods Resource.getProperty(String) and Resource.setProperty(String, Object).

Additionally, for every ontology class (which stores the information at the instance level), there is an instance of OntClassInfo (which stores the information at model level) and each OntClassInfo is accompanied by an OntClassInfoSetup that provides the possibility to set the model information (for security reasons, the setter methods are in OntClassInfoSetup and the getter methods are in OntClassInfo so that only the creator of an ontology can make changes to it).

In our example, the concept LoudSpeaker has the property volume and this information is a model information which is stored in an OntClassInfo, so the overwritten create() method would define:

OntClassInfoSetup oci = createNewOntClassInfo(URI_of_LoudSpeaker, factory, factoryIndex);
oci.addDatatypeProperty(URI_of_Volume_Property).

For the convenience of programmers there exists a Java class LoudSpeaker that corresponds to this class with the helper methods getVolume() and setVolume(int). An instance of this class would then identify a specific instance of LoudSpeaker, e.g. LoudSpeaker_2 with the volume 100.

To create an ontology in universAAL, a subclass of this class has to be defined and the method create() has to be overwritten. The create() method will set up all characteristics of the ontology. Each Ontology has to be registered at the OntologyManagement by calling OntologyManagement.register(org.universAAL.middleware.container.ModuleContext, Ontology) before it can be used.

In our example, the classes TV, LoudSpeaker, VideoCamera and Microphone are created with one of the createNewXXClassInfo methods and then all characteristics of these classes (like properties and restrictions) are added.

Author:
Carsten Stockloew
See Also:
OntClassInfo, RDFClassInfo, OntClassInfoSetup, RDFClassInfoSetup, ResourceFactory

Field Summary
static String PROP_OWL_IMPORT
          URI of the property 'imports'.
static String TYPE_OWL_ONTOLOGY
          URI of the ontology.
 
Constructor Summary
Ontology(String ontURI)
          Standard constructor to create a new ontology.
 
Method Summary
protected  boolean addImport(String ontURI)
          Add an import to this ontology.
 boolean checkPermission(String uri)
          Internal method.
abstract  void create()
          Create this ontology.
protected  OntClassInfoSetup createNewAbstractOntClassInfo(String classURI)
          Register a new abstract OWL class.
protected  OntClassInfoSetup createNewOntClassInfo(String classURI, ResourceFactory fac)
          Register a new OWL class.
protected  OntClassInfoSetup createNewOntClassInfo(String classURI, ResourceFactory fac, int factoryIndex)
          Register a new OWL class.
protected  RDFClassInfoSetup createNewRDFClassInfo(String classURI, ResourceFactory fac, int factoryIndex)
          Register a new RDF class.
protected  OntClassInfoSetup extendExistingOntClassInfo(String classURI)
           Extend an existing OWL class.
 Resource getInfo()
          Get the object that stores all general information about the ontology, like description, version, author, and imports.
 OntClassInfo[] getOntClassInfo()
          Get the class information of all OWL classes of this ontology.
 RDFClassInfo[] getRDFClassInfo()
          Get the class information of all RDF classes of this ontology.
 Resource[] getResourceList()
          Get a list of all resources of this ontology.
 boolean hasOntClass(String classURI)
          Determines whether this ontology defines or extends the given OWL class.
 void lock()
          Lock this instance and all its elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_OWL_ONTOLOGY

public static final String TYPE_OWL_ONTOLOGY
URI of the ontology.

See Also:
Constant Field Values

PROP_OWL_IMPORT

public static final String PROP_OWL_IMPORT
URI of the property 'imports'.

See Also:
Constant Field Values
Constructor Detail

Ontology

public Ontology(String ontURI)
Standard constructor to create a new ontology.

Parameters:
ontURI - The ontology URI. If this is a namespace, i.e. the ontology URI including the hash sign, the hash sign is removed.
Method Detail

addImport

protected boolean addImport(String ontURI)
Add an import to this ontology. An import states the URI of another ontology from which some concepts are used in this ontology.

Parameters:
ontURI - The URI of the import ontology.
Returns:
true, if the import could be added, or false, if the given ontology URI is not valid.

getInfo

public Resource getInfo()
Get the object that stores all general information about the ontology, like description, version, author, and imports.


create

public abstract void create()
Create this ontology. This method is called by OntologyManagement.register(org.universAAL.middleware.container.ModuleContext, Ontology) and MUST be overwritten by all subclasses.


checkPermission

public final boolean checkPermission(String uri)
Internal method.


hasOntClass

public boolean hasOntClass(String classURI)
Determines whether this ontology defines or extends the given OWL class.

Parameters:
classURI - URI of the class.
Returns:
true, if this ontology defines or extends the given OWL class.

getOntClassInfo

public final OntClassInfo[] getOntClassInfo()
Get the class information of all OWL classes of this ontology.

See Also:
getRDFClassInfo()

getRDFClassInfo

public final RDFClassInfo[] getRDFClassInfo()
Get the class information of all RDF classes of this ontology.

See Also:
getOntClassInfo()

createNewRDFClassInfo

protected RDFClassInfoSetup createNewRDFClassInfo(String classURI,
                                                  ResourceFactory fac,
                                                  int factoryIndex)
Register a new RDF class.

Parameters:
classURI - URI of the class.
fac - The factory to create new instances.
factoryIndex - Factory index to be given to the factory.
Returns:
The setup interface.

createNewAbstractOntClassInfo

protected OntClassInfoSetup createNewAbstractOntClassInfo(String classURI)
Register a new abstract OWL class. An OWL class is abstract iff the Java counterpart is abstract. As such a class can not be instantiated, no factory can be given.

Parameters:
classURI - URI of the class.
Returns:
The setup interface.
See Also:
extendExistingOntClassInfo(String)

createNewOntClassInfo

protected OntClassInfoSetup createNewOntClassInfo(String classURI,
                                                  ResourceFactory fac)
Register a new OWL class. This method calls createNewOntClassInfo(String, ResourceFactory, int) with a dummy factory index of -1.

Parameters:
classURI - URI of the class.
fac - The factory to create new instances.
Returns:
The setup interface.
See Also:
extendExistingOntClassInfo(String)

createNewOntClassInfo

protected OntClassInfoSetup createNewOntClassInfo(String classURI,
                                                  ResourceFactory fac,
                                                  int factoryIndex)
Register a new OWL class.

Parameters:
classURI - URI of the class.
fac - The factory to create new instances.
factoryIndex - Factory index to be given to the factory.
Returns:
The setup interface.
See Also:
extendExistingOntClassInfo(String)

extendExistingOntClassInfo

protected OntClassInfoSetup extendExistingOntClassInfo(String classURI)

Extend an existing OWL class. A class is normally defined only once and only in one ontology. However, other ontologies can add some characteristics to that class. This method should be called in that case: when a different ontology has already defined a class and some characteristics (like additional properties) have to be added by this ontology.

The OntologyManagement will combine all information (from the definition and all extenders) and will provide a combined view as if all these characteristics were defined only once and only in one ontology.

Parameters:
classURI - URI of the class to extend.
Returns:
The setup interface.

getResourceList

public Resource[] getResourceList()
Get a list of all resources of this ontology. The resources are the info part, the RDF and OWL classes as well as the properties of these classes.


lock

public void lock()
Lock this instance and all its elements. After it is locked, no changes can be made. The Ontology is automatically locked when it is registered at the OntologyManagement.



Copyright © 2014 universAAL Consortium. All Rights Reserved.