Search in sources :

Example 1 with UpdateProcessor

use of org.apache.jena.update.UpdateProcessor in project jena by apache.

the class TestSPARQLProtocol method update_02.

@Test
public void update_02() {
    UpdateRequest update = UpdateFactory.create("INSERT DATA {}");
    UpdateProcessor proc = UpdateExecutionFactory.createRemoteForm(update, serviceUpdate());
    proc.execute();
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateProcessor(org.apache.jena.update.UpdateProcessor) Test(org.junit.Test)

Example 2 with UpdateProcessor

use of org.apache.jena.update.UpdateProcessor in project jena by apache.

the class FusekiTestServer method resetServer.

/*package*/
static void resetServer() {
    if (countServer.get() == 0)
        throw new RuntimeException("No server started!");
    if (CLEAR_DSG_DIRECTLY) {
        Txn.executeWrite(dsgTesting, () -> dsgTesting.clear());
    } else {
        Update clearRequest = new UpdateDrop(Target.ALL);
        UpdateProcessor proc = UpdateExecutionFactory.createRemote(clearRequest, serviceUpdate());
        try {
            proc.execute();
        } catch (Throwable e) {
            e.printStackTrace();
            throw e;
        }
    }
}
Also used : UpdateProcessor(org.apache.jena.update.UpdateProcessor) Update(org.apache.jena.update.Update) UpdateDrop(org.apache.jena.sparql.modify.request.UpdateDrop)

Example 3 with UpdateProcessor

use of org.apache.jena.update.UpdateProcessor in project jena by apache.

the class TestSPARQLProtocol method update_01.

@Test
public void update_01() {
    UpdateRequest update = UpdateFactory.create("INSERT DATA {}");
    UpdateProcessor proc = UpdateExecutionFactory.createRemote(update, serviceUpdate());
    proc.execute();
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateProcessor(org.apache.jena.update.UpdateProcessor) Test(org.junit.Test)

Example 4 with UpdateProcessor

use of org.apache.jena.update.UpdateProcessor in project jena by apache.

the class AbstractTestDatasetWithTextIndexBase method doUpdate.

protected void doUpdate(String updateString) {
    dataset.begin(ReadWrite.WRITE);
    UpdateRequest request = UpdateFactory.create(updateString);
    UpdateProcessor proc = UpdateExecutionFactory.create(request, dataset);
    proc.execute();
    dataset.commit();
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateProcessor(org.apache.jena.update.UpdateProcessor)

Example 5 with UpdateProcessor

use of org.apache.jena.update.UpdateProcessor in project jena by apache.

the class TestParameterizedSparqlString method test_param_string_bnode_3.

@Test
public void test_param_string_bnode_3() {
    // Test case related to treatment of blank nodes when injecting into
    // SPARQL updates using _: syntax
    Model model = ModelFactory.createDefaultModel();
    Resource bnode = model.createResource();
    bnode.addProperty(RDF.type, OWL.Thing);
    Assert.assertEquals(1, model.size());
    Dataset ds = DatasetFactory.create(model);
    // Use a parameterized query to check the data can be found
    ParameterizedSparqlString pq = new ParameterizedSparqlString();
    pq.setCommandText("SELECT * WHERE { ?s ?p ?o }");
    pq.setIri("s", "_:" + bnode.getId());
    Query q = pq.asQuery();
    try (QueryExecution qe = QueryExecutionFactory.create(q, ds)) {
        ResultSet rset = qe.execSelect();
        Assert.assertEquals(1, ResultSetFormatter.consume(rset));
    }
    // Use a parameterized update to modify the data
    ParameterizedSparqlString s = new ParameterizedSparqlString();
    s.setCommandText("INSERT { ?o ?p ?s } WHERE { ?s ?p ?o }");
    s.setIri("s", "_:" + bnode.getId());
    UpdateRequest query = s.asUpdate();
    UpdateProcessor proc = UpdateExecutionFactory.create(query, ds);
    proc.execute();
    // This should be true because this was present in the intial model set
    // up
    Assert.assertEquals(1, model.listStatements(bnode, null, (RDFNode) null).toList().size());
    // This should return 0 because the INSERT should result in a new blank
    // node being created rather than the existing one being reused becaue
    // of the semantics of blank nodes usage in templates
    Assert.assertEquals(0, model.listStatements(null, null, bnode).toList().size());
}
Also used : UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateProcessor(org.apache.jena.update.UpdateProcessor) Test(org.junit.Test)

Aggregations

UpdateProcessor (org.apache.jena.update.UpdateProcessor)16 UpdateRequest (org.apache.jena.update.UpdateRequest)7 Test (org.junit.Test)7 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)3 UpdateDrop (org.apache.jena.sparql.modify.request.UpdateDrop)3 Update (org.apache.jena.update.Update)3 SQLException (java.sql.SQLException)1 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)1 After (org.junit.After)1 Before (org.junit.Before)1