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 TypeMethodDescriptionvoid
Adds the specified statements to the specified context in the storage.void
begin()
Begins a transaction.void
close()
Closes this resource releasing any sub-resources it holds.void
commit()
Commits the current transaction.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) 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.void
executeUpdate
(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).boolean
isOpen()
Retrieves status of this resource.void
Reloads data from the underlying storage (if possible).void
Removes the specified statements from the specified context in the storage.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) Removes statements matching the specified pattern from the specified storage context.void
Removes all property values specified by the provided argument for the specified subject(s).void
rollback()
Rolls back the current transaction.void
setDataset
(org.apache.jena.query.Dataset dataset) Sets new dataset on the underlying storage.<T> T
Returns 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:StorageConnector
Begins a transaction. -
commit
Description copied from interface:StorageConnector
Commits the current transaction.- Throws:
JenaDriverException
- If commit fails
-
rollback
public void rollback()Description copied from interface:StorageConnector
Rolls 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:StorageConnector
Retrieves 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.
contexts
are 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:StorageConnector
Checks 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.
context
is 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:
true
if at least one statement matches the criteria,false
otherwise
-
getContexts
Description copied from interface:StorageConnector
Lists all contexts (named graph) in the repository (including the transactional ones).- Returns:
- List of named graph URIs
-
add
Description copied from interface:StorageConnector
Adds the specified statements to the specified context in the storage.Requires an active transaction.
context
is 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:StorageConnector
Removes the specified statements from the specified context in the storage.Requires an active transaction.
context
is 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:StorageConnector
Removes statements matching the specified pattern from the specified storage context.context
is 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:StorageConnector
Removes 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:StatementExecutor
Executes the specified SPARQL SELECT query, returning the Jena ARQ result set.The
target
specifies 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:StatementExecutor
Executes the specified SPARQL ASK query.The
target
specifies 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:StatementExecutor
Executes the specified SPARQL 1.1 Update query.The
target
specifies 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:Closeable
Closes this resource releasing any sub-resources it holds.After closing the resource is not usable any more and calling methods on it (except
close
andisOpen
) will result inIllegalStateException
.Calling
close
on already closed resource does nothing.- Specified by:
close
in interfaceCloseable
- Specified by:
close
in 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:Closeable
Retrieves status of this resource. -
unwrap
Description copied from interface:Wrapper
Returns 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 anOntoDriverException
is thrown.
-