Class SharedStorageConnector
- All Implemented Interfaces:
Closeable,StatementExecutor,StorageConnector,Wrapper
- Direct Known Subclasses:
SnapshotStorageConnector
JenaOntoDriverProperties.READ_COMMITTED
connector strategy.
Adding statements to it actually adds them to the repository.
Note on transactions:
Starting a transaction on this connector also starts a write transaction on the underlying dataset. Commit then commits the transaction. Therefore, these transactions should be short. Reading can happen in parallel (as per Jena documentation).
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified statements to the specified context in the storage.voidbegin()Begins a transaction.voidclose()Closes this resource releasing any sub-resources it holds.voidcommit()Commits the current transaction.booleancontains(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value, Collection<String> contexts) Checks whether the specified context (named graph) contains any statements matching the specified criteria.executeAskQuery(org.apache.jena.query.Query query, Statement.StatementOntology target) Executes the specified SPARQL ASK query.executeSelectQuery(org.apache.jena.query.Query query, Statement.StatementOntology target) Executes the specified SPARQL SELECT query, returning the Jena ARQ result set.voidexecuteUpdate(String query, Statement.StatementOntology target) Executes the specified SPARQL 1.1 Update query.Collection<org.apache.jena.rdf.model.Statement>find(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value, Collection<String> contexts) Retrieves statements corresponding to the specified criteria from the specified named graph.Lists all contexts (named graph) in the repository (including the transactional ones).booleanisOpen()Retrieves status of this resource.voidReloads data from the underlying storage (if possible).voidRemoves the specified statements from the specified context in the storage.voidremove(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode object, String context) Removes statements matching the specified pattern from the specified storage context.voidRemoves all property values specified by the provided argument for the specified subject(s).voidrollback()Rolls back the current transaction.voidsetDataset(org.apache.jena.query.Dataset dataset) Sets new dataset on the underlying storage.<T> TReturns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.
-
Method Details
-
begin
public void begin()Description copied from interface:StorageConnectorBegins a transaction. -
commit
Description copied from interface:StorageConnectorCommits the current transaction.- Throws:
JenaDriverException- If commit fails
-
rollback
public void rollback()Description copied from interface:StorageConnectorRolls back the current transaction. -
find
public Collection<org.apache.jena.rdf.model.Statement> find(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value, Collection<String> contexts) Description copied from interface:StorageConnectorRetrieves statements corresponding to the specified criteria from the specified named graph.The first three parameters are optional, their absence signifies that any value in that position is acceptable.
contextsare also optional, their absence means that the default graph should be used.- Parameters:
subject- Statement subject, optionalproperty- Property, optionalvalue- Value, optionalcontexts- Named graph IRIs, optional. If empty, the default graph will be used- Returns:
- Collection of matching statements
-
contains
public boolean contains(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value, Collection<String> contexts) Description copied from interface:StorageConnectorChecks whether the specified context (named graph) contains any statements matching the specified criteria.The first three parameters are optional, their absence signifies that any value in that position is acceptable.
contextis also optional, its absence means that the default graph should be used.- Parameters:
subject- Subject, optionalproperty- Property, optionalvalue- Value, optionalcontexts- Named graph IRIs, optional. If empty, the default graph will be used- Returns:
trueif at least one statement matches the criteria,falseotherwise
-
getContexts
Description copied from interface:StorageConnectorLists all contexts (named graph) in the repository (including the transactional ones).- Returns:
- List of named graph URIs
-
add
Description copied from interface:StorageConnectorAdds the specified statements to the specified context in the storage.Requires an active transaction.
contextis optional, its absence means that the statements will be added into the the default graph.- Parameters:
statements- Statements to addcontext- Target context, optional
-
remove
Description copied from interface:StorageConnectorRemoves the specified statements from the specified context in the storage.Requires an active transaction.
contextis optional, its absence means that the statements will be removed from the the default graph.- Parameters:
statements- Statements to removecontext- Target context, optional
-
remove
public void remove(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode object, String context) Description copied from interface:StorageConnectorRemoves statements matching the specified pattern from the specified storage context.contextis optional, its absence means that the statements will be removed from the the default graph.- Parameters:
subject- Statement subject, optionalproperty- Statement property, optionalobject- Statement object, optionalcontext- Repository context IRI, optional
-
removePropertyValues
Description copied from interface:StorageConnectorRemoves all property values specified by the provided argument for the specified subject(s).- Parameters:
spc- Subject-predicate-contexts tuples
-
executeSelectQuery
public AbstractResultSet executeSelectQuery(org.apache.jena.query.Query query, Statement.StatementOntology target) throws JenaDriverException Description copied from interface:StatementExecutorExecutes the specified SPARQL SELECT query, returning the Jena ARQ result set.The
targetspecifies whether the query should be executed on the shared repository or whether the transactional snapshot will be used to evaluate the query. However, some implementations may ignore this parameter.- Parameters:
query- Query to executetarget- Dataset on which the query should be executed- Returns:
- ARQ result set
- Throws:
JenaDriverException- If query execution fails
-
executeAskQuery
public AbstractResultSet executeAskQuery(org.apache.jena.query.Query query, Statement.StatementOntology target) throws JenaDriverException Description copied from interface:StatementExecutorExecutes the specified SPARQL ASK query.The
targetspecifies whether the query should be executed on the shared repository or whether the transactional snapshot will be used to evaluate the query. However, some implementations may ignore this parameter.- Parameters:
query- Query to executetarget- Dataset on which the query should be executed- Returns:
- ASK result
- Throws:
JenaDriverException- If query execution fails
-
executeUpdate
public void executeUpdate(String query, Statement.StatementOntology target) throws JenaDriverException Description copied from interface:StatementExecutorExecutes the specified SPARQL 1.1 Update query.The
targetspecifies whether the query should be executed on the shared repository or whether the transactional snapshot will be used to evaluate the query. However, some implementations may ignore this parameter.- Parameters:
query- Query to executetarget- Dataset on which the update should be executed- Throws:
JenaDriverException- If query execution fails
-
close
public void close()Description copied from interface:CloseableCloses this resource releasing any sub-resources it holds.After closing the resource is not usable any more and calling methods on it (except
closeandisOpen) will result inIllegalStateException.Calling
closeon already closed resource does nothing.- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceStorageConnector
-
reloadStorage
public void reloadStorage()Reloads data from the underlying storage (if possible).Note that this applies only to RDF file-based storage access, other storage do not support reloading.
-
setDataset
public void setDataset(org.apache.jena.query.Dataset dataset) Sets new dataset on the underlying storage.Note that this is supported only for in-memory storage.
- Parameters:
dataset- The dataset to use
-
isOpen
public boolean isOpen()Description copied from interface:CloseableRetrieves status of this resource. -
unwrap
Description copied from interface:WrapperReturns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy. If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then anOntoDriverExceptionis thrown.
-