Interface RDFService
-
- All Known Implementing Classes:
LanguageFilteringRDFService,LoggingRDFService,RDFServiceFactorySingle.UnclosableRDFService,RDFServiceImpl,RDFServiceJena,RDFServiceModel,RDFServiceSDB,RDFServiceSparql,RDFServiceSparqlHttp,RDFServiceTDB,RDFServiceVirtuoso,SameAsFilteringRDFServiceFactory.SameAsFilteringRDFService
public interface RDFServiceInterface for API to write, read, and update Vitro's RDF store, with support to allow listening, logging and auditing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classRDFService.ModelSerializationFormatstatic classRDFService.ResultFormatstatic classRDFService.SPARQLQueryType
-
Method Summary
All Methods Instance Methods Abstract 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)StringgetDefaultWriteGraphURI()Returns the URI of the default write graphvoidgetGraphMetadata()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()booleanisEquivalentGraph(String graphURI, InputStream serializedGraph, RDFService.ModelSerializationFormat serializationFormat)Tests to see whether the supplied serialization is equivalent to the named graph, as it exists in the store.booleanisEquivalentGraph(String graphURI, org.apache.jena.rdf.model.Model graph)Tests to see whether the supplied serialization is equivalent to the named graph, as it exists in the store.ChangeSetmanufactureChangeSet()Creates a ChangeSet objectvoidnewIndividual(String individualURI, String individualTypeURI)If the given individual already exists in the default write graph, throws an RDFServiceException, otherwise adds one type assertion to the default write graph.voidnewIndividual(String individualURI, String individualTypeURI, String graphURI)If the given individual already exists in the given graph, throws an RDFServiceException, otherwise adds one type assertion to the given graph.booleanpreferPreciseOptionals()voidregisterJenaModelChangedListener(org.apache.jena.rdf.model.ModelChangedListener changeListener)Registers a Jena listener to listen to changes in any graph in the RDF store.voidregisterListener(ChangeListener changeListener)Registers a listener to listen to changes in any graph in the RDF store.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)Performs a SPARQL select query against the knowledge base.voidsparqlSelectQuery(String query, ResultSetConsumer consumer)Performs a SPARQL select query against the knowledge base.voidunregisterJenaModelChangedListener(org.apache.jena.rdf.model.ModelChangedListener changeListener)Unregisters a Jena listener from listening to changes in any graph in the RDF storevoidunregisterListener(ChangeListener changeListener)Unregisters a listener from listening to changes in any graph in the RDF store
-
-
-
Method Detail
-
changeSetUpdate
boolean changeSetUpdate(ChangeSet changeSet) throws RDFServiceException
Performs 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.- Parameters:
changeSet- - a set of changes to be performed on the RDF store.- Returns:
- boolean - indicates whether the precondition was satisfied
- Throws:
RDFServiceException
-
newIndividual
void newIndividual(String individualURI, String individualTypeURI) throws RDFServiceException
If the given individual already exists in the default write graph, throws an RDFServiceException, otherwise adds one type assertion to the default write graph.- Parameters:
individualURI- - URI of the individual to be addedindividualTypeURI- - URI of the type for the individual- Throws:
RDFServiceException
-
newIndividual
void newIndividual(String individualURI, String individualTypeURI, String graphURI) throws RDFServiceException
If the given individual already exists in the given graph, throws an RDFServiceException, otherwise adds one type assertion to the given graph.- Parameters:
individualURI- - URI of the individual to be addedindividualTypeURI- - URI of the type for the individualgraphURI- - URI of the graph to which to add the individual- Throws:
RDFServiceException
-
sparqlConstructQuery
InputStream sparqlConstructQuery(String query, RDFService.ModelSerializationFormat resultFormat) throws RDFServiceException
Performs 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.- 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
void sparqlConstructQuery(String query, org.apache.jena.rdf.model.Model model) throws RDFServiceException
Performs 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.- Parameters:
query- - the SPARQL query to be executed against the RDF storemodel- - the Model to add the statements to- Throws:
RDFServiceException
-
sparqlDescribeQuery
InputStream sparqlDescribeQuery(String query, RDFService.ModelSerializationFormat resultFormat) throws RDFServiceException
Performs 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.- 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
InputStream sparqlSelectQuery(String query, RDFService.ResultFormat resultFormat) throws RDFServiceException
Performs 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.- 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
void sparqlSelectQuery(String query, ResultSetConsumer consumer) throws RDFServiceException
Performs 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.- Parameters:
query- - the SPARQL query to be executed against the RDF storeconsumer- - the class to consume the results of the query- Throws:
RDFServiceException
-
sparqlAskQuery
boolean sparqlAskQuery(String query) throws RDFServiceException
Performs 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.- 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
List<String> getGraphURIs() throws RDFServiceException
Returns a list of all the graph URIs in the RDF store.- 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
-
getGraphMetadata
void getGraphMetadata() throws RDFServiceExceptionTo be determined. This is a place holder and is not implemented in current implementations.- Throws:
RDFServiceException
-
getDefaultWriteGraphURI
String getDefaultWriteGraphURI() throws RDFServiceException
Returns the URI of the default write graph- Returns:
- String URI of default write graph. Returns null if no default write graph has been set.
- Throws:
RDFServiceException
-
serializeAll
void serializeAll(OutputStream outputStream) throws RDFServiceException
Serializes 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.- Parameters:
outputStream- - receives the serialized result.- Throws:
RDFServiceException
-
serializeGraph
void serializeGraph(String graphURI, OutputStream outputStream) throws RDFServiceException
Serializes 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.- Parameters:
graphURI- - the URI of the desired graph. May not be null.outputStream- - receives the serialized result.- Throws:
RDFServiceException
-
isEquivalentGraph
boolean isEquivalentGraph(String graphURI, InputStream serializedGraph, RDFService.ModelSerializationFormat serializationFormat) throws RDFServiceException
Tests to see whether the supplied serialization is equivalent to the named graph, as it exists in the store. Equivalence means that if this serialization were written to the store, the resulting graph would be isomorphic to the existing named graph.- 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
boolean isEquivalentGraph(String graphURI, org.apache.jena.rdf.model.Model graph) throws RDFServiceException
Tests to see whether the supplied serialization is equivalent to the named graph, as it exists in the store. Equivalence means that if this serialization were written to the store, the resulting graph would be isomorphic to the existing named graph.- 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
-
registerJenaModelChangedListener
void registerJenaModelChangedListener(org.apache.jena.rdf.model.ModelChangedListener changeListener) throws RDFServiceExceptionRegisters a Jena listener to listen to changes in any graph in the RDF store.- Parameters:
changeListener- - the change listener- Throws:
RDFServiceException
-
unregisterJenaModelChangedListener
void unregisterJenaModelChangedListener(org.apache.jena.rdf.model.ModelChangedListener changeListener) throws RDFServiceExceptionUnregisters a Jena listener from listening to changes in any graph in the RDF store- Parameters:
changeListener- - the change listener- Throws:
RDFServiceException
-
registerListener
void registerListener(ChangeListener changeListener) throws RDFServiceException
Registers a listener to listen to changes in any graph in the RDF store.- Parameters:
changeListener- - the change listener- Throws:
RDFServiceException
-
unregisterListener
void unregisterListener(ChangeListener changeListener) throws RDFServiceException
Unregisters a listener from listening to changes in any graph in the RDF store- Parameters:
changeListener- - the change listener- Throws:
RDFServiceException
-
manufactureChangeSet
ChangeSet manufactureChangeSet()
Creates a ChangeSet object- Returns:
- ChangeSet an empty ChangeSet object
-
countTriples
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- Throws:
RDFServiceException
-
getTriples
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- Throws:
RDFServiceException
-
preferPreciseOptionals
boolean preferPreciseOptionals()
-
close
void close()
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.
-
setVitroRequest
void setVitroRequest(VitroRequest vitroRequest)
UQAM-Bug-Correction Useful among other things to transport the linguistic context in the service- Parameters:
vitroRequest-
-
getVitroRequest
VitroRequest getVitroRequest()
-
-