use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class ExTDB_Txn2 method execUpdate.
public static void execUpdate(String sparqlUpdateString, GraphStore graphStore) {
UpdateRequest request = UpdateFactory.create(sparqlUpdateString);
UpdateProcessor proc = UpdateExecutionFactory.create(request, graphStore);
proc.execute();
}
use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class JenaStatement method executeUpdate.
private int executeUpdate(UpdateRequest u) throws SQLException {
if (this.isClosed())
throw new SQLException("The Statement is closed");
if (this.connection.isReadOnly())
throw new SQLException("The JDBC connection is currently in read-only mode, updates are not permitted");
// Do we need transactions?
boolean needsBegin = (!this.autoCommit && this.transactionLevel != Connection.TRANSACTION_NONE && !this.hasActiveTransaction());
boolean needsCommit = (this.autoCommit && this.transactionLevel != Connection.TRANSACTION_NONE);
try {
// Start a Transaction if necessary
if (needsCommit || needsBegin) {
if (this.autoCommit) {
LOGGER.info("Running update in auto-commit mode");
} else {
LOGGER.info("Starting a new transaction to run update, transaction will not be auto-committed");
}
this.beginTransaction(ReadWrite.WRITE);
}
} catch (Exception e) {
LOGGER.error("Starting the new transaction failed", e);
throw new SQLException("Failed to start a new query transaction", e);
}
try {
// Pre-process the update
u = this.connection.applyPreProcessors(u);
// Execute updates
UpdateProcessor processor = this.createUpdateProcessor(u);
processor.execute();
// If auto-committing can commit immediately
if (needsCommit) {
LOGGER.info("Auto-committing update transaction");
this.commitTransaction();
}
return 0;
} catch (SQLException e) {
if (needsCommit) {
LOGGER.warn("Rolling back failed update transaction", e);
this.rollbackTransaction();
}
throw e;
} catch (Exception e) {
LOGGER.error("SPARQL Update evaluation failed", e);
if (needsCommit) {
LOGGER.warn("Rolling back failed update transaction");
this.rollbackTransaction();
}
throw new SQLException("Error occurred during SPARQL update evaluation", e);
}
}
use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class rupdate method exec.
private void exec(String endpoint, UpdateRequest req) {
UpdateProcessor proc = UpdateExecutionFactory.createRemote(req, endpoint);
proc.execute();
}
use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class TestRemoteEndpointResultsWithAuth method cleanupTest.
/**
* Clean up after each test by resetting the Fuseki instance
*/
@After
public void cleanupTest() {
Update clearRequest = new UpdateDrop(Target.ALL);
UpdateProcessor proc = UpdateExecutionFactory.createRemote(clearRequest, FusekiTestAuth.serviceUpdate(), client);
proc.execute();
}
use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class RDFConnectionRemote method update.
@Override
public void update(UpdateRequest update) {
checkUpdate();
UpdateProcessor proc = UpdateExecutionFactory.createRemote(update, svcUpdate, this.httpClient, this.httpContext);
exec(() -> proc.execute());
}
Aggregations