use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class UpdateTransformOps method transform.
public static UpdateRequest transform(UpdateRequest update, ElementTransform transform, ExprTransform exprTransform) {
UpdateRequest req = new UpdateRequest();
req.getPrefixMapping().setNsPrefixes(update.getPrefixMapping());
for (Update up : update.getOperations()) {
up = transform(up, transform, exprTransform);
req.add(up);
}
return req;
}
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;
// And some checking.
IndentedLineBuffer w = new IndentedLineBuffer();
UpdateWriter.output(req, w);
String updateString2 = w.asString();
UpdateRequest req2 = null;
try {
req2 = UpdateFactory.create(updateString2, syntax);
} catch (QueryParseException ex) {
System.err.println("Can not reparse update after serialization");
System.err.println(updateString2);
}
if (!req.equalTo(req2))
System.err.println("Reparsed update does not .equalTo original parsed request");
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class sdbupdate method execOneFile.
private void execOneFile(String filename, Dataset store) {
UpdateRequest req = UpdateFactory.read(filename, Syntax.syntaxARQ);
UpdateExecutionFactory.create(req, store).execute();
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestSyntaxTransform method testUpdateModel.
private void testUpdateModel(String input, String output, String varStr, String valStr) {
UpdateRequest req1 = UpdateFactory.create(PREFIX + input);
UpdateRequest reqExpected = UpdateFactory.create(PREFIX + output);
Map<String, RDFNode> map = new HashMap<>();
Node n = SSE.parseNode(valStr);
RDFNode x = ModelUtils.convertGraphNodeToRDFNode(n);
map.put(varStr, x);
UpdateRequest reqTrans = UpdateTransformOps.transformUpdate(req1, map);
// Crude.
String x1 = reqExpected.toString().replaceAll("[ \n\t]", "");
String x2 = reqTrans.toString().replaceAll("[ \n\t]", "");
//assertEquals(reqExpected, reqTrans) ;
assertEquals(x1, x2);
}
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);
}
Aggregations