it.polito.elite.ontology
Class OWLOntologyWrapper

java.lang.Object
  extended by it.polito.elite.ontology.OntologyAbstraction
      extended by it.polito.elite.ontology.OWLOntologyWrapper

public class OWLOntologyWrapper
extends OntologyAbstraction


Field Summary
private  edu.stanford.smi.protegex.owl.model.OWLModel owlModel
           
private  java.util.Hashtable<java.lang.String,RelationType> RelationsCache
           
 
Fields inherited from class it.polito.elite.ontology.OntologyAbstraction
log
 
Constructor Summary
OWLOntologyWrapper(edu.stanford.smi.protege.model.KnowledgeBase kb)
           
 
Method Summary
 void addAnnotationProperty(java.lang.String property, boolean isObjectProperty)
           
 boolean addAnnotationProperty4URI(java.lang.String uri, java.lang.String property, java.lang.Object value)
          Adds an annotation property of type property, having object as value, referred to a given concept (OWL class)
 void addImport(java.lang.String URI)
           
 void addNameSpace(java.lang.String prefix, java.lang.String namespace)
           
 boolean canQuery()
           
 void confirmLogicViewSupport()
           
 NodeTypeAbstraction createNodeTypeAbstraction(NodeTypesEnum t, java.lang.String expression)
          It is sufficient that it handles NamedClasses and NamedInstances
 java.util.HashSet<java.lang.String> getAllClasses(boolean listImportedClasses)
          Returns all the classes (concepts) in a knowldge base
 java.util.HashSet<java.lang.String> getAllInstances()
          A method for getting all the instances of a concept in the ontology (for a OWL model)
 java.util.Hashtable<java.lang.String,RelationType> getAllRelations(boolean listImported)
          Lists all the slots declared in a protege knowledge base, excluding the imported slots if listImported is true.
private  java.util.Hashtable<java.lang.String,RelationType> getAllRelationsOWL(boolean listImported)
           
 java.util.Hashtable<java.lang.String,java.lang.Object> getAnnotationProperties(java.lang.String resourceURI, boolean isNamedClass)
          A method that returns an hashtable containing all the annotations relative to the input class
 java.util.Hashtable<java.lang.String,java.util.HashSet<RelationData>> getDatatypeProperties(java.lang.String concept)
          A method that, given the name of a concept, provides as result a Hastable containing the couples datatype property, xsd type for each datatype property which has the given concept as domain.
 java.util.Hashtable<java.lang.String,java.util.HashSet<NodeTypeAbstraction>> getInstancesDatatypeProperties(java.lang.String instance)
          A method that, given the name of a concept, provides as result a Hastable containing the couples datatype property, value for each datatype property which has the given concept as domain.
 java.util.Hashtable<java.lang.String,java.util.HashSet<NodeTypeAbstraction>> getInstancesObjectProperties(java.lang.String instance)
          Returns an Hashtable containing for each instance "linked" to the instance i, a Set of objectProperties that start from i and reach the "linked" instance (usually such set is composed by only one objectProperty).
 java.util.HashSet<java.lang.String> getInstancesOfConcept(java.lang.String concept)
          A method for getting all the instances of a concept in the ontology (for a RDF/RDFS model)
 edu.stanford.smi.protegex.owl.model.OWLModel getModel()
           
 int getNumberOfSubClasses(java.lang.String clsName)
          A method that provides the number of direct subclasses for a given class (identified by its name)
 java.util.Hashtable<java.lang.String,java.util.HashSet<RelationData>> getObjectProperties(java.lang.String uri, boolean direct, boolean listImportedClass)
          Give the uri of a class, returns an hashtable of relations starting from the class together with an Hashset of endnodes for each relations (relationUri, EndNodes)
 NodeTypeAbstraction getPropertyRange(java.lang.String propertyURI)
           
 RelationType getRelationType(java.lang.String relURI)
          A method that tells if a relation is towards a literal
 java.util.Hashtable<java.lang.String,java.util.HashSet<NodeTypeAbstraction>> getRestrictions(java.lang.String clsURI)
          Retrieves restrictions specified for the concept identified by a given URI
 java.util.HashSet<java.lang.String> getRoots(boolean listImportedClasses)
          Lists all the root classes of the ontology (leaved here for backward compatibility)
 java.util.HashSet<java.lang.String> getSubClasses(java.lang.String clsName)
          A method for retrieving all the subclasses of a given class given its name
 java.util.HashSet<java.lang.String> getSuperClasses(java.lang.String clsName)
          A method for retrieving all the superclasses of a given class given its name
 boolean hasInstances(java.lang.String concept)
          A method for checking if a given concept c has some instances or not
 boolean isPrefixDefined(java.lang.String prefix)
           
 boolean isURI_imported(java.lang.String URI)
           
 java.util.HashSet<NodeTypeAbstraction> query(java.lang.String queryString, QueryLanguageEnum lang, int queryType)
           
 boolean removeAnnotationProperty4URI(java.lang.String clsURI, java.lang.String property, java.lang.Object value)
          Remove an annotation property of type property, having object as value, referred to a given concept (OWL class)
 void saveOntology(java.lang.String pathFname)
           
 void setLogicalConstraints(java.lang.String clsURI, ConceptData data)
          Retrieves "logical" information about the concept and stores it in proper fields of the relative ConceptData: DifferentFrom, SameAs, Anonymous Superclasses (unions, intersections)
 void setLogicalConstraints(java.lang.String instanceURI, InstanceData data)
          Retrieves "logical" information about the concept and stores it in proper fields of the relative Instance Data
 
Methods inherited from class it.polito.elite.ontology.OntologyAbstraction
createOntologyAbstraction, setLoggingLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

owlModel

private edu.stanford.smi.protegex.owl.model.OWLModel owlModel

RelationsCache

private java.util.Hashtable<java.lang.String,RelationType> RelationsCache
Constructor Detail

OWLOntologyWrapper

public OWLOntologyWrapper(edu.stanford.smi.protege.model.KnowledgeBase kb)
Method Detail

addAnnotationProperty

public void addAnnotationProperty(java.lang.String property,
                                  boolean isObjectProperty)

addAnnotationProperty4URI

public boolean addAnnotationProperty4URI(java.lang.String uri,
                                         java.lang.String property,
                                         java.lang.Object value)
Adds an annotation property of type property, having object as value, referred to a given concept (OWL class)

Specified by:
addAnnotationProperty4URI in class OntologyAbstraction
Parameters:
uri - the URI of the concept
property - The name of the annotation property we want to add
value - The value of the annotation
Returns:
true on success, false if the operation fails

addImport

public void addImport(java.lang.String URI)

addNameSpace

public void addNameSpace(java.lang.String prefix,
                         java.lang.String namespace)

canQuery

public boolean canQuery()
Specified by:
canQuery in class OntologyAbstraction

confirmLogicViewSupport

public void confirmLogicViewSupport()
Specified by:
confirmLogicViewSupport in class OntologyAbstraction

createNodeTypeAbstraction

public NodeTypeAbstraction createNodeTypeAbstraction(NodeTypesEnum t,
                                                     java.lang.String expression)
Description copied from class: OntologyAbstraction
It is sufficient that it handles NamedClasses and NamedInstances

Specified by:
createNodeTypeAbstraction in class OntologyAbstraction
Parameters:
t - type
expression - the expression (at now the URI of concept/individual)
Returns:
NodeTypeAbstraction

getAllClasses

public java.util.HashSet<java.lang.String> getAllClasses(boolean listImportedClasses)
Returns all the classes (concepts) in a knowldge base

Specified by:
getAllClasses in class OntologyAbstraction
Parameters:
listImportedClasses - true if also imported classes should be shown
Returns:
a HashSet containing the names of all the classes in the knowledge base

getAllInstances

