Class OwlapiConnection

java.lang.Object
cz.cvut.kbss.ontodriver.owlapi.OwlapiConnection
All Implemented Interfaces:
Connection, Wrapper, AutoCloseable

public class OwlapiConnection extends Object implements Connection
Default implementation of the Connection interface for OWLAPI driver.
  • Method Details

    • isOpen

      public boolean isOpen()
      Description copied from interface: Connection
      Whether this connection is active.
      Specified by:
      isOpen in interface Connection
      Returns:
      Active status of this connection
    • commit

      public void commit()
      Description copied from interface: Connection
      Commits this connection.

      This effectively makes persistent any changes made since the last commit/rollback or since this connection was opened.

      If this connection is in auto-commit mode, calling this method has no effect.

      Specified by:
      commit in interface Connection
    • ensureOpen

      public void ensureOpen()
    • rollback

      public void rollback()
      Description copied from interface: Connection
      Rolls back any changes made in the current transaction.

      If this connection is in auto-commit mode, calling this method has no effect.

      Specified by:
      rollback in interface Connection
    • setAutoCommit

      public void setAutoCommit(boolean autoCommit)
      Description copied from interface: Connection
      Sets this connection's auto-commit mode to the specified state.
      Specified by:
      setAutoCommit in interface Connection
      Parameters:
      autoCommit - The new auto-commit state
    • isAutoCommit

      public boolean isAutoCommit()
      Description copied from interface: Connection
      Returns this connection's auto-commit mode.
      Specified by:
      isAutoCommit in interface Connection
      Returns:
      true if this connection is in auto-commit mode, false otherwise
    • createStatement

      public Statement createStatement()
      Description copied from interface: Connection
      Creates a new SPARQL statement.
      Specified by:
      createStatement in interface Connection
      Returns:
      a Statement instance
    • prepareStatement

      public PreparedStatement prepareStatement(String sparql)
      Description copied from interface: Connection
      Creates and returns a new prepared SPARQL statement.
      Specified by:
      prepareStatement in interface Connection
      Parameters:
      sparql - The query to prepare
      Returns:
      PreparedStatement
    • isConsistent

      public boolean isConsistent(URI context)
      Description copied from interface: Connection
      Verifies consistency of ontology context with the specified URI

      Note that null argument means checking consistency of the whole repository.

      Specified by:
      isConsistent in interface Connection
      Parameters:
      context - Context identifier, can be null
      Returns:
      Consistency status
    • getContexts

      public List<URI> getContexts()
      Description copied from interface: Connection
      Gets a set of currently available contexts in the underlying repository.

      Note that the default context is not included in the result.

      Specified by:
      getContexts in interface Connection
      Returns:
      List of context URIs
    • contains

      public boolean contains(Axiom<?> axiom, Set<URI> contexts)
      Description copied from interface: Connection
      Checks whether the storage contains the specified axiom.

      The contexts optionally specify repository contexts in which to look for the axiom.

      Specified by:
      contains in interface Connection
      Parameters:
      axiom - The axiom to look for
      contexts - Optional search contexts, an empty set means to look in the default storage context
      Returns:
      true if the storage contains matching axiom, false otherwise
    • isInferred

      public boolean isInferred(Axiom<?> axiom, Set<URI> contexts)
      Description copied from interface: Connection
      Checks whether the specified axiom is inferred in the underlying repository.

      The contexts optionally specify repository contexts in which to look for the axiom. However, note that different triple stores treat inference differently and inferred statements may be stored in a special context. In this case, the implementation may choose to ignore the provided set of contexts.

      Also note that since most underlying repository access implementations do not allow retrieving inferred statements only and instead provide either only asserted or asserted + inferred statements, this method may return false in case the repository contains the axiom both inferred and asserted.

      Specified by:
      isInferred in interface Connection
      Parameters:
      axiom - Axiom whose inference to check
      contexts - Optional search contexts, an empty set means to look in the default storage context
      Returns:
      true if the repository inferred the specified axiom, false if the axiom is asserted or not present at all
    • find

      public Collection<Axiom<?>> find(AxiomDescriptor descriptor) throws OntoDriverException
      Description copied from interface: Connection
      Finds axioms with the corresponding subject and properties.
      Specified by:
      find in interface Connection
      Parameters:
      descriptor - Loading descriptor specifies subject, properties to load and possible contexts to work with
      Returns:
      Collection of axioms matching the specified criteria
      Throws:
      OntoDriverException - If an ontology access error occurs
    • persist

      public void persist(AxiomValueDescriptor descriptor) throws OntoDriverException
      Description copied from interface: Connection
      Persists new individual and its property values specified by the descriptor.
      Specified by:
      persist in interface Connection
      Parameters:
      descriptor - Descriptor of the persisted values
      Throws:
      OntoDriverException - If an ontology access error occurs
    • generateIdentifier

      public URI generateIdentifier(URI classUri)
      Description copied from interface: Connection
      Generates a new unique identifier based on the specified type.

      The identifier is required to be unique in the whole repository.

      Specified by:
      generateIdentifier in interface Connection
      Parameters:
      classUri - OWL class identifier
      Returns:
      Unique identifier
    • update

      public void update(AxiomValueDescriptor descriptor) throws OntoDriverException
      Description copied from interface: Connection
      Persists the values specified by this descriptor, removing existing property values from the ontology.

      This method removes original values of properties specified in the descriptor and persists new values specified therein.

      Specified by:
      update in interface Connection
      Parameters:
      descriptor - Descriptor of the update values
      Throws:
      OntoDriverException - If an ontology access error occurs
    • remove

      public void remove(AxiomDescriptor descriptor) throws OntoDriverException
      Description copied from interface: Connection
      Removes all axioms related to subject specified by the descriptor.

      The descriptor may also specify contexts from which property assertion axioms should be removed.

      Note that this method will cause also removal of axioms in which the NamedResource specified by the argument stands as value.

      Specified by:
      remove in interface Connection
      Parameters:
      descriptor - Descriptor of contexts and the subject of removal
      Throws:
      OntoDriverException - If an ontology access error occurs
    • lists

      public Lists lists()
      Description copied from interface: Connection
      Gets ontology lists handler.
      Specified by:
      lists in interface Connection
      Returns:
      Lists handler
    • types

      public Types types()
      Description copied from interface: Connection
      Gets types handler.
      Specified by:
      types in interface Connection
      Returns:
      Types handler
    • properties

      public Properties properties()
      Description copied from interface: Connection
      Gets handler for unmapped properties.
      Specified by:
      properties in interface Connection
      Returns:
      Properties handler
    • containers

      public Containers containers()
      Description copied from interface: Connection
      Gets handler for RDF containers.
      Specified by:
      containers in interface Connection
      Returns:
      Containers handler
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • commitIfAuto

      public void commitIfAuto()
    • unwrap

      public <T> T unwrap(Class<T> cls) throws OntoDriverException
      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
      Throws:
      OntoDriverException - If no matching object is found