Search in sources :

Example 1 with UpdateExec

use of org.apache.jena.sparql.exec.UpdateExec in project jena by apache.

the class UpdateAction method execute$.

// All non-streaming updates come through here.
private static void execute$(UpdateRequest request, DatasetGraph datasetGraph, Binding inputBinding) {
    UpdateExec uProc = UpdateExec.newBuilder().update(request).dataset(datasetGraph).initialBinding(inputBinding).build();
    if (uProc == null)
        throw new ARQException("No suitable update procesors are registered/able to execute your updates");
    uProc.execute();
}
Also used : ARQException(org.apache.jena.sparql.ARQException) UpdateExec(org.apache.jena.sparql.exec.UpdateExec)

Example 2 with UpdateExec

use of org.apache.jena.sparql.exec.UpdateExec in project jena by apache.

the class AbstractTestRDFLink 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 (RDFLink link = link()) {
        UpdateExecBuilder updateBuilder = link.newUpdate();
        UpdateExec uExec = updateBuilder.update(update).build();
        Txn.executeWrite(link, () -> uExec.execute());
    }
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateExecBuilder(org.apache.jena.sparql.exec.UpdateExecBuilder) UpdateExec(org.apache.jena.sparql.exec.UpdateExec) Test(org.junit.Test)

Example 3 with UpdateExec

use of org.apache.jena.sparql.exec.UpdateExec in project jena by apache.

the class AbstractTestUpdateGraph method testInsertData1.

@Test
public void testInsertData1() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    defaultGraphData(gStore, graph1);
    QuadDataAcc acc = new QuadDataAcc();
    acc.addTriple(triple2);
    UpdateDataInsert insert = new UpdateDataInsert(acc);
    UpdateExec uProc = UpdateExec.dataset(gStore).update(insert).build();
    uProc.execute();
    assertFalse(graphEmpty(gStore.getDefaultGraph()));
    assertTrue(graphContains(gStore.getDefaultGraph(), triple1));
    assertTrue(graphContains(gStore.getDefaultGraph(), triple2));
}
Also used : UpdateExec(org.apache.jena.sparql.exec.UpdateExec) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 4 with UpdateExec

use of org.apache.jena.sparql.exec.UpdateExec in project jena by apache.

the class AbstractTestUpdateGraph method testDeleteData1.

@Test
public void testDeleteData1() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    defaultGraphData(gStore, graph1);
    QuadDataAcc acc = new QuadDataAcc();
    acc.addTriple(triple2);
    UpdateDataDelete delete = new UpdateDataDelete(acc);
    UpdateExec uProc = UpdateExec.dataset(gStore).update(delete).build();
    uProc.execute();
    assertFalse(graphEmpty(gStore.getDefaultGraph()));
    assertTrue(graphContains(gStore.getDefaultGraph(), triple1));
    assertFalse(graphContains(gStore.getDefaultGraph(), triple2));
}
Also used : UpdateExec(org.apache.jena.sparql.exec.UpdateExec) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 5 with UpdateExec

use of org.apache.jena.sparql.exec.UpdateExec in project jena by apache.

the class AbstractTestUpdateGraph method testDeleteData2.

@Test
public void testDeleteData2() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    defaultGraphData(gStore, graph1);
    QuadDataAcc acc = new QuadDataAcc();
    acc.addTriple(triple1);
    UpdateDataDelete delete = new UpdateDataDelete(acc);
    UpdateExec uProc = UpdateExec.dataset(gStore).update(delete).build();
    uProc.execute();
    assertTrue(graphEmpty(gStore.getDefaultGraph()));
    assertFalse(graphContains(gStore.getDefaultGraph(), triple1));
}
Also used : UpdateExec(org.apache.jena.sparql.exec.UpdateExec) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Aggregations

UpdateExec (org.apache.jena.sparql.exec.UpdateExec)5 Test (org.junit.Test)4 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)3 ARQException (org.apache.jena.sparql.ARQException)1 UpdateExecBuilder (org.apache.jena.sparql.exec.UpdateExecBuilder)1 UpdateRequest (org.apache.jena.update.UpdateRequest)1