use of org.apache.jena.update.UpdateExecution in project jena by apache.
the class AbstractTestDatasetWithTextIndexBase method doUpdate.
protected void doUpdate(String updateString) {
dataset.begin(ReadWrite.WRITE);
UpdateRequest request = UpdateFactory.create(updateString);
UpdateExecution proc = UpdateExecutionFactory.create(request, dataset);
proc.execute();
dataset.commit();
}
use of org.apache.jena.update.UpdateExecution 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.wrap(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();
UpdateExecution 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());
}
use of org.apache.jena.update.UpdateExecution in project jena by apache.
the class TestAuthUpdate_JDK method update_authenv_01_good.
@Test
public void update_authenv_01_good() {
// Auth credentials for valid user with correct password
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateExecution ue = UpdateExecutionHTTP.create().endpoint(databaseURL()).update(updates).build();
String dsURL = databaseURL();
URI uri = URI.create(dsURL);
AuthEnv.get().registerUsernamePassword(uri, "allowed", "password");
try {
ue.execute();
} finally {
AuthEnv.get().unregisterUsernamePassword(uri);
}
}
use of org.apache.jena.update.UpdateExecution in project jena by apache.
the class TestAuthUpdate_JDK method update_with_auth_04.
@Test
public void update_with_auth_04() {
UpdateRequest updates = UpdateFactory.create("CREATE SILENT GRAPH <http://graph>");
UpdateExecution ue = withAuthJDK(UpdateExecutionHTTP.create().endpoint(databaseURL()).update(updates), "allowed", "password");
ue.execute();
}
use of org.apache.jena.update.UpdateExecution in project jena by apache.
the class ExTDB_Txn2 method execUpdate.
public static void execUpdate(String sparqlUpdateString, Dataset dataset) {
UpdateRequest request = UpdateFactory.create(sparqlUpdateString);
UpdateExecution proc = UpdateExecutionFactory.create(request, dataset);
proc.execute();
}
Aggregations