kaos.core.csi.ontology
Class OntologyServiceImpl

java.lang.Object
  extended by kaos.core.csi.ontology.OntologyServiceImpl
All Implemented Interfaces:
OntologyService

public class OntologyServiceImpl
extends java.lang.Object
implements OntologyService

Defines the operations to manage and access Ontology Service and its repository

Author:
KAoS Team $Revision: 1.11 $

Method Summary
 SerializableOntModelImpl getConstructedOntologyStructure(java.lang.String structureId)
          This method retrieves user defined ontology structure identified by the id from the repository.
 java.util.List getConstructedOntologyStructures()
          This method retrieves all user defined ontology structures in the repository.
 java.util.Set getImmediateSubClassesOf(java.lang.String className)
          Get set of immediate subclasses of the given class (direct children of the class).
static OntologyService getInstance()
          Retrieve an instance of OntologyService.
static OntologyService getInstance(java.lang.String transportName)
          Retrieve an instance of OntologyService.
 java.util.Set<java.lang.String> getInstancesOf(java.lang.String conceptName)
          Get set of instances of the given concept; if the concept is an instance itself the set contains just this instance.
 java.util.Set<java.lang.String> getListOfLoadedOntologies()
          This method returns a set of urls depicting ontologies loaded into the Ontology Service
 java.util.Set<java.lang.String> getOntologyDefinitionForConcept(java.lang.String conceptName)
          Get set of urls for the given short concept name.
 java.util.List<java.lang.String> getPropertiesApplicableTo(java.lang.String className)
          Get properties applicable to the given class
 java.lang.String getRangeOnPropertyForClass(java.lang.String className, java.lang.String propertyName)
          Get the name of the class defining the range of the specified property for the given class.
 java.util.List<java.lang.String> getSchema(java.lang.String conceptName)
          Get XML schema of the given concept if such a schema is available
 java.util.Set getSubClassesOf(java.lang.String className)
          Get set of subclasses of the given class.
 java.util.Set getSubPropertiesOf(java.lang.String propertyName)
          Get set of subproperties of the given property.
 java.util.Set getSuperPropertiesOf(java.lang.String propertyName)
          Get set of superproperties of the given property.
 java.util.Set<java.lang.String> getUltimateOntologyTypesOfIndividual(java.lang.String individualName)
          Finds the ultimate Ontology type of the provided individual
 java.util.Set<java.lang.String> getValuesForProperty(java.lang.String property, java.lang.String subject)
          Get the values of a given property for a given subject
 java.util.Vector initiateActionClassTargets(java.lang.String actionClassName, java.lang.String actorClassName)
          Get properties applicable to the action class
 void loadOntologies(java.util.List<SerializableOntModelImpl> myOntModels, boolean recursiveLoad)
          Adds ontology included in the provide objects into the ontology repository.
 void loadOntology(SerializableOntModelImpl myOntModel, boolean recursiveLoad)
          Adds ontology included in the provide objects into the ontology repository.
 void loadOntology(java.lang.String loadedOWL)
          Loads ontology in OWL into the repository of the Ontology Service
 void loadOntology(java.lang.String myURL, boolean recursiveLoad)
          Loads ontology in OWL from given URL into the repository of the Ontology Service
protected  void logMessage(java.lang.String msg, java.lang.Exception e, int logLevel)
           
protected  void logMessage(java.lang.String msg, int logLevel)
           
 void putSchema(java.lang.String conceptName, java.lang.String xmlSchema)
          Add an XML schema for the given concept
 void removeConstructedOntologyStructure(java.lang.String structureId)
          This method removes a user defined ontology structure identified by the id from the repository.
 void removeConstructedOntologyStructures(java.util.List<java.lang.String> structureIds)
          This method removes multiple user defined ontology structure identified by the id from the repository.
 boolean testTrue(java.lang.String statement)
          Test if the KIF statemant is true according to the ontologies in the ontology repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static OntologyService getInstance(java.lang.String transportName)
                                   throws java.lang.Exception
Retrieve an instance of OntologyService. The returned instance has initialized communication with the DS.

