Class RDFServiceJena
- java.lang.Object
-
- edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceImpl
-
- edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.RDFServiceJena
-
- All Implemented Interfaces:
RDFService
- Direct Known Subclasses:
RDFServiceModel,RDFServiceSDB,RDFServiceTDB
public abstract class RDFServiceJena extends RDFServiceImpl implements RDFService
-
-
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 Modifier and Type Field Description protected List<String>graphURIsprotected booleanisRebuildGraphURICacheRunningprotected booleanrebuildGraphURICache-
Fields inherited from class edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceImpl
defaultWriteGraphURI, registeredJenaListeners, registeredListeners
-
-
Constructor Summary
Constructors Constructor Description RDFServiceJena()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidapplyChangeSetToModel(ChangeSet changeSet, org.apache.jena.query.Dataset dataset)abstract 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 org.apache.jena.query.QueryExecutioncreateQueryExecution(String queryString, org.apache.jena.query.Query q, org.apache.jena.query.Dataset d)protected abstract DatasetWrappergetDatasetWrapper()voidgetGraphMetadata()To be determined.List<String>getGraphURIs()Returns 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)VitroRequestgetVitroRequest()protected voidinsureThatInputStreamsAreResettable(ChangeSet changeSet)booleanisEquivalentGraph(String graphURI, InputStream serializedGraph, RDFService.ModelSerializationFormat serializationFormat)The basic version.booleanisEquivalentGraph(String graphURI, org.apache.jena.rdf.model.Model graph)The basic version.protected voidnotifyListenersOfPostChangeEvents(ChangeSet changeSet)protected voidnotifyListenersOfPreChangeEvents(ChangeSet changeSet)protected voidoperateOnModel(org.apache.jena.rdf.model.Model model, ModelChange modelChange)booleanpreferPreciseOptionals()protected voidrebuildGraphUris()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.voidsetVitroRequest(VitroRequest vitroRequest)UQAM-Bug-Correction Useful among other things to transport the linguistic context in the servicebooleansparqlAskQuery(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.RDFServiceImpl
createQuery, getDefaultWriteGraphURI, getRegisteredJenaModelChangedListeners, getRegisteredListeners, getSerializationFormatString, isPreconditionSatisfied, manufactureChangeSet, newIndividual, newIndividual, notifyListeners, notifyListenersOfChanges, notifyListenersOfEvent, pyString, registerJenaModelChangedListener, registerListener, separateStatementsWithBlankNodes, sparqlNode, sparqlNodeUpdate, sparqlSelectQueryHasResults, sparqlTriple, toString, unregisterJenaModelChangedListener, unregisterListener
-
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
-
-
-
-
Method Detail
-
getDatasetWrapper
protected abstract DatasetWrapper getDatasetWrapper()
-
changeSetUpdate
public abstract 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- Parameters:
changeSet- - a set of changes to be performed on the RDF store.- Returns:
- boolean - indicates whether the precondition was satisfied
- Throws:
RDFServiceException
-
notifyListenersOfPreChangeEvents
protected void notifyListenersOfPreChangeEvents(ChangeSet changeSet)
-
insureThatInputStreamsAreResettable
protected void insureThatInputStreamsAreResettable(ChangeSet changeSet) throws IOException
- Throws:
IOException
-
applyChangeSetToModel
protected void applyChangeSetToModel(ChangeSet changeSet, org.apache.jena.query.Dataset dataset)
-
notifyListenersOfPostChangeEvents
protected void notifyListenersOfPostChangeEvents(ChangeSet changeSet)
-
operateOnModel
protected void operateOnModel(org.apache.jena.rdf.model.Model model, ModelChange modelChange)
-
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- 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- 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- 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
TODO Is there a way to accomplish this without buffering the entire result?- Specified by:
sparqlSelectQueryin interfaceRDFService- 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- 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- 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 interface:RDFServiceReturns a list of all the graph URIs in the RDF store.- Specified by:
getGraphURIsin interfaceRDFService- 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
-
rebuildGraphUris
protected void rebuildGraphUris()
-
getGraphMetadata
public void getGraphMetadata() throws RDFServiceExceptionDescription copied from interface:RDFServiceTo be determined. This is a place holder and is not implemented in current implementations.- Specified by:
getGraphMetadatain interfaceRDFService- 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- 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- 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
The basic version. Parse the model from the file, read the model from the tripleStore, and ask whether they are isomorphic.- Specified by:
isEquivalentGraphin interfaceRDFService- 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
The basic version. Parse the model from the file, read the model from the tripleStore, and ask whether they are isomorphic.- Specified by:
isEquivalentGraphin interfaceRDFService- 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 classRDFServiceImpl- 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 classRDFServiceImpl- Throws:
RDFServiceException
-
preferPreciseOptionals
public boolean preferPreciseOptionals()
- Specified by:
preferPreciseOptionalsin interfaceRDFService
-
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
-
createQueryExecution
protected org.apache.jena.query.QueryExecution createQueryExecution(String queryString, org.apache.jena.query.Query q, org.apache.jena.query.Dataset d)
-
setVitroRequest
public void setVitroRequest(VitroRequest vitroRequest)
Description copied from interface:RDFServiceUQAM-Bug-Correction Useful among other things to transport the linguistic context in the service- Specified by:
setVitroRequestin interfaceRDFService- Overrides:
setVitroRequestin classRDFServiceImpl
-
getVitroRequest
public VitroRequest getVitroRequest()
- Specified by:
getVitroRequestin interfaceRDFService- Overrides:
getVitroRequestin classRDFServiceImpl
-
-