Interface Connection

All Superinterfaces:
AutoCloseable, Wrapper
All Known Implementing Classes:
JenaConnection, OwlapiConnection, Rdf4jConnection

public interface Connection extends AutoCloseable, Wrapper
  • Method Details

    • isOpen

      boolean isOpen()
      Whether this connection is active.
      Returns:
      Active status of this connection
    • commit

      void commit() throws OntoDriverException
      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.

      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • rollback

      void rollback() throws OntoDriverException
      Rolls back any changes made in the current transaction.

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

      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • setAutoCommit

      void setAutoCommit(boolean autoCommit)
      Sets this connection's auto-commit mode to the specified state.
      Parameters:
      autoCommit - The new auto-commit state
      Throws:
      IllegalStateException - If called on a closed connection
    • isAutoCommit

      boolean isAutoCommit()
      Returns this connection's auto-commit mode.
      Returns:
      true if this connection is in auto-commit mode, false otherwise
      Throws:
      IllegalStateException - If called on a closed connection
    • createStatement

      Statement createStatement() throws OntoDriverException
      Creates a new SPARQL statement.
      Returns:
      a Statement instance
      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • prepareStatement

      PreparedStatement prepareStatement(String sparql) throws OntoDriverException
      Creates and returns a new prepared SPARQL statement.
      Parameters:
      sparql - The query to prepare
      Returns:
      PreparedStatement
      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • isConsistent

      boolean isConsistent(URI context) throws OntoDriverException
      Verifies consistency of ontology context with the specified URI

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

      Parameters:
      context - Context identifier, can be null
      Returns:
      Consistency status
      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • getContexts

      List<URI> getContexts() throws OntoDriverException
      Gets a set of currently available contexts in the underlying repository.

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

      Returns:
      List of context URIs
      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • contains

      boolean contains(Axiom<?> axiom, Set<URI> contexts) throws OntoDriverException
      Checks whether the storage contains the specified axiom.

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

      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
      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • isInferred

      boolean isInferred(Axiom<?> axiom, Set<URI> contexts) throws OntoDriverException
      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.

      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
      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • find

      Collection<Axiom<?>> find(AxiomDescriptor descriptor) throws OntoDriverException
      Finds axioms with the corresponding subject and properties.
      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
      IllegalStateException - If called on a closed connection
    • persist

      void persist(AxiomValueDescriptor descriptor) throws OntoDriverException
      Persists new individual and its property values specified by the descriptor.
      Parameters:
      descriptor - Descriptor of the persisted values
      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • generateIdentifier

      URI generateIdentifier(URI classUri) throws OntoDriverException
      Generates a new unique identifier based on the specified type.

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

      Parameters:
      classUri - OWL class identifier
      Returns:
      Unique identifier
      Throws:
      OntoDriverException - If an ontology access error occurs
    • update

      void update(AxiomValueDescriptor descriptor) throws OntoDriverException
      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.

      Parameters:
      descriptor - Descriptor of the update values
      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • remove

      void remove(AxiomDescriptor descriptor) throws OntoDriverException
      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.

      Parameters:
      descriptor - Descriptor of contexts and the subject of removal
      Throws:
      OntoDriverException - If an ontology access error occurs
      IllegalStateException - If called on a closed connection
    • lists

      Lists lists()
      Gets ontology lists handler.
      Returns:
      Lists handler
    • types

      Types types()
      Gets types handler.
      Returns:
      Types handler
    • properties

      Properties properties()
      Gets handler for unmapped properties.
      Returns:
      Properties handler
    • containers

      Containers containers()
      Gets handler for RDF containers.
      Returns:
      Containers handler