Parameters:
transportName - String specifying the name of the transport to use for communication with the KAoS Directory Service.
Returns:
a singleton, OntologyService.
Throws:
java.lang.Exception

getInstance

public static OntologyService getInstance()
                                   throws java.lang.Exception
Retrieve an instance of OntologyService. Thy returned instance may or may not be able to communicate with the Directory Service. If the communication with the Directory Service is not supported, then all requested operations will be invoked only on the local Guard.

Returns:
a singleton, OntologyService.
Throws:
java.lang.Exception

getInstancesOf

public java.util.Set<java.lang.String> getInstancesOf(java.lang.String conceptName)
                                               throws UnknownConceptException,
                                                      DirectoryFailure
Description copied from interface: OntologyService
Get set of instances of the given concept; if the concept is an instance itself the set contains just this instance.

Specified by:
getInstancesOf in interface OntologyService
Parameters:
conceptName - The name of the concept in the Jena format
Returns:
Set of instance ids
Throws:
UnknownConceptException
DirectoryFailure
See Also:
OntologyService.getInstancesOf(java.lang.String)

getUltimateOntologyTypesOfIndividual

public java.util.Set<java.lang.String> getUltimateOntologyTypesOfIndividual(java.lang.String individualName)
                                                                     throws UnknownConceptException,
                                                                            DirectoryFailure
Finds the ultimate Ontology type of the provided individual

Specified by:
getUltimateOntologyTypesOfIndividual in interface OntologyService
Parameters:
individualName - the name of the individual
Returns:
the set of names of the Ontology classes being the most narrow ones for the given individual
Throws:
UnknownConceptException - if concept unknown or any problem with JTP approached
DirectoryFailure

getListOfLoadedOntologies

public java.util.Set<java.lang.String> getListOfLoadedOntologies()
                                                          throws DirectoryFailure
Description copied from interface: OntologyService
This method returns a set of urls depicting ontologies loaded into the Ontology Service

Specified by:
getListOfLoadedOntologies in interface OntologyService
Throws:
DirectoryFailure
See Also:
OntologyService.getListOfLoadedOntologies()

getOntologyDefinitionForConcept

public java.util.Set<java.lang.String> getOntologyDefinitionForConcept(java.lang.String conceptName)
                                                                throws DirectoryFailure
Description copied from interface: OntologyService
Get set of urls for the given short concept name. Currently it tries to match the concept name with the local name of the ontology definitions url

Specified by:
getOntologyDefinitionForConcept in interface OntologyService
Parameters:
conceptName - A short name of concept, e.g. "Actor"
Returns:
Set of url containing the short concept name
Throws:
DirectoryFailure
See Also:
OntologyService.getOntologyDefinitionForConcept(java.lang.String)

getPropertiesApplicableTo

public java.util.List<java.lang.String> getPropertiesApplicableTo(java.lang.String className)
                                                           throws UnknownConceptException,
                                                                  QueryFailure,
                                                                  DirectoryFailure
Description copied from interface: OntologyService
Get properties applicable to the given class

Specified by:
getPropertiesApplicableTo in interface OntologyService
Parameters:
className - the name of the class
Returns:
vector of properties names
Throws:
UnknownConceptException
QueryFailure
DirectoryFailure
See Also:
OntologyService.getPropertiesApplicableTo(java.lang.String)

getValuesForProperty

public java.util.Set<java.lang.String> getValuesForProperty(java.lang.String property,
                                                            java.lang.String subject)
                                                     throws DirectoryFailure,
                                                            QueryFailure
Description copied from interface: OntologyService
Get the values of a given property for a given subject

Specified by:
getValuesForProperty in interface OntologyService
Parameters:
property - - the property for which to lookup values
subject - - the subject to get the property values for
Returns:
Set of property values for the given subject as Strings
Throws:
QueryFailure
DirectoryFailure
See Also:
OntologyService.getValuesForProperty(java.lang.String, java.lang.String)

getRangeOnPropertyForClass

public java.lang.String getRangeOnPropertyForClass(java.lang.String className,
                                                   java.lang.String propertyName)
                                            throws UnknownConceptException,
                                                   QueryFailure,
                                                   DirectoryFailure
