kaos.ontology.repository
Class JTPOntologyRepository

java.lang.Object
  extended by kaos.ontology.repository.OntologyRepositoryCommons
      extended by kaos.ontology.repository.JTPOntologyRepository
All Implemented Interfaces:
OntologyRepository

public class JTPOntologyRepository
extends OntologyRepositoryCommons
implements OntologyRepository

This class contains the JPT ontology repository and provides method to load new ontologies, manage ontologies and query the ontology knowledge base.


Nested Class Summary
 
Nested classes/interfaces inherited from interface kaos.ontology.repository.OntologyRepository
OntologyRepository.ReasoningException
 
Field Summary
 
Fields inherited from class kaos.ontology.repository.OntologyRepositoryCommons
allClasses, allConcepts, allProperties, foundClassesDefinedInNamspaces, foundConceptsOntologyMapping, foundInstancesDefinedInNamspaces, foundNamespacesImportedByNamspaces, foundPropertyDefinedInNamspaces, foundPropertyRangesForClasses, immediateSubClassesOfClasses, instancesOfClasses, myFilteredNamespaces, myKAoSDirectoryService, myOntologyLoader, myOntologyRepository, subClassesOfClasses, subPropertiesOfProperties, superClassesOfClasses, superPropertiesOfProperties
 
Constructor Summary
JTPOntologyRepository()
           
JTPOntologyRepository(boolean loadDefaultOntologies)
           
 
Method Summary
 java.util.Set<java.lang.String> askQuery(java.lang.String variableName, java.lang.String multiplyVariablesQuery)
          Get values of the selected variable satisfying the KIF query with possibly many variable.
 java.util.Set<java.lang.String> getClassesDefInNamespace(java.lang.String namespaceName)
          Get set of classes defined in the given namespace.
 java.util.Set<java.lang.String> getImmediateSubClassesOf(java.lang.String className)
          Get set of immediate subclasses of the given class (direct children of the class).
 java.util.Set<java.lang.String> getInstancesDefInNamespace(java.lang.String namespaceName)
          Get set of instances defined in the given namespace.
 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> getNamspacesImportedByNamespace(java.lang.String namespaceName)
          Get set of namespaces imported by the given namespace.
 java.util.Set<java.lang.String> getOntologyDefinitionForConcept(java.lang.String conceptName)
          Get mapping to the urls of ontology concept for the given concept name.
 java.util.List<java.lang.String> getPropertiesApplicableTo(java.lang.String className)
          Get properties applicable to the given class
 java.util.Set<java.lang.String> getPropertiesDefInNamespace(java.lang.String namespaceName)
          Get set of properties defined in the given namespace.
 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.Set<java.lang.String> getResourcesWithValueForProperty(java.lang.String property, java.lang.String value)
          Get values of the variable satisfying the KIF query: (property ?subject value).
 java.util.Set<java.lang.String> getSubClassesOf(java.lang.String className)
          Get set of subclasses of the given class.
 java.util.Set<java.lang.String> getSubPropertiesOf(java.lang.String propertyName)
          Get set of subproperties of the given property.
 java.util.Set<java.lang.String> getSuperClassesOf(java.lang.String className)
          Get set of superclasses of the given class.
 java.util.Set<java.lang.String> getSuperPropertiesOf(java.lang.String propertyName)
          Get set of super properties of the given property.
 java.util.Set<java.lang.String> getUltimateOntologyTypesOfIndividual(java.lang.String individualName)
          Finds the ultimate Ontology type of the provided individual, from the ontologies explicitly loaded into repository
 javax.swing.undo.UndoManager getUndoManager()
          Get the undo manager for reasoning inference.
 java.lang.String getUniqueValueForProperty(java.lang.String property, java.lang.String subject)
          Get a single value of the variable satisfying the KIF query: (property subject ?val).
 java.util.Set<java.lang.String> getValuesForProperty(java.lang.String property, java.lang.String subjectStr)
          Get values of the variable satisfying the KIF query: (property subject ?val).
 void loadKB(java.net.URL _url)
          Stores the assertion as well as its forward-chained information.
 void loadOntology(OntModel myOWLModel, boolean recursiveLoad)
          Loads ontology from the provided url.
 int tellKifString(java.lang.String assertion)
          Stores the assertion as well as its forward-chained information.
 int tellOwlString(java.lang.String assertion)
          Stores the assertion as well as its forward-chained information.
 boolean testTrue(java.lang.String statement)
          Test if the KIF statement is true according to the ontologies in the ontology repository.
 void untellKifString(java.lang.String assertion)
          Deletes the assertion as well as its forward-chained information.
 void untellOwlString(java.lang.String assertion)
          Deletes the assertion as well as its forward-chained information.
 
