use of org.apache.jena.sparql.modify.request.QuadAcc in project jena by apache.
the class QueryTransformOps method mutateConstruct.
// Transform CONSTRUCT query template
private static void mutateConstruct(Query query, Query query2, ElementTransform transform) {
if (query.isConstructQuad()) {
Template template = query.getConstructTemplate();
List<Quad> quads = template.getQuads();
QuadAcc accQuads = new QuadAcc();
quads.forEach(quad1 -> {
Quad quad2 = transform.transform(quad1);
accQuads.addQuad(quad2);
});
Template template2 = new Template(accQuads);
query2.setConstructTemplate(template2);
return;
}
if (query.isConstructType()) {
Template template = query.getConstructTemplate();
List<Triple> triples = template.getBGP().getList();
BasicPattern accTriple = new BasicPattern();
triples.forEach(triple1 -> {
Triple triple2 = transform.transform(triple1);
accTriple.add(triple2);
});
Template template2 = new Template(accTriple);
query2.setConstructTemplate(template2);
return;
}
}
use of org.apache.jena.sparql.modify.request.QuadAcc in project jena by apache.
the class UpdateBuilder method buildWhere.
// build updates with where clauses
private Update buildWhere() {
UpdateModify retval = new UpdateModify();
if (with != null) {
Node graph = values.get(with);
if (graph == null) {
graph = with;
}
retval.setWithIRI(graph);
}
QuadAcc acc;
Iterator<Quad> iter;
if (!inserts.isEmpty()) {
retval.setHasInsertClause(true);
acc = retval.getInsertAcc();
iter = getQuads(inserts);
while (iter.hasNext()) {
acc.addQuad(iter.next());
}
}
if (!deletes.isEmpty()) {
retval.setHasDeleteClause(true);
acc = retval.getDeleteAcc();
iter = getQuads(deletes);
while (iter.hasNext()) {
acc.addQuad(iter.next());
}
}
retval.setElement(whereProcessor.setVars(values).build());
return retval;
}
use of org.apache.jena.sparql.modify.request.QuadAcc in project jena by apache.
the class QueryTransformOps method mutateByQueryType.
// Do the result form part of the cloned query.
private static void mutateByQueryType(Query q2, ElementTransform transform, ExprTransform exprTransform) {
switch(q2.queryType()) {
case ASK:
break;
case CONSTRUCT:
// case CONSTRUCT_QUADS :
// Variables in CONSTRUCT template.
Template template = q2.getConstructTemplate();
QuadAcc acc = new QuadAcc();
List<Quad> quads = template.getQuads();
template.getQuads().forEach(q -> {
Node g = transform(q.getGraph(), exprTransform);
Node s = transform(q.getSubject(), exprTransform);
Node p = transform(q.getPredicate(), exprTransform);
Node o = transform(q.getObject(), exprTransform);
acc.addQuad(Quad.create(g, s, p, o));
});
Template template2 = new Template(acc);
q2.setConstructTemplate(template2);
break;
case DESCRIBE:
// Variables in describe.
mutateDescribeVar(q2.getProjectVars(), q2.getResultURIs(), exprTransform);
break;
case SELECT:
mutateVarExprList(q2.getProject(), exprTransform);
break;
case CONSTRUCT_JSON:
throw new UnsupportedOperationException("Transform of JSON template queries");
case UNKNOWN:
throw new JenaException("Unknown qu ery type");
}
}
Aggregations