com.hp.hpl.jena.reasoner.dig
Class DIGAdapter

java.lang.Object
  extended by com.hp.hpl.jena.reasoner.dig.DIGAdapter

public class DIGAdapter
extends Object

An adapter class that mediates between a Jena InfGraph and a DIG reasoner process.

Version:
CVS $Id: DIGAdapter.java,v 1.18 2004/12/07 09:56:35 andy_seaborne Exp $
Author:
Ian Dickinson, HP Labs (email)

Field Summary
static String ANON_MARKER
          Mark a bNode identifier
static List KNOWN_CONCEPTS
          Well known concept URI's
static DIGProfile RACER_17_PROFILE
          DIG profile for 1.7
static List XSD_INT_TYPES
          Well known integer type URI's, these we will translate into DIG integer attributes
 
Constructor Summary
DIGAdapter(OntModelSpec spec, Graph source)
          Construct a DIG adapter for the given source data graph, which is encoding an ontology in a language represented by the given model spec.
DIGAdapter(OntModelSpec spec, Graph source, DIGConnection connection, Model axioms)
          Construct a DIG adapter for the given source data graph, which is encoding an ontology in a language represented by the given model spec.
 
Method Summary
 void addClassDescription(Element elem, Node node)
          Add a DIG reference to the class identifed in the source graph by the given Jena graph Node to the given XML element.
 void addClassDescription(Element elem, Node node, Model sourceData)
          Add a DIG reference to the class identifed in the source graph by the given Jena graph Node to the given XML element.
 void addClassDescription(Element elem, Resource res, Model sourceData)
          Add a DIG reference to the class identifed in the source graph by the given Jena resource to the given XML element.
 void close()
          Close this adapter, and release the connector to the external DIG KB.
 Element createQueryElement(Document query, String elemName)
          Create a new element to represent a query, adding to it a unique query ID.
 ExtendedIterator find(TriplePattern pattern)
          Basic pattern lookup interface - answer an iterator over the triples matching the given pattern.
 ExtendedIterator find(TriplePattern pattern, Model premises)
          Basic pattern lookup interface - answer an iterator over the triples matching the given (S,P,O) pattern, given also some premises for the query.
 DIGConnection getConnection()
          Answer this adapter's connection to the database.
 DIGIdentifier getDigIdentifier()
          Answer the DIG identification structure we obtain by querying the attached reasoner.
 Graph getGraph()
          Answer the graph of local (source) data.
 String getNodeID(Node n)
          Answer an identifier for a node, named or anon
 Profile getOntLanguage()
          Answer the ontology language profile we're assuming in this reasoner.
 DIGProfile getProfile()
          Answer the DIG profile for the DIG interface this reasoner is attached to.
 DIGQueryTranslator getQueryTranslator(TriplePattern pattern, Model premises)
          Answer the query translator that matches the given pattern, if any
 Iterator getRecentWarnings()
          Answer an iterator over any recent warnings returned from from the remote DIG reasoner.
 String getResourceID(Resource r)
          Answer an identifier for a resource, named or bNode
 OntModelSpec getSourceSpecification()
          Answer the ontology language specification for the source model underlying this DIG adapter.
 boolean isConcept(Node node, Model premises)
          Answer true if the given node corresponds to one of the concepts known to the DIG reasoner.
 boolean isIndividual(Node node)
          Answer true if the given node corresponds to one of the individuals known to the DIG reasoner.
 boolean isRole(Node node, Model premises)
          Answer true if the given node corresponds to one of the roles known to the DIG reasoner.
 void resetKB()
          Clear the old contents of the DIG knowledge base
 void setProfile(DIGProfile profile)
          Set the profile specifying the variable parts of the DIG profile that are being used in this instance.
 Document translateKbToDig()
          Answer an XML document that contains the DIG translation of the local graph, wrapped as a tell verb
 boolean uploadKB()
          Upload the entire contents of the local knowledge base (OWL/DAML model) to the DIG reasoner, using a single large TELL verb.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RACER_17_PROFILE

