Dataquay 0.8
Dataquay::Transaction Class Referenceabstract

Transaction is an abstract interface for classes that read and write an RDF Store within the context of an atomic operation such as an editing command. More...

#include <dataquay/Transaction.h>

Inheritance diagram for Dataquay::Transaction:

Public Types

enum  ImportDuplicatesMode { ImportIgnoreDuplicates , ImportFailOnDuplicates , ImportPermitDuplicates }
 ImportDuplicatesMode determines the outcome when an import operation encounters a triple in the imported data set that already exists in the store. More...
 
enum  Feature { ModifyFeature , QueryFeature , RemoteImportFeature }
 Feature defines the set of optional features a Store implementation may support. More...
 
typedef QSet< FeatureFeatures
 

Public Member Functions

virtual ~Transaction ()
 Delete this transaction object.
 
virtual void commit ()=0
 Commit this transaction.
 
virtual void rollback ()=0
 Roll back this transaction.
 
virtual ChangeSet getCommittedChanges () const =0
 Return the ChangeSet committed in this transaction.
 
virtual ChangeSet getChanges () const =0
 Return the ChangeSet for this transaction to date.
 
virtual bool add (Triple t)=0
 Add a triple to the store.
 
virtual bool remove (Triple t)=0
 Remove a triple from the store.
 
virtual void change (ChangeSet changes)=0
 Atomically apply the sequence of add/remove changes described in the given ChangeSet.
 
virtual void revert (ChangeSet changes)=0
 Atomically apply the sequence of add/remove changes described in the given ChangeSet, in reverse (ie removing adds and adding removes, in reverse order).
 
virtual bool contains (Triple t) const =0
 Return true if the store contains the given triple, false otherwise.
 
virtual Triples match (Triple t) const =0
 Return all triples matching the given wildcard triple.
 
virtual ResultSet query (QString sparql) const =0
 Run a SPARQL query against the store and return its results.
 
virtual Node complete (Triple t) const =0
 Given a triple in which any two nodes are specified and the other is a wildcard node of type Nothing, return a node that can be substituted for the Nothing node in order to complete a triple that exists in the store.
 
virtual Triple matchOnce (Triple t) const =0
 Return a triple from the store that matches the given wildcard triple, or the empty triple if none matches.
 
virtual Node queryOnce (QString sparql, QString bindingName) const =0
 Run a SPARQL query against the store and return the node of the first result for the given query binding.
 