Methods inherited from class kaos.ontology.repository.OntologyRepositoryCommons
addFilteredNamespace, filterConcept, filterConcepts, flushCaches, getAllNamespaces, getFilteredNamespaces, getListOfLoadedOntologies, initFilteredNamespaces, initiateClassProperties, printDebugString, removeFilteredNamespace, resetOntologyLoader, setNotificationRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface kaos.ontology.repository.OntologyRepository
addFilteredNamespace, getAllNamespaces, getFilteredNamespaces, getListOfLoadedOntologies, initiateClassProperties, removeFilteredNamespace, resetOntologyLoader, setNotificationRef
 

Constructor Detail

JTPOntologyRepository

public JTPOntologyRepository()

JTPOntologyRepository

public JTPOntologyRepository(boolean loadDefaultOntologies)
Method Detail

loadKB

public void loadKB(java.net.URL _url)
            throws OntologyRepository.ReasoningException,
                   java.io.IOException
Description copied from interface: OntologyRepository
Stores the assertion as well as its forward-chained information.

Specified by:
loadKB in interface OntologyRepository
Parameters:
_url - - a url to a file containing KIF-formatted string to assert
Throws:
OntologyRepository.ReasoningException
java.io.IOException

tellKifString

public int tellKifString(java.lang.String assertion)
                  throws OntologyRepository.ReasoningException
Description copied from interface: OntologyRepository
Stores the assertion as well as its forward-chained information.

Specified by:
tellKifString in interface OntologyRepository
Parameters:
assertion - - a KIF-formatted string to assert
Throws:
OntologyRepository.ReasoningException

untellKifString

public void untellKifString(java.lang.String assertion)
                     throws OntologyRepository.ReasoningException
Description copied from interface: OntologyRepository
Deletes the assertion as well as its forward-chained information.

Specified by:
untellKifString in interface OntologyRepository
Parameters:
assertion - - a KIF-formatted string to untell
Throws:
OntologyRepository.ReasoningException

tellOwlString

public int tellOwlString(java.lang.String assertion)
                  throws OntologyRepository.ReasoningException
Description copied from interface: OntologyRepository
Stores the assertion as well as its forward-chained information.

Specified by:
tellOwlString in interface OntologyRepository
Parameters:
assertion - - OWL string to assert
Throws:
OntologyRepository.ReasoningException

untellOwlString

public void untellOwlString(java.lang.String assertion)
                     throws OntologyRepository.ReasoningException
Description copied from interface: OntologyRepository
Deletes the assertion as well as its forward-chained information.

Specified by:
untellOwlString in interface OntologyRepository
Parameters:
assertion - - a OWL-formatted string to untell
Throws:
OntologyRepository.ReasoningException

getUndoManager

public javax.swing.undo.UndoManager getUndoManager()
Description copied from interface: OntologyRepository
Get the undo manager for reasoning inference.

Specified by:
getUndoManager in interface OntologyRepository

loadOntology

public void loadOntology(OntModel myOWLModel,
                         boolean recursiveLoad)
                  throws OntologyRepository.ReasoningException,
                         java.io.IOException
Description copied from interface: OntologyRepository
Loads ontology from the provided url.

Specified by:
loadOntology in interface OntologyRepository
Overrides:
loadOntology in class OntologyRepositoryCommons
Parameters:
myOWLModel - the url to the ontology
recursiveLoad - indicates if the imported ontologies (by the ontology depicted by myURL) should also be recursively loaded.
Throws:
OntologyRepository.ReasoningException - or IOException when loading of the ontology failed.
java.io.IOException

testTrue

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

Specified by:
testTrue in interface OntologyRepository
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:
OntologyRepository.ReasoningException - if reasoning failed.

getUniqueValueForProperty

public java.lang.String getUniqueValueForProperty(java.lang.String property,
                                                  java.lang.String subject)
                                           throws OntologyRepository.ReasoningException
Description copied from interface: OntologyRepository
Get a single value of the variable satisfying the KIF query: (property subject ?val).

Specified by:
getUniqueValueForProperty in interface OntologyRepository
Parameters:
property - the name of the property
subject - the name of the subject
Returns:
a single value for the property on this subject
Throws:
OntologyRepository.ReasoningException - if reasoning failed.

getValuesForProperty

public java.util.Set<java.lang.String> getValuesForProperty(java.lang.String property,
                                                            java.lang.String subjectStr)
                                                     throws OntologyRepository.ReasoningException
Description copied from interface: OntologyRepository
Get values of the variable satisfying the KIF query: (property subject ?val).

Specified by:
getValuesForProperty in interface OntologyRepository
Parameters:
property - the name of the property
subjectStr - the name of the subject
Returns:
a set with values for the property on this subject
Throws:
OntologyRepository.ReasoningException - if reasoning failed.

getResourcesWithValueForProperty

public java.util.Set<java.lang.String> getResourcesWithValueForProperty(java.lang.String property,
                                                                        java.lang.String value)
                                                                 throws OntologyRepository.ReasoningException
Description copied from interface: OntologyRepository
Get values of the variable satisfying the KIF query: (property ?subject value).

Specified by:
getResourcesWithValueForProperty in interface OntologyRepository
Parameters:
property - the name of the property
value - the value
Returns:
a set with name of subjects which has the specified value for the given property
Throws:
OntologyRepository.ReasoningException - if reasoning failed.

askQuery

public java.util.Set<java.lang.String> askQuery(java.lang.String variableName,
                                                java.lang.String multiplyVariablesQuery)
                                         throws OntologyRepository.ReasoningException
Description copied from interface: OntologyRepository
Get values of the selected variable satisfying the KIF query with possibly many variable.

Specified by:
askQuery in interface OntologyRepository
Parameters:
variableName - the name of the selected variable
multiplyVariablesQuery - the query
Returns:
a set with values satisfying the query
Throws:
OntologyRepository.ReasoningException - if reasoning failed.

getPropertiesApplicableTo

public java.util.List<java.lang.String> getPropertiesApplicableTo(java.lang.String className)
                                                           throws OntologyRepository.ReasoningException
Description copied from interface: OntologyRepository
Get properties applicable to the given class

Specified by:
getPropertiesApplicableTo in interface OntologyRepository
Parameters:
className - the name of the class
Returns:
vector of properties names
Throws:
OntologyRepository.ReasoningException - if reasoning failed.

getRangeOnPropertyForClass

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

Specified by:
getRangeOnPropertyForClass in interface OntologyRepository
Parameters:
className - the name of the class
propertyName - the name of the property
Returns:
the name of the class defining the range
Throws:
OntologyRepository.ReasoningException - if reasoning failed.

getUltimateOntologyTypesOfIndividual

public java.util.Set<java.lang.String> getUltimateOntologyTypesOfIndividual(java.lang.String individualName)
                                                                     throws UnknownConceptException
Description copied from interface: OntologyRepository
Finds the ultimate Ontology type of the provided individual, from the ontologies explicitly loaded into repository

Specified by:
getUltimateOntologyTypesOfIndividual in interface OntologyRepository
Parameters:
individualName - the name of the individual
Returns:
the vector of names of the Ontology classes being the most narrow ones for the given individual
Throws:
UnknownConceptException

getInstancesOf

