use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestService method update_service_context_application_01.
@Test
public void update_service_context_application_01() {
// This test requires no service context to be set
@SuppressWarnings("unchecked") Map<String, Context> serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
if (serviceContextMap != null) {
serviceContextMap.remove(SERVICE);
}
UpdateRequest updates = UpdateFactory.create("CREATE GRAPH <http://example>");
UpdateProcessRemoteBase engine = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, SERVICE);
Assert.assertNotNull(engine);
// Check that no settings were changed
Assert.assertNull(engine.getClient());
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class update method execOne.
private void execOne(String requestString, DatasetGraph store) {
UpdateRequest req = UpdateFactory.create(requestString, updateSyntax);
UpdateExecutionFactory.create(req, store).execute();
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class update method execOneFile.
private void execOneFile(String filename, DatasetGraph store) {
UpdateRequest req = UpdateFactory.read(filename, updateSyntax);
UpdateExecutionFactory.create(req, store).execute();
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class rupdate method exec.
@Override
protected void exec() {
if (modRemote.getServiceURL() == null) {
throw new CmdException("No endpoint given");
}
String endpoint = modRemote.getServiceURL();
for (String filename : requestFiles) {
UpdateRequest req = UpdateFactory.read(filename);
exec(endpoint, req);
}
for (String requestString : super.getPositional()) {
requestString = indirect(requestString);
UpdateRequest req = UpdateFactory.create(requestString);
exec(endpoint, req);
}
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class UpdateBuilderExampleTests method example4.
/**
* Example 4:
*
* @see https://www.w3.org/TR/sparql11-update/#example_4
*/
@Test
public void example4() {
Resource r = ResourceFactory.createResource("http://example/book1");
Node graphName = NodeFactory.createURI("http://example/bookStore");
Dataset ds = DatasetFactory.create();
ds.addNamedModel(graphName.getURI(), m);
m.setNsPrefix("dc", DC_11.NS);
m.add(r, DC_11.title, "Fundamentals of Compiler Desing");
SelectBuilder sb = new SelectBuilder().addWhere(r, DC_11.title, "Fundamentals of Compiler Desing");
sb = new SelectBuilder().addPrefix("dc", DC_11.NS).addGraph(graphName, sb);
UpdateBuilder builder = new UpdateBuilder().addPrefix("dc", DC_11.NS).addDelete(sb);
UpdateRequest req = builder.buildRequest();
sb = new SelectBuilder().addWhere(r, DC_11.title, "Fundamentals of Compiler Design");
sb = new SelectBuilder().addPrefix("dc", DC_11.NS).addGraph(graphName, sb);
builder = new UpdateBuilder().addPrefix("dc", DC_11.NS).addInsert(sb);
builder.appendTo(req);
UpdateAction.execute(req, ds);
Model m2 = ds.getNamedModel(graphName.getURI());
assertTrue(m2.contains(r, DC_11.title, "Fundamentals of Compiler Design"));
assertEquals(1, m2.listStatements().toSet().size());
// assertEquals( 1, m2.getNsPrefixMap().size());
// assertEquals( DC.NS, m2.getNsPrefixMap().get("dc"));
}
Aggregations