public java.util.HashSet<java.lang.String> getAllInstances()
A method for getting all the instances of a concept in the ontology (for a OWL model)

Specified by:
getAllInstances in class OntologyAbstraction
Returns:
the HashSet containing all the instances of a given ontology

getAllRelations

public java.util.Hashtable<java.lang.String,RelationType> getAllRelations(boolean listImported)
Lists all the slots declared in a protege knowledge base, excluding the imported slots if listImported is true.

Specified by:
getAllRelations in class OntologyAbstraction
Parameters:
listImported - true if slots coming from imported classes shall be shown
Returns:
an Hastable containing the name of the slots together with the eventual annotation properties of the slot

getAllRelationsOWL

private java.util.Hashtable<java.lang.String,RelationType> getAllRelationsOWL(boolean listImported)

getAnnotationProperties

public java.util.Hashtable<java.lang.String,java.lang.Object> getAnnotationProperties(java.lang.String resourceURI,
                                                                                      boolean isNamedClass)
A method that returns an hashtable containing all the annotations relative to the input class

Specified by:
getAnnotationProperties in class OntologyAbstraction
Parameters:
resourceURI - the class or propery we want to extract annotation properties from
Returns:
an Hashtable containing property name and value

getDatatypeProperties

public java.util.Hashtable<java.lang.String,java.util.HashSet<RelationData>> getDatatypeProperties(java.lang.String concept)
A method that, given the name of a concept, provides as result a Hastable containing the couples datatype property, xsd type for each datatype property which has the given concept as domain.

Specified by:
getDatatypeProperties in class OntologyAbstraction
Parameters:
concept -
Returns:
the hashtable of datatype properties for concept together with their xsd type

getInstancesDatatypeProperties

public java.util.Hashtable<java.lang.String,java.util.HashSet<NodeTypeAbstraction>> getInstancesDatatypeProperties(java.lang.String instance)
A method that, given the name of a concept, provides as result a Hastable containing the couples datatype property, value for each datatype property which has the given concept as domain.

Specified by:
getInstancesDatatypeProperties in class OntologyAbstraction
Parameters:
instance - The instance URI
Returns:
the hashtable of datatype properties for concept together with their xsd type

getInstancesObjectProperties

public java.util.Hashtable<java.lang.String,java.util.HashSet<NodeTypeAbstraction>> getInstancesObjectProperties(java.lang.String instance)
Returns an Hashtable containing for each instance "linked" to the instance i, a Set of objectProperties that start from i and reach the "linked" instance (usually such set is composed by only one objectProperty).

Specified by:
getInstancesObjectProperties in class OntologyAbstraction
Parameters:
instance - the instance i
Returns:
the hashtable of linked instances

getInstancesOfConcept

public java.util.HashSet<java.lang.String> getInstancesOfConcept(java.lang.String concept)
Description copied from class: OntologyAbstraction
A method for getting all the instances of a concept in the ontology (for a RDF/RDFS model)

Specified by:
getInstancesOfConcept in class OntologyAbstraction
Parameters:
concept - The concept URI
Returns:
the HashSet containing all the instances of a given concept

getModel

public edu.stanford.smi.protegex.owl.model.OWLModel getModel()

getNumberOfSubClasses

public int getNumberOfSubClasses(java.lang.String clsName)
A method that provides the number of direct subclasses for a given class (identified by its name)

Specified by:
getNumberOfSubClasses in class OntologyAbstraction
Parameters:
clsName - the name of the class
Returns:
the number of subclasses as an int

getObjectProperties

public java.util.Hashtable<java.lang.String,java.util.HashSet<RelationData>> getObjectProperties(java.lang.String uri,
                                                                                                 boolean direct,
                                                                                                 boolean listImportedClass)
Give the uri of a class, returns an hashtable of relations starting from the class together with an Hashset of endnodes for each relations (relationUri, EndNodes)

