use of org.apache.jena.query.QuerySolutionMap in project jena by apache.
the class TestAPI method testInitialBindings4.
@Test
public void testInitialBindings4() {
// Test derived from report by Holger Knublauch
String queryString = "PREFIX : <" + ns + ">\n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT * \n" + "WHERE { \n" + " ?x :p1 ?z ." + " NOT EXISTS { \n" + " ?x rdfs:label ?z . \n" + " }\n" + "}";
Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
QuerySolutionMap map = new QuerySolutionMap();
map.add("this", OWL.Thing);
try (QueryExecution qExec = QueryExecution.model(m).query(queryString).initialBinding(map).build()) {
ResultSet rs = qExec.execSelect();
while (rs.hasNext()) {
QuerySolution qs = rs.nextSolution();
}
}
}
use of org.apache.jena.query.QuerySolutionMap in project jena by apache.
the class TestAPI method testInitialBindingsConstruct1.
@Test
public void testInitialBindingsConstruct1() {
QuerySolutionMap init = new QuerySolutionMap();
init.add("z", m.createLiteral("zzz"));
String qs = "CONSTRUCT {?s ?p ?z} {?s ?p 'x1'}";
try (QueryExecution qExec = QueryExecution.model(m).query(qs).initialBinding(init).build()) {
Model r = qExec.execConstruct();
assertTrue("Empty model", r.size() > 0);
Property p1 = m.createProperty(ns + "p1");
assertTrue("Empty model", r.contains(null, p1, init.get("z")));
}
}
Aggregations