use of org.apache.jena.sparql.syntax.ElementTriplesBlock in project jena by apache.
the class labelSearch method buildSyntax.
// Build SPARQL syntax and compile it.
// Not recommended.
private QueryIterator buildSyntax(QueryIterator input, Node nodeVar, String pattern, ExecutionContext execCxt) {
Var var2 = createNewVar();
// Triple patterns for ?x rdfs:label ?hiddenVar
ElementTriplesBlock elementBGP = new ElementTriplesBlock();
Triple t = new Triple(nodeVar, RDFS.label.asNode(), var2);
elementBGP.addTriple(t);
// Regular expression for regex(?hiddenVar, "pattern", "i")
Expr regex = new E_Regex(new ExprVar(var2.getName()), pattern, "i");
ElementGroup elementGroup = new ElementGroup();
elementGroup.addElement(elementBGP);
elementGroup.addElement(new ElementFilter(regex));
// Compile it.
// The better design is to build the Op structure programmatically,
Op op = Algebra.compile(elementGroup);
op = Algebra.optimize(op, execCxt.getContext());
return QC.execute(op, input, execCxt);
}
use of org.apache.jena.sparql.syntax.ElementTriplesBlock in project jena by apache.
the class UpdateEngineWorker method elementFromQuads.
protected Element elementFromQuads(List<Quad> quads) {
ElementGroup el = new ElementGroup();
ElementTriplesBlock x = new ElementTriplesBlock();
// Maybe empty??
el.addElement(x);
Node g = Quad.defaultGraphNodeGenerated;
for (Quad q : quads) {
if (q.getGraph() != g) {
g = q.getGraph();
x = new ElementTriplesBlock();
if (g == null || g == Quad.defaultGraphNodeGenerated)
el.addElement(x);
else {
ElementNamedGraph eng = new ElementNamedGraph(g, x);
el.addElement(eng);
}
}
x.addTriple(q.asTriple());
}
return el;
}
Aggregations