Class SnapshotStorageConnector

java.lang.Object
cz.cvut.kbss.ontodriver.jena.connector.SharedStorageConnector
cz.cvut.kbss.ontodriver.jena.connector.SnapshotStorageConnector
All Implemented Interfaces:
Closeable, StatementExecutor, StorageConnector, Wrapper

public class SnapshotStorageConnector extends SharedStorageConnector
This connector implements the JenaOntoDriverProperties.SNAPSHOT-based transactional strategy.

It is also used when inference is required from the driver.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(List<org.apache.jena.rdf.model.Statement> statements, String context)
    Adds the specified statements to the specified context in the storage.
    void
    Begins a transaction.
    void
    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
    Executes the specified SPARQL 1.1 Update query.
    List<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
    Retrieves status of this resource.
    void
    remove(List<org.apache.jena.rdf.model.Statement> statements, String context)
    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
    Rolls back the current transaction.
    <T> T
    unwrap(Class<T> cls)
    Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

    Methods inherited from class cz.cvut.kbss.ontodriver.jena.connector.SharedStorageConnector

    close, reloadStorage, setDataset

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • begin

      public void begin()
      Description copied from interface: StorageConnector
      Begins a transaction.
      Specified by:
      begin in interface StorageConnector
      Overrides:
      begin in class SharedStorageConnector
    • commit

      public void commit() throws JenaDriverException
      Description copied from interface: StorageConnector
      Commits the current transaction.
      Specified by:
      commit in interface StorageConnector
      Overrides:
      commit in class SharedStorageConnector
      Throws:
      JenaDriverException - If commit fails
    • rollback

      public void rollback()
      Description copied from interface: StorageConnector
      Rolls back the current transaction.
      Specified by:
      rollback in interface StorageConnector
      Overrides:
      rollback in class SharedStorageConnector
    • find

      public List<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.

      Specified by:
      find in interface StorageConnector
      Overrides:
      find in class SharedStorageConnector
      Parameters:
      subject - Statement subject, optional
      property - Property, optional
      value - Value, optional
      contexts - 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.

      Specified by:
      contains in interface StorageConnector
      Overrides:
      contains in class SharedStorageConnector
      Parameters:
      subject - Subject, optional
      property - Property, optional
      value - Value, optional
      contexts - 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

      public List<String> getContexts()
      Description copied from interface: StorageConnector
      Lists all contexts (named graph) in the repository (including the transactional ones).
      Specified by:
      getContexts in interface StorageConnector
      Overrides:
      getContexts in class SharedStorageConnector
      Returns:
      List of named graph URIs
    • add

      public void add(List<org.apache.jena.rdf.model.Statement> statements, String context)
      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.

      Specified by:
      add in interface StorageConnector
      Overrides:
      add in class SharedStorageConnector
      Parameters:
      statements - Statements to add
      context - Target context, optional
    • remove

      public void remove(List<org.apache.jena.rdf.model.Statement> statements, String context)
      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.

      Specified by:
      remove in interface StorageConnector
      Overrides:
      remove in class SharedStorageConnector
      Parameters:
      statements - Statements to remove
      context - 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.

      Specified by:
      remove in interface StorageConnector
      Overrides:
      remove in class SharedStorageConnector
      Parameters:
      subject - Statement subject, optional
      property - Statement property, optional
      object - Statement object, optional
      context - Repository context IRI, optional
    • removePropertyValues

      public void removePropertyValues(Collection<SubjectPredicateContext> spc)
      Description copied from interface: StorageConnector
      Removes all property values specified by the provided argument for the specified subject(s).
      Specified by:
      removePropertyValues in interface StorageConnector
      Overrides:
      removePropertyValues in class SharedStorageConnector
      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.

      Specified by:
      executeSelectQuery in interface StatementExecutor
      Overrides:
      executeSelectQuery in class SharedStorageConnector
      Parameters:
      query - Query to execute
      target - 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.

      Specified by:
      executeAskQuery in interface StatementExecutor
      Overrides:
      executeAskQuery in class SharedStorageConnector
      Parameters:
      query - Query to execute
      target - 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.

      Specified by:
      executeUpdate in interface StatementExecutor
      Overrides:
      executeUpdate in class SharedStorageConnector
      Parameters:
      query - Query to execute
      target - Dataset on which the update should be executed
      Throws:
      JenaDriverException - If query execution fails
    • isOpen

      public boolean isOpen()
      Description copied from interface: Closeable
      Retrieves status of this resource.
      Specified by:
      isOpen in interface Closeable
      Returns:
      true if the resource is open, false otherwise
    • unwrap

      public <T> T unwrap(Class<T> cls)
      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 an OntoDriverException is thrown.
      Specified by:
      unwrap in interface Wrapper
      Type Parameters:
      T - The type of the class modeled by this Class object
      Parameters:
      cls - The type of the required result
      Returns:
      An object implementing the interface