Search in sources :

Example 91 with UpdateRequest

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());
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateProcessor(org.apache.jena.update.UpdateProcessor) Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model)

Example 92 with UpdateRequest

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());
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateDataInsert(org.apache.jena.sparql.modify.request.UpdateDataInsert) Update(org.apache.jena.update.Update) Test(org.junit.Test)

Example 93 with UpdateRequest

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);
    }
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) Test(org.junit.Test)

Example 94 with UpdateRequest

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());
    }
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateExecutionBuilder(org.apache.jena.update.UpdateExecutionBuilder) UpdateExecution(org.apache.jena.update.UpdateExecution) Test(org.junit.Test)

Example 95 with UpdateRequest

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);
    }
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) Test(org.junit.Test)

Aggregations

UpdateRequest (org.apache.jena.update.UpdateRequest)130 Test (org.junit.Test)85 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)20 UpdateProcessor (org.apache.jena.update.UpdateProcessor)14 UpdateProcessRemoteBase (org.apache.jena.sparql.modify.UpdateProcessRemoteBase)13 Model (org.apache.jena.rdf.model.Model)10 Dataset (org.apache.jena.query.Dataset)9 UpdateExecution (org.apache.jena.update.UpdateExecution)9 Node (org.apache.jena.graph.Node)7 RDFNode (org.apache.jena.rdf.model.RDFNode)6 Resource (org.apache.jena.rdf.model.Resource)6 HttpTest (org.apache.jena.fuseki.test.HttpTest)5 URI (java.net.URI)4 HashMap (java.util.HashMap)4 Syntax (org.apache.jena.query.Syntax)4 Context (org.apache.jena.sparql.util.Context)4 AuthScope (org.apache.http.auth.AuthScope)3 Literal (org.apache.jena.rdf.model.Literal)3 Update (org.apache.jena.update.Update)3 StringWriter (java.io.StringWriter)2