Description copied from interface: OntologyService
Get the name of the class defining the range of the specified property for the given class.

Specified by:
getRangeOnPropertyForClass in interface OntologyService
Parameters:
className - the name of the class
propertyName - the name of the property
Returns:
the name of the class defining the range
Throws:
UnknownConceptException
QueryFailure
DirectoryFailure
See Also:
OntologyService.getRangeOnPropertyForClass(java.lang.String, java.lang.String)

getSchema

public java.util.List<java.lang.String> getSchema(java.lang.String conceptName)
                                           throws UnknownConceptException,
                                                  DirectoryFailure
Description copied from interface: OntologyService
Get XML schema of the given concept if such a schema is available

Specified by:
getSchema in interface OntologyService
Parameters:
conceptName - uri name of the concept
Returns:
A List containing Strings that define the XML schema of the given concept. The reason it is a vector of strings and not just one string is that the definition can be complex, i.e. derived from multiple more primitive schemas, hence this vector contains definitions for all those schemas too.
Throws:
UnknownConceptException
DirectoryFailure
See Also:
OntologyService.getSchema(java.lang.String)

putSchema

public void putSchema(java.lang.String conceptName,
                      java.lang.String xmlSchema)
               throws DirectoryFailure
Description copied from interface: OntologyService
Add an XML schema for the given concept

Specified by:
putSchema in interface OntologyService
Parameters:
conceptName - uri name of the concept
Throws:
DirectoryFailure
See Also:
OntologyService.putSchema(java.lang.String, java.lang.String)

getSubClassesOf

public java.util.Set getSubClassesOf(java.lang.String className)
                              throws UnknownConceptException,
                                     DirectoryFailure
Description copied from interface: OntologyService
Get set of subclasses of the given class.

Specified by:
getSubClassesOf in interface OntologyService
Parameters:
className - The name of the class
Returns:
Set of subclasses names
Throws:
UnknownConceptException
DirectoryFailure

getImmediateSubClassesOf

public java.util.Set getImmediateSubClassesOf(java.lang.String className)
                                       throws UnknownConceptException,
                                              DirectoryFailure
Description copied from interface: OntologyService
Get set of immediate subclasses of the given class (direct children of the class).

Specified by:
getImmediateSubClassesOf in interface OntologyService
Parameters:
className - The name of the class in Jena format
Returns:
Set of subclasses names in Jena format
Throws:
UnknownConceptException
DirectoryFailure

getSubPropertiesOf

public java.util.Set getSubPropertiesOf(java.lang.String propertyName)
                                 throws UnknownConceptException,
                                        DirectoryFailure
Description copied from interface: OntologyService
Get set of subproperties of the given property.

Specified by:
getSubPropertiesOf in interface OntologyService
Parameters:
propertyName - The name of the property
Returns:
Set of subproperties names
Throws:
UnknownConceptException
DirectoryFailure

getSuperPropertiesOf

public java.util.Set getSuperPropertiesOf(java.lang.String propertyName)
                                   throws UnknownConceptException,
                                          DirectoryFailure
Description copied from interface: OntologyService
Get set of superproperties of the given property.

Specified by:
getSuperPropertiesOf in interface OntologyService
Parameters:
propertyName - The name of the property
Returns:
Set of superproperties names
Throws:
UnknownConceptException
DirectoryFailure

initiateActionClassTargets

public java.util.Vector initiateActionClassTargets(java.lang.String actionClassName,
                                                   java.lang.String actorClassName)
                                            throws DirectoryFailure
Description copied from interface: OntologyService
Get properties applicable to the action class

Specified by:
initiateActionClassTargets in interface OntologyService
Parameters:
actionClassName - the name of the action class performing
actorClassName - the name of the actor class performing the action
Returns:
vector of TargetClassDescription
Throws:
DirectoryFailure

loadOntology

public void loadOntology(java.lang.String loadedOWL)
                  throws OntologyRepository.ReasoningException,
                         DirectoryFailure
Description copied from interface: OntologyService
Loads ontology in OWL into the repository of the Ontology Service

