public class DatasetImpl extends Object implements Dataset
Transactional.Promote
Constructor and Description |
---|
DatasetImpl(Dataset ds)
Deprecated.
|
DatasetImpl(Model model)
Create a Dataset with the model as default model.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort a transaction - finish the transaction and undo any changes (if a "write" transaction)
|
Dataset |
addNamedModel(String uri,
Model model)
Set a named graph.
|
DatasetGraph |
asDatasetGraph()
Get the dataset in graph form
|
void |
begin()
Start a transaction which is READ mode and which will switch to WRITE if an update
is attempted but only if no intermediate transaction has performed an update.
|
void |
begin(ReadWrite mode)
Start either a READ or WRITE transaction
|
void |
begin(TxnType txnType)
Start a transaction.
READ or WRITE transactions start in that state and do not change for the lifetime of the transaction. |
void |
close()
Close the dataset, potentially releasing any associated resources.
|
void |
commit()
Commit a transaction - finish the transaction and make any changes permanent (if a "write" transaction)
|
boolean |
containsNamedModel(String uri)
Does the dataset contain a model with the name supplied?
|
void |
end()
Finish the transaction - if a write transaction and commit() has not been called, then abort
|
Context |
getContext()
Get the context associated with this dataset
|
Model |
getDefaultModel()
Get the default graph as a Jena Model
|
Lock |
getLock()
Get the lock for this dataset
|
Model |
getNamedModel(String uri)
Get a graph by name as a Jena Model
|
Model |
getUnionModel()
Get the graph which is the unionof all named graphs as a Jena Model
|
boolean |
isEmpty() |
boolean |
isInTransaction()
Say whether a transaction is active
|
Iterator<String> |
listNames()
List the names
|
boolean |
promote(Transactional.Promote txnType)
Attempt to promote a transaction from "read" mode to "write" and the transaction.
|
Dataset |
removeNamedModel(String uri)
Remove a named graph.
|
Dataset |
replaceNamedModel(String uri,
Model model)
Change a named graph for another using the same name
|
Dataset |
setDefaultModel(Model model)
Set the default graph.
|
boolean |
supportsTransactionAbort()
Declare whether
Dataset.abort() is supported. |
boolean |
supportsTransactions()
Does this dataset support transactions? Supporting transactions means that
the dataset implementation provides
Dataset.begin(org.apache.jena.query.ReadWrite) , Dataset.commit() ,
Dataset.end() which otherwise may throw
UnsupportedOperationException . |
ReadWrite |
transactionMode()
Return the current mode of the transaction - "read" or "write".
|
TxnType |
transactionType()
Return the transaction type used in
begin(TxnType) . |
static Dataset |
wrap(DatasetGraph datasetGraph)
Wrap an existing DatasetGraph
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
promote
public DatasetImpl(Model model)
@Deprecated public DatasetImpl(Dataset ds)
public static Dataset wrap(DatasetGraph datasetGraph)
public Model getDefaultModel()
Dataset
getDefaultModel
in interface Dataset
public Model getUnionModel()
Dataset
getUnionModel
in interface Dataset
public Lock getLock()
Dataset
public Context getContext()
Dataset
getContext
in interface Dataset
public boolean supportsTransactions()
Dataset
Dataset.begin(org.apache.jena.query.ReadWrite)
, Dataset.commit()
,
Dataset.end()
which otherwise may throw
UnsupportedOperationException
.
See Dataset.supportsTransactionAbort()
for Dataset.abort()
.
A Dataset
that provides functionality across independent systems
can not provide all features strong guarantees. For example, they may use MRSW
locking and some isolation control. Specifically, they do not necessarily
provide Dataset.abort()
.
In addition, check details of a specific implementation.
supportsTransactions
in interface Dataset
public boolean supportsTransactionAbort()
Dataset
Dataset.abort()
is supported.
This goes along with clearing up after exceptions inside application transaction code.supportsTransactionAbort
in interface Dataset
public void begin()
Transactional
See Transactional.begin(TxnType)
for more details an options.
May not be implemented. See Transactional.begin(ReadWrite)
is guaranteed to be provided.
begin
in interface Transactional
public void begin(TxnType txnType)
Transactional
WRITE
: this guarantees a WRITE will complete if commit()
is
called. The same as begin(ReadWrite.WRITE)
.
READ
: the transaction can not promote to WRITE,ensuring read-only
access to the data. The same as begin(ReadWrite.READ)
.
READ_PROMOTE
: the transaction will go from "read" to "write" if an
update is attempted and if the dataset has not been changed by another write
transaction. See also Transactional.promote()
.
READ_COMMITTED_PROMOTE
: Use this with care. The promotion will
succeed but changes from other transactions become visible.
begin
). If READ_PROMOTE
, the dataset must not have
changed; if READ_COMMITTED_PROMOTE
any intermediate changes are
visible but the application can not assume any data it has read in the
transaction is the same as it was at the point the transaction started.
This operation is optional and some implementations may throw
a JenaTransactionException
exception for some or all TxnType
values.
See Transactional.begin(ReadWrite)
for a form that is required of implementations.
begin
in interface Transactional
public void begin(ReadWrite mode)
Dataset
begin
in interface Dataset
begin
in interface Transactional
public boolean promote(Transactional.Promote txnType)
Transactional
READ
, which is read-only.
An argument of READ_PROMOTE
treats the promotion as if the transaction was started
with READ_PROMOTE
(any other writer commiting since the transaction started
blocks promotion) and READ_COMMITTED_PROMOTE
treats the promotion as if the transaction was started
with READ_COMMITTED_PROMOTE
(intemediate writer commits become visible).
Returns "true" if the transaction is in write mode after the call. The method always succeeds of the transaction is already "write".
This method returns true if a READ_PROMOTE
or
READ_COMMITTED_PROMOTE
is promoted.
This method returns false if a READ_PROMOTE
can't be promoted - the
transaction is still valid and in "read" mode.
This method throws an exception if there is an attempt to promote a READ
transaction.
promote
in interface Transactional
public ReadWrite transactionMode()
Transactional
transactionMode
in interface Transactional
public TxnType transactionType()
Transactional
begin(TxnType)
.
If the caller is not in a transaction, this method returns null.transactionType
in interface Transactional
public boolean isInTransaction()
isInTransaction
in interface Dataset
isInTransaction
in interface Transactional
public void commit()
Dataset
commit
in interface Dataset
commit
in interface Transactional
public void abort()
Dataset
abort
in interface Dataset
abort
in interface Transactional
public void end()
Dataset
end
in interface Dataset
end
in interface Transactional
public DatasetGraph asDatasetGraph()
Dataset
asDatasetGraph
in interface Dataset
public Model getNamedModel(String uri)
Dataset
getNamedModel
in interface Dataset
public Dataset addNamedModel(String uri, Model model)
Dataset
addNamedModel
in interface Dataset
uri
- the name of the graph to setmodel
- the graph to setDataset
for continued usagepublic Dataset removeNamedModel(String uri)
Dataset
removeNamedModel
in interface Dataset
uri
- the name of the gaph to removeDataset
for continued usagepublic Dataset replaceNamedModel(String uri, Model model)
Dataset
replaceNamedModel
in interface Dataset
uri
- the name of the graph to replacemodel
- the graph with which to replace itDataset
for continued usagepublic Dataset setDefaultModel(Model model)
Dataset
setDefaultModel
in interface Dataset
model
- the default graph to setDataset
for continued usagepublic boolean containsNamedModel(String uri)
Dataset
containsNamedModel
in interface Dataset
public Iterator<String> listNames()
Dataset
public void close()
Dataset
Licenced under the Apache License, Version 2.0