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.
OntClassInfo
,
RDFClassInfo
,
OntClassInfoSetup
,
RDFClassInfoSetup
,
ResourceFactory
Modifier and Type | Field and Description |
---|---|
static String |
PROP_OWL_IMPORT
URI of the property 'imports'.
|
static String |
TYPE_OWL_ONTOLOGY
URI of the ontology.
|
Constructor and Description |
---|
Ontology(String ontURI)
Standard constructor to create a new ontology.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public static final String TYPE_OWL_ONTOLOGY
public static final String PROP_OWL_IMPORT
public Ontology(String ontURI)
ontURI
- The ontology URI. If this is a namespace, i.e. the ontology
URI including the hash sign, the hash sign is removed.protected boolean addImport(String ontURI)
ontURI
- The URI of the import ontology.public Resource getInfo()
public abstract void create()
OntologyManagement.register(org.universAAL.middleware.container.ModuleContext, Ontology)
and MUST be overwritten by all subclasses.public final boolean checkPermission(String uri)
public boolean hasOntClass(String classURI)
classURI
- URI of the class.public final OntClassInfo[] getOntClassInfo()
getRDFClassInfo()
public final RDFClassInfo[] getRDFClassInfo()
getOntClassInfo()
protected RDFClassInfoSetup createNewRDFClassInfo(String classURI, ResourceFactory fac, int factoryIndex)
classURI
- URI of the class.fac
- The factory to create new instances.factoryIndex
- Factory index to be given to the factory.protected OntClassInfoSetup createNewAbstractOntClassInfo(String classURI)
classURI
- URI of the class.extendExistingOntClassInfo(String)
protected OntClassInfoSetup createNewOntClassInfo(String classURI, ResourceFactory fac)
createNewOntClassInfo(String, ResourceFactory, int)
with a dummy
factory index of -1.classURI
- URI of the class.fac
- The factory to create new instances.extendExistingOntClassInfo(String)
protected OntClassInfoSetup createNewOntClassInfo(String classURI, ResourceFactory fac, int factoryIndex)
classURI
- URI of the class.fac
- The factory to create new instances.factoryIndex
- Factory index to be given to the factory.extendExistingOntClassInfo(String)
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.
classURI
- URI of the class to extend.public Resource[] getResourceList()
public void lock()
Ontology
is automatically locked when it is
registered at the OntologyManagement
.Copyright © 2015 universAAL Consortium. All rights reserved.