Specified by:
loadOntology in interface OntologyService
Parameters:
loadedOWL - string containing a syntactically correctly OWL
Throws:
OntologyRepository.ReasoningException - when loading of the ontology failed.
DirectoryFailure

loadOntology

public void loadOntology(java.lang.String myURL,
                         boolean recursiveLoad)
                  throws OntologyRepository.ReasoningException,
                         java.io.IOException,
                         DirectoryFailure
Description copied from interface: OntologyService
Loads ontology in OWL from given URL into the repository of the Ontology Service

Specified by:
loadOntology in interface OntologyService
recursiveLoad - whether to load the OWL imported by the given URI
Throws:
OntologyRepository.ReasoningException - when loading of the ontology failed.
java.io.IOException
DirectoryFailure

loadOntology

public void loadOntology(SerializableOntModelImpl myOntModel,
                         boolean recursiveLoad)
                  throws OntologyRepository.ReasoningException,
                         java.io.IOException
Description copied from interface: OntologyService
Adds ontology included in the provide objects into the ontology repository.

Specified by:
loadOntology in interface OntologyService
Parameters:
myOntModel - The object of type Jena OntModel containing the added ontology
recursiveLoad - Indicates if the imported ontologies (by the ontology contained in myOntModel) should also be recursively loaded.
Throws:
OntologyRepository.ReasoningException
java.io.IOException

loadOntologies

public void loadOntologies(java.util.List<SerializableOntModelImpl> myOntModels,
                           boolean recursiveLoad)
                    throws OntologyRepository.ReasoningException,
                           java.io.IOException
Description copied from interface: OntologyService
Adds ontology included in the provide objects into the ontology repository.

Specified by:
loadOntologies in interface OntologyService
recursiveLoad - Indicates if the imported ontologies (by the ontology contained in myOntModel) should also be recursively loaded.
Throws:
OntologyRepository.ReasoningException
java.io.IOException

testTrue

public boolean testTrue(java.lang.String statement)
                 throws QueryFailure,
                        DirectoryFailure
Description copied from interface: OntologyService
Test if the KIF statemant is true according to the ontologies in the ontology repository.

Specified by:
testTrue in interface OntologyService
Parameters:
statement - the statement in KIF to be tested if true
Returns:
true if the statement is true and false in the opposite case
Throws:
QueryFailure
DirectoryFailure

getConstructedOntologyStructure

public SerializableOntModelImpl getConstructedOntologyStructure(java.lang.String structureId)
                                                         throws OntologyRepository.ReasoningException,
                                                                UnknownConceptException,
                                                                java.io.IOException,
                                                                DirectoryFailure
Description copied from interface: OntologyService
This method retrieves user defined ontology structure identified by the id from the repository.

Specified by:
getConstructedOntologyStructure in interface OntologyService
Returns:
SerializableOntModelImpl objects
Throws:
OntologyRepository.ReasoningException
UnknownConceptException
java.io.IOException
DirectoryFailure

getConstructedOntologyStructures

public java.util.List getConstructedOntologyStructures()
                                                throws DirectoryFailure
Description copied from interface: OntologyService
This method retrieves all user defined ontology structures in the repository.

Specified by:
getConstructedOntologyStructures in interface OntologyService
Returns:
list containing SerializableOntModelImpl objects
Throws:
DirectoryFailure

removeConstructedOntologyStructure

public void removeConstructedOntologyStructure(java.lang.String structureId)
                                        throws DirectoryFailure
Description copied from interface: OntologyService
This method removes a user defined ontology structure identified by the id from the repository.

Specified by:
removeConstructedOntologyStructure in interface OntologyService
Throws:
DirectoryFailure

removeConstructedOntologyStructures

public void removeConstructedOntologyStructures(java.util.List<java.lang.String> structureIds)
                                         throws DirectoryFailure
Description copied from interface: OntologyService
This method removes multiple user defined ontology structure identified by the id from the repository.

Specified by:
removeConstructedOntologyStructures in interface OntologyService
Throws:
DirectoryFailure

logMessage

protected void logMessage(java.lang.String msg,
                          int logLevel)

logMessage

protected void logMessage(java.lang.String msg,
                          java.lang.Exception e,
                          int logLevel)