use of org.apache.jena.query.QuerySolution in project autoindex by dice-group.
the class AutoIndexTest method testgetallclasses.
public void testgetallclasses() {
seh.setLang("en");
seh.setBaseUri(endpoint);
ResultSet results = seh.getallclasses();
assertNotNull(results);
List<QuerySolution> asText = ResultSetFormatter.toList(results);
Joiner listOfResults = Joiner.on("\n");
System.out.println("Classes Results" + listOfResults.join(asText));
System.out.println("Total Visible Results = " + asText.size());
Assert.assertTrue(asText.size() > 1);
}
use of org.apache.jena.query.QuerySolution in project jena by apache.
the class TestAPI method testInitialBindings3.
@Test
public void testInitialBindings3() {
QuerySolutionMap init = new QuerySolutionMap();
init.add("z", m.createLiteral("zzz"));
String qs = "SELECT * {?s ?p 'x1'}";
try (QueryExecution qExec = QueryExecution.model(m).query(qs).initialBinding(init).build()) {
ResultSet rs = qExec.execSelect();
QuerySolution qSoln = rs.nextSolution();
assertTrue("Initial setting not set correctly now", qSoln.getLiteral("z").getLexicalForm().equals("zzz"));
}
}
use of org.apache.jena.query.QuerySolution in project jena by apache.
the class TestSecurityFilterLocal method subjects.
private Set<Node> subjects(DatasetGraph dsg, String queryString, SecurityContext sCxt) {
final DatasetGraph dsg1 = applyFilterDSG ? DataAccessCtl.filteredDataset(dsg, sCxt) : dsg;
Dataset ds = DatasetFactory.wrap(dsg1);
return Txn.calculateRead(ds, () -> {
try (QueryExecution qExec = QueryExecutionFactory.create(queryString, ds)) {
// }
if (applyFilterTDB)
sCxt.filterTDB(dsg1, qExec);
List<QuerySolution> results = Iter.toList(qExec.execSelect());
Stream<Node> stream = results.stream().map(qs -> qs.get("s")).filter(Objects::nonNull).map(RDFNode::asNode);
return SetUtils.toSet(stream);
}
});
}
use of org.apache.jena.query.QuerySolution in project jena by apache.
the class TestSecurityFilterLocal method graphs.
private Set<Node> graphs(DatasetGraph dsg, SecurityContext sCxt) {
// Either applyFilterDSG or applyFilterTDB
final DatasetGraph dsg1 = applyFilterDSG ? DataAccessCtl.filteredDataset(dsg, sCxt) : dsg;
Dataset ds = DatasetFactory.wrap(dsg1);
return Txn.calculateRead(ds, () -> {
try (QueryExecution qExec = QueryExecutionFactory.create(queryGraphNames, ds)) {
if (applyFilterTDB)
sCxt.filterTDB(dsg1, qExec);
List<QuerySolution> results = Iter.toList(qExec.execSelect());
Stream<Node> stream = results.stream().map(qs -> qs.get("g")).filter(Objects::nonNull).map(RDFNode::asNode);
return SetUtils.toSet(stream);
}
});
}
use of org.apache.jena.query.QuerySolution in project jena by apache.
the class TestSecurityFilterLocal method subjects.
private Set<Node> subjects(DatasetGraph dsg, Function<DatasetGraph, Graph> graphChoice, String queryString, SecurityContext sCxt) {
final DatasetGraph dsg1 = applyFilterDSG ? DataAccessCtl.filteredDataset(dsg, sCxt) : dsg;
Graph graph = graphChoice.apply(dsg1);
if (graph == null)
// Can't see the graph.
return Collections.emptySet();
Model model = ModelFactory.createModelForGraph(graph);
return Txn.calculateRead(testdsg, () -> {
try (QueryExecution qExec = QueryExecutionFactory.create(queryString, model)) {
if (applyFilterTDB)
sCxt.filterTDB(dsg1, qExec);
List<QuerySolution> results = Iter.toList(qExec.execSelect());
Stream<Node> stream = results.stream().map(qs -> qs.get("s")).filter(Objects::nonNull).map(RDFNode::asNode);
return SetUtils.toSet(stream);
}
});
}
Aggregations