public static final DIGProfile RACER_17_PROFILE
DIG profile for 1.7


ANON_MARKER

public static final String ANON_MARKER
Mark a bNode identifier

See Also:
Constant Field Values

KNOWN_CONCEPTS

public static final List KNOWN_CONCEPTS
Well known concept URI's


XSD_INT_TYPES

public static final List XSD_INT_TYPES
Well known integer type URI's, these we will translate into DIG integer attributes

Constructor Detail

DIGAdapter

public DIGAdapter(OntModelSpec spec,
                  Graph source)

Construct a DIG adapter for the given source data graph, which is encoding an ontology in a language represented by the given model spec. Allocates a new DIG connection using the default connection URL (http://localhost:8081).

Parameters:
spec - An ont model spec encoding the ontology language of the source graph
source - The graph that contains the source data on which the DIG reasoner will operate

DIGAdapter

public DIGAdapter(OntModelSpec spec,
                  Graph source,
                  DIGConnection connection,
                  Model axioms)

Construct a DIG adapter for the given source data graph, which is encoding an ontology in a language represented by the given model spec.

Parameters:
spec - An ont model spec encoding the ontology language of the source graph
source - The graph that contains the source data on which the DIG reasoner will operate
connection - A pre-configured DIG connection to use to communicate with the external reasoner
axioms - A model containing axioms appropriate to the ontology language this adapter is processing. May be null.
Method Detail

getProfile

public DIGProfile getProfile()

Answer the DIG profile for the DIG interface this reasoner is attached to.

Returns:
A profile detailing the parameters of the DIG variant this reasoner is interacting with.

setProfile

public void setProfile(DIGProfile profile)

Set the profile specifying the variable parts of the DIG profile that are being used in this instance.

Parameters:
profile - The new DIG profile

getOntLanguage

public Profile getOntLanguage()

Answer the ontology language profile we're assuming in this reasoner.

Returns:
The ontology language via the language profile

getDigIdentifier

public DIGIdentifier getDigIdentifier()

Answer the DIG identification structure we obtain by querying the attached reasoner.

Returns:
An object containing the results of querying the reasoner for its identity and capabilities

uploadKB

public boolean uploadKB()

Upload the entire contents of the local knowledge base (OWL/DAML model) to the DIG reasoner, using a single large TELL verb.

Returns:
True if the ontology model was uploaded to DIG without any warnings. Recent warnings are available via getRecentWarnings()
Throws:
DigReasonerException - If the upload fails for any reason. The error message from the DIG reasoner will be returned.

getRecentWarnings

public Iterator getRecentWarnings()

Answer an iterator over any recent warnings returned from from the remote DIG reasoner.

Returns:
An iterator over any warnings; if there are no warnings the return value will be an iterator that returns hasNext() = false.

translateKbToDig

public Document translateKbToDig()

Answer an XML document that contains the DIG translation of the local graph, wrapped as a tell verb

Returns:
An XML document containing the tell verb

resetKB

public void resetKB()

Clear the old contents of the DIG knowledge base


getConnection

public DIGConnection getConnection()

Answer this adapter's connection to the database.

Returns:
The DIG connector this adapter is using, or null if the connection has been closed.

close

public void close()

Close this adapter, and release the connector to the external DIG KB.


find

public ExtendedIterator find(TriplePattern pattern)

Basic pattern lookup interface - answer an iterator over the triples matching the given pattern. Where possible, this query will first be given to the external reasoner, with the local graph used to generate supplemental bindings.

Parameters:
pattern - a TriplePattern to be matched against the data
Returns:
An ExtendedIterator over all Triples in the data set that match the pattern

find

public ExtendedIterator find(TriplePattern pattern,
                             Model premises)

Basic pattern lookup interface - answer an iterator over the triples matching the given (S,P,O) pattern, given also some premises for the query. Where possible, this query will first be given to the external reasoner, with the local graph used to generate supplemental bindings.

Parameters:
pattern - a TriplePattern to be matched against the data
premises - A model containing additional premises for the find query, typically used to allow the subject and/or object to be an expression rather than just a simple node
Returns:
An ExtendedIterator over all Triples in the data set that match the pattern

getQueryTranslator

public DIGQueryTranslator getQueryTranslator(TriplePattern pattern,
                                             Model premises)

Answer the query translator that matches the given pattern, if any

Parameters:
pattern - The triple pattern that has been received
premises - A model containing the premises to a query (e.g. a class expression)
Returns:
A DIG translator that can translate this pattern to a DIG query, or null if no matches.

getGraph

public Graph getGraph()

Answer the graph of local (source) data.

Returns:
The graph containing the local source data.

getResourceID

public String getResourceID(Resource r)

Answer an identifier for a resource, named or bNode

Parameters:
r - A resource
Returns:
A unique identifier for the resource as a string, which will either be the resource URI for named resources, or a unique ID string for bNodes

getNodeID

public String getNodeID(Node n)

Answer an identifier for a node, named or anon

Parameters:
n - An RDF node
Returns:
A unique identifier for the node as a string, which will either be the resource URI for named nodes, or a unique ID string for bNodes

addClassDescription

public void addClassDescription(Element elem,
                                Node node)

Add a DIG reference to the class identifed in the source graph by the given Jena graph Node to the given XML element. If the class is a named class, this will be a <catom> element, otherwise it will be a class description axiom. Assumes that the instance variable m_sourceData provides the statements that further define the class if it is a description not a name.

Parameters:
elem - The parent XML element to which the class description will be attached
node - An RDF graph node representing a class we wish to describe.

addClassDescription

public void addClassDescription(Element elem,
                                Node node,
                                Model sourceData)

Add a DIG reference to the class identifed in the source graph by the given Jena graph Node to the given XML element. If the class is a named class, this will be a <catom> element, otherwise it will be a class description axiom.

Parameters:
elem - The parent XML element to which the class description will be attached
node - An RDF graph node representing a class we wish to describe.
sourceData - A model containing the statements about the given class description resource

addClassDescription

public void addClassDescription(Element elem,
                                Resource res,
                                Model sourceData)

Add a DIG reference to the class identifed in the source graph by the given Jena resource to the given XML element. If the class is a named class, this will be a <catom> element, otherwise it will be a class description axiom.

Parameters:
elem - The parent XML element to which the class description will be attached
res - An RDF resource representing a class we wish to describe.
sourceData - A model containing the statements about the given class description resource

isIndividual

public boolean isIndividual(Node node)

Answer true if the given node corresponds to one of the individuals known to the DIG reasoner.

Parameters:
node - A node to test
Returns:
True if node is a known individual

isRole

public boolean isRole(Node node,
                      Model premises)

Answer true if the given node corresponds to one of the roles known to the DIG reasoner.

Parameters:
node - A node to test
premises - A model defining premises that may encode more information about node, or may be null
Returns:
True if node is a known role

isConcept

public boolean isConcept(Node node,
                         Model premises)

Answer true if the given node corresponds to one of the concepts known to the DIG reasoner.

Parameters:
node - A node to test
premises - A model defining premises that may encode more information about node, or may be null
Returns:
True if node is a known concept

getSourceSpecification

public OntModelSpec getSourceSpecification()

Answer the ontology language specification for the source model underlying this DIG adapter.

Returns:
The ontology model spec

createQueryElement

public Element createQueryElement(Document query,
                                  String elemName)

Create a new element to represent a query, adding to it a unique query ID.

Parameters:
query - The query document
elemName - The string name of the query element
Returns:
The new query element


Copyright © 2000, 2001, 2002, 2003, 2004 Hewlett-Packard Development Company, LP