Class RDFServiceTDB
- java.lang.Object
-
- edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceImpl
-
- edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.RDFServiceJena
-
- edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.tdb.RDFServiceTDB
-
- All Implemented Interfaces:
RDFService
public class RDFServiceTDB extends RDFServiceJena
An implementation that is based on Jena TDB.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService
RDFService.ModelSerializationFormat, RDFService.ResultFormat, RDFService.SPARQLQueryType
-
-
Field Summary
-
Fields inherited from class edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceImpl
defaultWriteGraphURI, graphURIs, isRebuildGraphURICacheRunning, rebuildGraphURICache, registeredJenaListeners, registeredListeners
-
-
Constructor Summary
Constructors Constructor Description RDFServiceTDB(String directoryPath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanchangeSetUpdate(ChangeSet changeSet)Performs a series of additions to and or removals from specified graphs in the RDF store.voidclose()Frees any resources held by this RDFService object The implementation of this method should be idempotent so that multiple invocations do not cause an error.longcountTriples(org.apache.jena.rdf.model.RDFNode subject, org.apache.jena.rdf.model.RDFNode predicate, org.apache.jena.rdf.model.RDFNode object)protected DatasetWrappergetDatasetWrapper()List<String>getGraphURIs()Get a list of all the graph URIs in the RDF store.org.apache.jena.rdf.model.ModelgetTriples(org.apache.jena.rdf.model.RDFNode subject, org.apache.jena.rdf.model.RDFNode predicate, org.apache.jena.rdf.model.RDFNode object, long limit, long offset)booleanisEquivalentGraph(String graphURI, InputStream serializedGraph, RDFService.ModelSerializationFormat serializationFormat)TDB has a bug: if given a literal of type xsd:nonNegativeInteger, it stores a literal of type xsd:integer.booleanisEquivalentGraph(String graphURI, org.apache.jena.rdf.model.Model graph)TDB has a bug: if given a literal of type xsd:nonNegativeInteger, it stores a literal of type xsd:integer.booleanpreferPreciseOptionals()voidserializeAll(OutputStream outputStream)Serializes the union of all named and unnamed graphs in the store to the supplied OutputStream, in N-Quads format.voidserializeGraph(String graphURI, OutputStream outputStream)Serializes the contents of the named graph to the supplied OutputStream, in N-Triples format.booleansparqlAskQuery(String query)Performs a SPARQL ASK query against the knowledge base.InputStreamsparqlConstructQuery(String query, RDFService.ModelSerializationFormat resultFormat)Performs a SPARQL construct query against the knowledge base.voidsparqlConstructQuery(String query, org.apache.jena.rdf.model.Model model)Performs a SPARQL construct query against the knowledge base.InputStreamsparqlDescribeQuery(String query, RDFService.ModelSerializationFormat resultFormat)Performs a SPARQL describe query against the knowledge base.InputStreamsparqlSelectQuery(String query, RDFService.ResultFormat resultFormat)TODO Is there a way to accomplish this without buffering the entire result?voidsparqlSelectQuery(String query, ResultSetConsumer consumer)Performs a SPARQL select query against the knowledge base.-
Methods inherited from class edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.RDFServiceJena
applyChangeSetToModel, createQueryExecution, getGraphMetadata, getVitroRequest, insureThatInputStreamsAreResettable, notifyListenersOfPostChangeEvents, notifyListenersOfPreChangeEvents, operateOnModel, rebuildGraphUris, setVitroRequest
-
Methods inherited from class edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceImpl
createQuery, getDefaultWriteGraphURI, getRegisteredJenaModelChangedListeners, getRegisteredListeners, getSerializationFormatString, isPreconditionSatisfied, manufactureChangeSet, newIndividual, newIndividual, notifyListeners, notifyListenersOfChanges, notifyListenersOfEvent, pyString, registerJenaModelChangedListener, registerListener, separateStatementsWithBlankNodes, sparqlNode, sparqlNodeUpdate, sparqlSelectQueryHasResults, sparqlTriple, toString, unregisterJenaModelChangedListener, unregisterListener, updateGraphURIs
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService
getDefaultWriteGraphURI, manufactureChangeSet, newIndividual, newIndividual, registerJenaModelChangedListener, registerListener, unregisterJenaModelChangedListener, unregisterListener
-
-
-
-
Constructor Detail
-
RDFServiceTDB
public RDFServiceTDB(String directoryPath) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getDatasetWrapper
protected DatasetWrapper getDatasetWrapper()
- Specified by:
getDatasetWrapperin classRDFServiceJena
-
changeSetUpdate
public boolean changeSetUpdate(ChangeSet changeSet) throws RDFServiceException
Description copied from interface:RDFServicePerforms a series of additions to and or removals from specified graphs in the RDF store. preConditionSparql is executed against the union of all the graphs in the knowledge base before any updates are made. If the precondition query returns a non-empty result, no updates are made made.- Specified by:
changeSetUpdatein interfaceRDFService- Specified by:
changeSetUpdatein classRDFServiceJena- Parameters:
changeSet- - a set of changes to be performed on the RDF store.- Returns:
- boolean - indicates whether the precondition was satisfied
- Throws:
RDFServiceException
-
preferPreciseOptionals
public boolean preferPreciseOptionals()
- Specified by:
preferPreciseOptionalsin interfaceRDFService- Overrides:
preferPreciseOptionalsin classRDFServiceJena
-
close
public void close()
Description copied from interface:RDFServiceFrees any resources held by this RDFService object The implementation of this method should be idempotent so that multiple invocations do not cause an error.- Specified by:
closein interfaceRDFService- Overrides:
closein classRDFServiceJena
-
sparqlConstructQuery
public InputStream sparqlConstructQuery(String query, RDFService.ModelSerializationFormat resultFormat) throws RDFServiceException
Description copied from interface:RDFServicePerforms a SPARQL construct query against the knowledge base. The query may have an embedded graph identifier. If the query does not contain a graph identifier the query is executed against the union of all named and unnamed graphs in the store.- Specified by:
sparqlConstructQueryin interfaceRDFService- Overrides:
sparqlConstructQueryin classRDFServiceJena- Parameters:
query- - the SPARQL query to be executed against the RDF storeresultFormat- - type of serialization for RDF result of the SPARQL query- Returns:
- InputStream - the result of the query
- Throws:
RDFServiceException
-
sparqlConstructQuery
public void sparqlConstructQuery(String query, org.apache.jena.rdf.model.Model model) throws RDFServiceException
Description copied from interface:RDFServicePerforms a SPARQL construct query against the knowledge base. The query may have an embedded graph identifier. If the query does not contain a graph identifier the query is executed against the union of all named and unnamed graphs in the store.- Specified by:
sparqlConstructQueryin interfaceRDFService- Overrides:
sparqlConstructQueryin classRDFServiceJena- Parameters:
query- - the SPARQL query to be executed against the RDF storemodel- - the Model to add the statements to- Throws:
RDFServiceException
-
sparqlDescribeQuery
public InputStream sparqlDescribeQuery(String query, RDFService.ModelSerializationFormat resultFormat) throws RDFServiceException
Description copied from interface:RDFServicePerforms a SPARQL describe query against the knowledge base. The query may have an embedded graph identifier. If the query does not contain a graph identifier the query is executed against the union of all named and unnamed graphs in the store.- Specified by:
sparqlDescribeQueryin interfaceRDFService- Overrides:
sparqlDescribeQueryin classRDFServiceJena- Parameters:
query- - the SPARQL query to be executed against the RDF storeresultFormat- - type of serialization for RDF result of the SPARQL query- Returns:
- InputStream - the result of the query
- Throws:
RDFServiceException
-
sparqlSelectQuery
public InputStream sparqlSelectQuery(String query, RDFService.ResultFormat resultFormat) throws RDFServiceException
Description copied from class:RDFServiceJenaTODO Is there a way to accomplish this without buffering the entire result?- Specified by:
sparqlSelectQueryin interfaceRDFService- Overrides:
sparqlSelectQueryin classRDFServiceJena- Parameters:
query- - the SPARQL query to be executed against the RDF storeresultFormat- - format for the result of the Select query- Returns:
- InputStream - the result of the query
- Throws:
RDFServiceException
-
sparqlSelectQuery
public void sparqlSelectQuery(String query, ResultSetConsumer consumer) throws RDFServiceException
Description copied from interface:RDFServicePerforms a SPARQL select query against the knowledge base. The query may have an embedded graph identifier. If the query does not contain a graph identifier the query is executed against the union of all named and unnamed graphs in the store.- Specified by:
sparqlSelectQueryin interfaceRDFService- Overrides:
sparqlSelectQueryin classRDFServiceJena- Parameters:
query- - the SPARQL query to be executed against the RDF storeconsumer- - the class to consume the results of the query- Throws:
RDFServiceException
-
sparqlAskQuery
public boolean sparqlAskQuery(String query) throws RDFServiceException
Description copied from interface:RDFServicePerforms a SPARQL ASK query against the knowledge base. The query may have an embedded graph identifier. If the query does not contain a graph identifier the query is executed against the union of all named and unnamed graphs in the store.- Specified by:
sparqlAskQueryin interfaceRDFService- Overrides:
sparqlAskQueryin classRDFServiceJena- Parameters:
query- - the SPARQL ASK query to be executed against the RDF store- Returns:
- boolean - the result of the SPARQL ASK query
- Throws:
RDFServiceException
-
getGraphURIs
public List<String> getGraphURIs() throws RDFServiceException
Description copied from class:RDFServiceImplGet a list of all the graph URIs in the RDF store.- Specified by:
getGraphURIsin interfaceRDFService- Overrides:
getGraphURIsin classRDFServiceImpl- Returns:
- list of all the named graph URIs in the RDF store. Return an empty list of there no named graphs in the store.
- Throws:
RDFServiceException
-
serializeAll
public void serializeAll(OutputStream outputStream) throws RDFServiceException
Description copied from interface:RDFServiceSerializes the union of all named and unnamed graphs in the store to the supplied OutputStream, in N-Quads format. This method is designed for exporting data from VIVO, so any filters should be bypassed. If possible, this should be done without buffering in memory, so arbitrarily large graphs can be exported.- Specified by:
serializeAllin interfaceRDFService- Overrides:
serializeAllin classRDFServiceJena- Parameters:
outputStream- - receives the serialized result.- Throws:
RDFServiceException
-
serializeGraph
public void serializeGraph(String graphURI, OutputStream outputStream) throws RDFServiceException
Description copied from interface:RDFServiceSerializes the contents of the named graph to the supplied OutputStream, in N-Triples format. This method is designed for exporting data from VIVO, so any filters should be bypassed. If possible, this should be done without buffering in memory, so arbitrarily large graphs can be exported.- Specified by:
serializeGraphin interfaceRDFService- Overrides:
serializeGraphin classRDFServiceJena- Parameters:
graphURI- - the URI of the desired graph. May not be null.outputStream- - receives the serialized result.- Throws:
RDFServiceException
-
isEquivalentGraph
public boolean isEquivalentGraph(String graphURI, InputStream serializedGraph, RDFService.ModelSerializationFormat serializationFormat) throws RDFServiceException
TDB has a bug: if given a literal of type xsd:nonNegativeInteger, it stores a literal of type xsd:integer. To determine whether this serialized graph is equivalent to what's in TDB, we need to do the same.- Specified by:
isEquivalentGraphin interfaceRDFService- Overrides:
isEquivalentGraphin classRDFServiceJena- Parameters:
graphURI- - the URI of the graph to test against. May not be null.serializedGraph- - the contents to be compared with the existing graph. May not be null.serializationFormat- - May not be null.- Throws:
RDFServiceException
-
isEquivalentGraph
public boolean isEquivalentGraph(String graphURI, org.apache.jena.rdf.model.Model graph) throws RDFServiceException
TDB has a bug: if given a literal of type xsd:nonNegativeInteger, it stores a literal of type xsd:integer. To determine whether this serialized graph is equivalent to what's in TDB, we need to do the same.- Specified by:
isEquivalentGraphin interfaceRDFService- Overrides:
isEquivalentGraphin classRDFServiceJena- Parameters:
graphURI- - the URI of the graph to test against. May not be null.graph- - the contents to be compared with the existing graph. May not be null.- Throws:
RDFServiceException
-
countTriples
public long countTriples(org.apache.jena.rdf.model.RDFNode subject, org.apache.jena.rdf.model.RDFNode predicate, org.apache.jena.rdf.model.RDFNode object) throws RDFServiceException- Specified by:
countTriplesin interfaceRDFService- Overrides:
countTriplesin classRDFServiceJena- Throws:
RDFServiceException
-
getTriples
public org.apache.jena.rdf.model.Model getTriples(org.apache.jena.rdf.model.RDFNode subject, org.apache.jena.rdf.model.RDFNode predicate, org.apache.jena.rdf.model.RDFNode object, long limit, long offset) throws RDFServiceException- Specified by:
getTriplesin interfaceRDFService- Overrides:
getTriplesin classRDFServiceJena- Throws:
RDFServiceException
-
-