use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class RDFLinkHTTP method updateExec.
private void updateExec(UpdateRequest update, String updateString) {
checkUpdate();
if (update == null && updateString == null)
throw new InternalErrorException("Both update request and update string are null");
UpdateRequest actual = null;
if (update == null) {
if (parseCheckUpdates)
actual = UpdateFactory.create(updateString);
}
// Use the update string as provided if possible, otherwise serialize the update.
String updateStringToSend = (updateString != null) ? updateString : update.toString();
createUExecBuilder().updateString(updateStringToSend).build().execute();
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class Test_SPARQL_TDB method update.
private void update(Dataset dataset, String string) {
UpdateRequest req = UpdateFactory.create(string);
UpdateExec.newBuilder().update(req).dataset(dataset.asDatasetGraph()).execute();
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class JenaStatement method executeUpdate.
@Override
public final int executeUpdate(String sql) 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");
// Pre-process the command text
LOGGER.info("Received input command text:\n {}", sql);
sql = this.connection.applyPreProcessors(sql);
LOGGER.info("Command text after pre-processing:\n {}", sql);
UpdateRequest u = null;
try {
u = UpdateFactory.create(sql);
} catch (Exception e) {
LOGGER.error("Invalid SPARQL update", e);
throw new SQLException("Not a valid SPARQL Update", e);
}
if (u == null)
throw new SQLException("Unable to create a SPARQL Update Request");
return this.executeUpdate(u);
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class load method execUpdate.
@Override
protected void execUpdate(DatasetGraph dataset) {
if (loadFiles.size() == 0)
throw new CmdException("Nothing to do");
UpdateRequest req = new UpdateRequest();
for (String filename : loadFiles) {
UpdateLoad loadReq = new UpdateLoad(filename, graphName);
req.add(loadReq);
}
if (true) {
// Need a better way
monitor(dataset.getDefaultGraph());
for (Iterator<Node> iter = dataset.listGraphNodes(); iter.hasNext(); ) {
Graph g = dataset.getGraph(iter.next());
monitor(g);
}
}
UpdateExec.newBuilder().update(req).dataset(dataset).execute();
if (dump) {
IndentedWriter out = IndentedWriter.stdout;
SSE.write(dataset);
out.flush();
}
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class uparse method execOne.
private void execOne(String updateString, Syntax syntax) {
UpdateRequest req;
try {
req = UpdateFactory.create(updateString, syntax);
} catch (QueryParseException ex) {
System.err.print("Parse error: ");
System.err.println(ex.getMessage());
return;
}
// req.output(IndentedWriter.stderr) ;
if (printUpdate)
System.out.print(req);
if (printNone)
return;
try {
LogCtl.disable(QueryParserBase.ParserLoggerName);
checkUpdate(req, syntax);
} catch (UpdateCheckException ex) {
System.err.println();
System.err.println("**** Check failure: " + ex.getMessage());
if (ex.getCause() != null)
ex.getCause().printStackTrace(System.err);
} finally {
LogCtl.setLevel(QueryParserBase.ParserLoggerName, "INFO");
}
}
Aggregations