public java.util.Set<java.lang.String> getInstancesOf(java.lang.String conceptName)
                                               throws UnknownConceptException
Description copied from interface: OntologyRepository
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 OntologyRepository
Parameters:
conceptName - The name of the concept in the Jena format
Returns:
Set of instance ids in the Jena format
Throws:
UnknownConceptException - if forActor is unknown for the ontology repository

getSuperClassesOf

public java.util.Set<java.lang.String> getSuperClassesOf(java.lang.String className)
                                                  throws UnknownConceptException
Description copied from interface: OntologyRepository
Get set of superclasses of the given class.

Specified by:
getSuperClassesOf in interface OntologyRepository
Parameters:
className - The name of the class in Jena format
Returns:
Set of superclasses names in Jena format
Throws:
UnknownConceptException - if className is unknown for the ontology repository

getSubClassesOf

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

Specified by:
getSubClassesOf in interface OntologyRepository
Parameters:
className - The name of the class in Jena format
Returns:
Set of subclasses names in Jena format
Throws:
UnknownConceptException - if className is unknown for the ontology repository

getImmediateSubClassesOf

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

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

getSuperPropertiesOf

public java.util.Set<java.lang.String> getSuperPropertiesOf(java.lang.String propertyName)
                                                     throws UnknownConceptException
Description copied from interface: OntologyRepository
Get set of super properties of the given property.

Specified by:
getSuperPropertiesOf in interface OntologyRepository
Parameters:
propertyName - The name of the property in Jena format
Returns:
Set of super properties names in Jena format
Throws:
UnknownConceptException

getSubPropertiesOf

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

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

getClassesDefInNamespace

public java.util.Set<java.lang.String> getClassesDefInNamespace(java.lang.String namespaceName)
                                                         throws UnknownNamespaceException
Description copied from interface: OntologyRepository
Get set of classes defined in the given namespace.

Specified by:
getClassesDefInNamespace in interface OntologyRepository
Parameters:
namespaceName - The name of the namespace in the Jena format
Returns:
Set of classes names in the Jena format
Throws:
UnknownNamespaceException - if namespaceName is unknown for the ontology repository

getPropertiesDefInNamespace

public java.util.Set<java.lang.String> getPropertiesDefInNamespace(java.lang.String namespaceName)
                                                            throws UnknownNamespaceException
Description copied from interface: OntologyRepository
Get set of properties defined in the given namespace.

Specified by:
getPropertiesDefInNamespace in interface OntologyRepository
Parameters:
namespaceName - The name of the namespace in the Jena format
Returns:
Set of properties names in the Jena format
Throws:
UnknownNamespaceException - if namespaceName is unknown for the ontology repository

getInstancesDefInNamespace

public java.util.Set<java.lang.String> getInstancesDefInNamespace(java.lang.String namespaceName)
                                                           throws UnknownNamespaceException
Description copied from interface: OntologyRepository
Get set of instances defined in the given namespace.

Specified by:
getInstancesDefInNamespace in interface OntologyRepository
Parameters:
namespaceName - The name of the namespace in the Jena format
Returns:
Set of instances names in the Jena format
Throws:
UnknownNamespaceException - if namespaceName is unknown for the ontology repository

getNamspacesImportedByNamespace

public java.util.Set<java.lang.String> getNamspacesImportedByNamespace(java.lang.String namespaceName)
                                                                throws UnknownNamespaceException
Description copied from interface: OntologyRepository
Get set of namespaces imported by the given namespace.

Specified by:
getNamspacesImportedByNamespace in interface OntologyRepository
Parameters:
namespaceName - The name of the namespace in the Jena format
Returns:
Set of namespaces names in the Jena format
Throws:
UnknownNamespaceException - if namespaceName is unknown for the ontology repository

getOntologyDefinitionForConcept

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

Specified by:
getOntologyDefinitionForConcept in interface OntologyRepository
Parameters:
conceptName - The name of the namespace in the Jena format
Returns:
Set of ontology definition url potentially matching the search concept