Specified by:
getObjectProperties in class OntologyAbstraction
Parameters:
uri - the uri of the starting class
direct - --direct relations only (currently ignored)
listImportedClass - -- show system classes or not (to be deprecated)
Returns:
(relationUri <Uri>, EndNodes <HashSet>)

getPropertyRange

public NodeTypeAbstraction getPropertyRange(java.lang.String propertyURI)
Specified by:
getPropertyRange in class OntologyAbstraction

getRelationType

public RelationType getRelationType(java.lang.String relURI)
Description copied from class: OntologyAbstraction
A method that tells if a relation is towards a literal

Specified by:
getRelationType in class OntologyAbstraction
Returns:
a RelationType

getRestrictions

public java.util.Hashtable<java.lang.String,java.util.HashSet<NodeTypeAbstraction>> getRestrictions(java.lang.String clsURI)
Description copied from class: OntologyAbstraction
Retrieves restrictions specified for the concept identified by a given URI

Specified by:
getRestrictions in class OntologyAbstraction
Parameters:
clsURI - The URI of the concept
Returns:
an HashSet of NodeTypeAbstraction Objects

getRoots

public java.util.HashSet<java.lang.String> getRoots(boolean listImportedClasses)
Lists all the root classes of the ontology (leaved here for backward compatibility)

Specified by:
getRoots in class OntologyAbstraction
Parameters:
listImportedClasses - true if also imported classes should be shown
Returns:
an Iterator over the names of all the root classes in the knowledge base

getSubClasses

public java.util.HashSet<java.lang.String> getSubClasses(java.lang.String clsName)
A method for retrieving all the subclasses of a given class given its name

Specified by:
getSubClasses in class OntologyAbstraction
Parameters:
clsName - the class name
Returns:
an Iterator <String> over the subclasses names

getSuperClasses

public java.util.HashSet<java.lang.String> getSuperClasses(java.lang.String clsName)
A method for retrieving all the superclasses of a given class given its name

Specified by:
getSuperClasses in class OntologyAbstraction
Parameters:
clsName - the class name
Returns:
an Iterator <String> over the superclasses names

hasInstances

public boolean hasInstances(java.lang.String concept)
A method for checking if a given concept c has some instances or not

Specified by:
hasInstances in class OntologyAbstraction
Parameters:
concept - the concept for which instances might exist
Returns:
true if it has some instances, false otherwise

isPrefixDefined

public boolean isPrefixDefined(java.lang.String prefix)

isURI_imported

public boolean isURI_imported(java.lang.String URI)

query

public java.util.HashSet<NodeTypeAbstraction> query(java.lang.String queryString,
                                                    QueryLanguageEnum lang,
                                                    int queryType)

removeAnnotationProperty4URI

public boolean removeAnnotationProperty4URI(java.lang.String clsURI,
                                            java.lang.String property,
                                            java.lang.Object value)
Remove an annotation property of type property, having object as value, referred to a given concept (OWL class)

Specified by:
removeAnnotationProperty4URI in class OntologyAbstraction
Parameters:
clsURI - the URI of the concept or the object property with the annotation
property - The name of the annotation property we want to remove
value - The value of the annotation
Returns:
true on success, false if the removal fails

saveOntology

public void saveOntology(java.lang.String pathFname)

setLogicalConstraints

public void setLogicalConstraints(java.lang.String clsURI,
                                  ConceptData data)
Retrieves "logical" information about the concept and stores it in proper fields of the relative ConceptData: DifferentFrom, SameAs, Anonymous Superclasses (unions, intersections)

Specified by:
setLogicalConstraints in class OntologyAbstraction
Parameters:
clsURI - the concept class name
data - the concept data

setLogicalConstraints

public void setLogicalConstraints(java.lang.String instanceURI,
                                  InstanceData data)
Retrieves "logical" information about the concept and stores it in proper fields of the relative Instance Data

Specified by:
setLogicalConstraints in class OntologyAbstraction
Parameters:
instanceURI - the instance name
data - the instance data