use of org.apache.jena.sparql.syntax.ElementGroup in project jena by apache.
the class QueryExecutionBase method execDescribe.
@Override
public Model execDescribe(Model model) {
checkNotClosed();
if (!query.isDescribeType())
throw new QueryExecException("Attempt to get a DESCRIBE result from a " + labelForQuery(query) + " query");
//Was: query.setQueryResultStar(true) ; but why?
query.setResultVars();
// If there was no WhereClause, use an empty pattern (one solution, no columns).
if (query.getQueryPattern() == null)
query.setQueryPattern(new ElementGroup());
Set<RDFNode> set = new HashSet<>();
//May return null (no query pattern)
ResultSet qRes = execResultSet();
// Prefixes for result (after initialization)
insertPrefixesInto(model);
if (qRes != null) {
for (; qRes.hasNext(); ) {
QuerySolution rb = qRes.nextSolution();
for (String varName : query.getResultVars()) {
RDFNode n = rb.get(varName);
set.add(n);
}
}
}
if (query.getResultURIs() != null) {
// Any URIs in the DESCRIBE
for (Node n : query.getResultURIs()) {
// Need to make dataset available to describe handlers.
RDFNode rNode = ModelUtils.convertGraphNodeToRDFNode(n, dataset.getDefaultModel());
set.add(rNode);
}
}
// Create new handlers for this process.
List<DescribeHandler> dhList = DescribeHandlerRegistry.get().newHandlerList();
getContext().put(ARQConstants.sysCurrentDataset, getDataset());
// Notify start of describe phase
for (DescribeHandler dh : dhList) dh.start(model, getContext());
// Do describe for each resource found.
for (RDFNode n : set) {
if (n instanceof Resource) {
for (DescribeHandler dh : dhList) {
dh.describe((Resource) n);
}
} else {
// Can't describe literals
continue;
}
}
for (DescribeHandler dh : dhList) dh.finish();
this.close();
return model;
}
use of org.apache.jena.sparql.syntax.ElementGroup in project jena by apache.
the class TestBlankNodeBinary method bNodeSPARQL_Query_1.
// Check SPARQL parsing.
@Test
public void bNodeSPARQL_Query_1() {
String qs = "SELECT * { ?s ?p <_:ABC>}";
Query query = QueryFactory.create(qs);
Element el = ((ElementGroup) query.getQueryPattern()).get(0);
ElementPathBlock epb = (ElementPathBlock) el;
TriplePath tp = epb.getPattern().get(0);
Triple t = tp.asTriple();
assertEquals("ABC", t.getObject().getBlankNodeLabel());
}
use of org.apache.jena.sparql.syntax.ElementGroup in project jena by apache.
the class TestService method makeElt.
/*package*/
static ElementService makeElt(EnvTest env) {
Node serviceNode = NodeFactory.createURI(env.datasetURL());
ElementGroup elt = new ElementGroup();
Element elt1 = new ElementTriplesBlock(bgp);
elt.addElement(elt1);
ElementService eltService = new ElementService(SERVICE, elt);
return eltService;
}
use of org.apache.jena.sparql.syntax.ElementGroup in project jena by apache.
the class TestService method makeOp.
/*package*/
static OpService makeOp(EnvTest env, Node serviceNode) {
ElementGroup elt = new ElementGroup();
Element elt1 = new ElementTriplesBlock(bgp);
elt.addElement(elt1);
Op subOp = Algebra.compile(elt1);
// ElementService eltService = new ElementService(SERVICE, elt);
OpService opService = new OpService(serviceNode, subOp, false);
return opService;
}
use of org.apache.jena.sparql.syntax.ElementGroup in project jena by apache.
the class TestService method makeOpElt.
/*package*/
static OpService makeOpElt(EnvTest env) {
Node serviceNode = NodeFactory.createURI(env.datasetURL());
ElementGroup elt = new ElementGroup();
Element elt1 = new ElementTriplesBlock(bgp);
elt.addElement(elt1);
Op subOp = Algebra.compile(elt1);
ElementService eltService = new ElementService(SERVICE, elt);
OpService opService = new OpService(serviceNode, subOp, eltService, false);
return opService;
}
Aggregations