virtual Uri getUniqueUri (QString prefix) const =0
 Get a new URI, starting with the given prefix (e.g.
 
virtual Node addBlankNode ()=0
 Create and return a new blank node.
 
virtual Uri expand (QString uri) const =0
 Expand the given URI (which may use local namespaces) and prefix-expand it, returning the result as a Uri.
 
virtual void save (QString filename) const =0
 Export the store to an RDF/TTL file with the given filename.
 
virtual void import (QUrl url, ImportDuplicatesMode idm, QString format="")=0
 Import the RDF document found at the given URL into the current store (in addition to its existing contents).
 
virtual void importString (QString encodedRdf, Uri baseUri, ImportDuplicatesMode idm, QString format="")=0
 Import the RDF document encoded in the given string into the current store (in addition to its existing contents).
 
virtual Features getSupportedFeatures () const =0
 Retrieve the set of optional features supported by this Store implementation.
 

Protected Member Functions

 Transaction ()
 

Detailed Description

Transaction is an abstract interface for classes that read and write an RDF Store within the context of an atomic operation such as an editing command.

The Transaction interface provides the same editing operations as the Store interface; it subclasses from Store and may be interchanged with Store in most contexts. To obtain a Transaction, use TransactionalStore.

Definition at line 52 of file Transaction.h.

Member Typedef Documentation

◆ Features

Definition at line 290 of file Store.h.

Member Enumeration Documentation

◆ ImportDuplicatesMode

ImportDuplicatesMode determines the outcome when an import operation encounters a triple in the imported data set that already exists in the store.

ImportIgnoreDuplicates: Any duplicate of a triple that is already in the store is discarded without comment.

ImportFailOnDuplicates: Import will fail with an RDFDuplicateImportException if any duplicate of a triple already in the store is found, and nothing will be imported.

ImportPermitDuplicates: No tests for duplicate triples will be carried out, and the behaviour when duplicates are imported will depend on the underlying store implementation (which may merge them or store them as separate duplicate triples). This is usually inadvisable: besides its unpredictability, this class does not generally handle duplicate triples well in other contexts.

Enumerator
ImportIgnoreDuplicates 
ImportFailOnDuplicates 
ImportPermitDuplicates 

Definition at line 222 of file Store.h.

◆ Feature

enum Dataquay::Store::Feature
inherited

Feature defines the set of optional features a Store implementation may support.

Code that uses Store should check that the features it requires are available before trying to make use of them.

ModifyFeature: The store can be modified (triples can be added to it). All current Store implementations support this feature.

QueryFeature: The store supports SPARQL queries through the query and queryOnce methods. A store that does not support queries will throw RDFUnsupportedError when these functions are called.

RemoteImportFeature: The store can import URLs that represent network resources as well as URLs referring to files on the local disc. The extent to which this feature is actually available may also depend on the configuration of the underlying RDF library. A store that does not support remote URLs will fail as if the resource was absent, when asked to load one.

Enumerator
ModifyFeature 
QueryFeature 
RemoteImportFeature 

Definition at line 284 of file Store.h.

Constructor & Destructor Documentation

◆ ~Transaction()

virtual Dataquay::Transaction::~Transaction ( )
inlinevirtual

Delete this transaction object.

You must either commit or roll back the transaction before deleting it.

The destructor will throw RDFTransactionError if the transaction has been used but not committed or rolled back. Such a situation indicates a straightforward coding oversight: fix the code, rather than catching the exception.

Definition at line 64 of file Transaction.h.

◆ Transaction()

Dataquay::Transaction::Transaction ( )
inlineprotected

Definition at line 115 of file Transaction.h.

Member Function Documentation

◆ commit()

virtual void Dataquay::Transaction::commit ( )
pure virtual

Commit this transaction.

Changes made during the transaction will be committed to the store, atomically with respect to other active transactions.

You should not attempt to use the Transaction object again (except to call getChanges or to delete it) after this call is made. Any further call to the transaction's Store interface will throw an RDFTransactionError.

◆ rollback()

virtual void Dataquay::Transaction::rollback ( )
pure virtual

Roll back this transaction.

All changes made during the transaction will be discarded.

You should not attempt to use the Transaction object again (except to delete it) after this call is made. Any further call to the transaction's Store interface will throw an RDFTransactionError.

◆ getCommittedChanges()

virtual ChangeSet Dataquay::Transaction::getCommittedChanges ( ) const
pure virtual

Return the ChangeSet committed in this transaction.

If the transaction has not yet been committed (or has been rolled back), this will be empty.

(After a transaction has been committed, you can in principle revert it in its entirety by calling Store::revert() with this change set.)

◆ getChanges()

virtual ChangeSet Dataquay::Transaction::getChanges ( ) const
pure virtual

Return the ChangeSet for this transaction to date.

This returns all changes provisionally made (but not necessarily committed) during the transaction.

If the transaction has been rolled back, this will return the changes that were accumulated prior to the roll back, i.e. the changes that were then rolled back.

If the transaction has been committed, this will return the same ChangeSet as getCommittedChanges().

◆ add()

virtual bool Dataquay::Store::add ( Triple t)
pure virtualinherited

Add a triple to the store.

Return false if the triple was already in the store. (Dataquay does not permit duplicate triples in a store.) Throw RDFException if the triple can not be added for some other reason.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ remove()

virtual bool Dataquay::Store::remove ( Triple t)
pure virtualinherited

Remove a triple from the store.

If some nodes in the triple are Nothing nodes, remove all matching triples. Return false if no matching triple was found in the store. Throw RDFException if removal failed for some other reason.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ change()

virtual void Dataquay::Store::change ( ChangeSet changes)
pure virtualinherited

Atomically apply the sequence of add/remove changes described in the given ChangeSet.

Throw RDFException if any operation fails for any reason (including duplication etc).

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ revert()

virtual void Dataquay::Store::revert ( ChangeSet changes)
pure virtualinherited

Atomically apply the sequence of add/remove changes described in the given ChangeSet, in reverse (ie removing adds and adding removes, in reverse order).

Throw RDFException if any operation fails for any reason (including duplication etc).

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ contains()

virtual bool Dataquay::Store::contains ( Triple t) const
pure virtualinherited

Return true if the store contains the given triple, false otherwise.

Throw RDFException if the triple is not complete or if the test failed for any other reason.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ match()

virtual Triples Dataquay::Store::match ( Triple t) const
pure virtualinherited

Return all triples matching the given wildcard triple.

A node of type Nothing in any part of the triple matches any node in the data store. Return an empty list if there are no matches; may throw RDFException if matching fails in some other way.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ query()

virtual ResultSet Dataquay::Store::query ( QString sparql) const
pure virtualinherited

Run a SPARQL query against the store and return its results.

Any prefixes added previously using addQueryPrefix will be available in this query without needing to be declared in the SPARQL given here (equivalent to writing "PREFIX prefix: <uri>" for each prefix,uri pair set with addPrefix).

May throw RDFException.

Note that the RDF store must have an absolute base URI (rather than the default "#") in order to perform queries, as relative URIs in the query will be interpreted relative to the query base rather than the store and without a proper base URI there is no way to override that internally.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ complete()

virtual Node Dataquay::Store::complete ( Triple t) const
pure virtualinherited

Given a triple in which any two nodes are specified and the other is a wildcard node of type Nothing, return a node that can be substituted for the Nothing node in order to complete a triple that exists in the store.

If no matching triple can be found, return a null node. If more than one triple matches, the returned value may arbitrarily be from any of them. May throw RDFException.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ matchOnce()

virtual Triple Dataquay::Store::matchOnce ( Triple t) const
pure virtualinherited

Return a triple from the store that matches the given wildcard triple, or the empty triple if none matches.

A node of type Nothing in any part of the triple matches any node in the data store. If more than one triple matches, the returned value may arbitrarily be any of them. May throw RDFException.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ queryOnce()

virtual Node Dataquay::Store::queryOnce ( QString sparql,
QString bindingName ) const
pure virtualinherited

Run a SPARQL query against the store and return the node of the first result for the given query binding.

This is a shorthand for use with queries that are only expected to have one result. May throw RDFException.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ getUniqueUri()

virtual Uri Dataquay::Store::getUniqueUri ( QString prefix) const
pure virtualinherited

Get a new URI, starting with the given prefix (e.g.

":event_"), that does not currently exist within this store. The URI will be prefix expanded.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ addBlankNode()

virtual Node Dataquay::Store::addBlankNode ( )
pure virtualinherited

Create and return a new blank node.

This node can only be referred to using the given Node object, and only during its lifetime within this instance of the store.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ expand()

virtual Uri Dataquay::Store::expand ( QString uri) const
pure virtualinherited

Expand the given URI (which may use local namespaces) and prefix-expand it, returning the result as a Uri.

(The Uri class cannot be used to store URIs that have unexpanded namespace prefixes.)

The set of available prefixes for expansion depends on the subclass implementation. See, for example, BasicStore::addPrefix.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ save()

virtual void Dataquay::Store::save ( QString filename) const
pure virtualinherited

Export the store to an RDF/TTL file with the given filename.

If the file already exists, it will if possible be overwritten. May throw RDFException, FileOperationFailed, FailedToOpenFile, etc.

Note that unlike import (which takes a URL argument), save takes a simple filename with no file:// prefix.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ import()

virtual void Dataquay::Store::import ( QUrl url,
ImportDuplicatesMode idm,
QString format = "" )
pure virtualinherited

Import the RDF document found at the given URL into the current store (in addition to its existing contents).

Its behaviour when a triple is encountered that already exists in the store is controlled by the ImportDuplicatesMode.

May throw RDFException or RDFDuplicateImportException.

Note that the URL must be a URL, not just a filename (i.e. local files need the file: prefix).

If format is specified, it will be taken as the RDF parse format (e.g. ntriples). The set of supported format strings depends on the underlying RDF library configuration. The default is to guess the format if possible.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ importString()

virtual void Dataquay::Store::importString ( QString encodedRdf,
Uri baseUri,
ImportDuplicatesMode idm,
QString format = "" )
pure virtualinherited

Import the RDF document encoded in the given string into the current store (in addition to its existing contents).

Its behaviour when a triple is encountered that already exists in the store is controlled by the ImportDuplicatesMode.

May throw RDFException or RDFDuplicateImportException.

If format is specified, it will be taken as the RDF parse format (e.g. ntriples). The set of supported format strings depends on the underlying RDF library configuration. The default is to guess the format if possible.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.

◆ getSupportedFeatures()

virtual Features Dataquay::Store::getSupportedFeatures ( ) const
pure virtualinherited

Retrieve the set of optional features supported by this Store implementation.

Implemented in Dataquay::BasicStore, Dataquay::Connection, and Dataquay::TransactionalStore.


The documentation for this class was generated from the following file: