use of org.apache.jena.update.UpdateRequest in project webofneeds by researchstudio-sat.
the class GetAgreementsTests method condenseTestCaseByQuery.
private static void condenseTestCaseByQuery(Path resource, String outputPath) throws Exception {
String condensationQuery = readCondensationQuery();
UpdateRequest update = UpdateFactory.create(condensationQuery);
Dataset condensedDataset = loadDatasetFromFileSystem(resource.toFile().getAbsolutePath());
UpdateProcessor updateProcessor = UpdateExecutionFactory.create(update, condensedDataset);
updateProcessor.execute();
Iterator<String> graphNames = condensedDataset.listNames();
while (graphNames.hasNext()) {
Model graph = condensedDataset.getNamedModel(graphNames.next());
if (graph.isEmpty()) {
graphNames.remove();
}
}
RDFDataMgr.write(new FileOutputStream(outputPath + resource.getFileName()), condensedDataset, Lang.TRIG);
System.out.println("wrote condensed input file to: " + outputPath + resource.getFileName());
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestBlankNodeBinary method bNodeSPARQL_Update_1.
@Test
public void bNodeSPARQL_Update_1() {
String str = "INSERT DATA { <x:s> <x:p> <_:789> }";
UpdateRequest req = UpdateFactory.create(str);
Update update = req.getOperations().get(0);
UpdateDataInsert ins = (UpdateDataInsert) update;
Node obj = ins.getQuads().get(0).getObject();
assertEquals("789", obj.getBlankNodeLabel());
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class TestUpdateExecHTTP method update_form_2.
@Test
public void update_form_2() {
UpdateRequest req = UpdateFactory.create("INSERT DATA { <x:s> <x:p> 567 } ");
UpdateExecHTTP uExec = UpdateExecHTTP.newBuilder().endpoint(service()).sendMode(UpdateSendMode.asPostForm).update(req).build();
uExec.execute();
try (QueryExecHTTP qExec = QueryExecHTTP.newBuilder().endpoint(serviceQuery()).queryString("ASK { ?s ?p 567 }").build()) {
boolean b = qExec.ask();
assertTrue(b);
}
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class AbstractTestRDFConnection method update_05.
@Test
public void update_05() {
UpdateRequest update = new UpdateRequest();
update.add("INSERT DATA { <urn:ex:s> <urn:ex:p> <urn:ex:o>}");
try (RDFConnection conn = connection()) {
UpdateExecutionBuilder updateBuilder = conn.newUpdate();
UpdateExecution uExec = updateBuilder.update(update).build();
Txn.executeWrite(conn, () -> uExec.execute());
}
}
use of org.apache.jena.update.UpdateRequest in project jena by apache.
the class AbstractTestRDFConnection method update_03.
@Test
public void update_03() {
UpdateRequest update = new UpdateRequest();
update.add("INSERT DATA { <urn:ex:s> <urn:ex:p> <urn:ex:o>}");
try (RDFConnection conn = connection()) {
conn.update(update);
}
}
Aggregations