
edu.rpi.tw.twks.nanopub.DatasetTransaction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of twks-nanopub Show documentation
Show all versions of twks-nanopub Show documentation
${product} nanopublication library
package edu.rpi.tw.twks.nanopub;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.ReadWrite;
import static com.google.common.base.Preconditions.checkNotNull;
public final class DatasetTransaction implements AutoCloseable {
private final Dataset dataset;
public DatasetTransaction(final Dataset dataset, final ReadWrite readWrite) {
this.dataset = checkNotNull(dataset);
if (dataset.supportsTransactions()) {
dataset.begin(readWrite);
}
}
public final void abort() {
if (dataset.supportsTransactionAbort()) {
dataset.abort();
}
}
public final void commit() {
if (dataset.supportsTransactions()) {
dataset.commit();
}
}
@Override
public final void close() {
if (dataset.supportsTransactions()) {
dataset.end();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy