Search in sources :

Example 1 with ExprRewriter

use of org.apache.jena.arq.querybuilder.rewriters.ExprRewriter in project jena by apache.

the class SolutionModifierHandler method setVars.

@Override
public void setVars(Map<Var, Node> values) {
    if (values.isEmpty()) {
        return;
    }
    ExprRewriter exprRewriter = new ExprRewriter(values);
    ExprList having = exprRewriter.rewrite(new ExprList(query.getHavingExprs()));
    List<SortCondition> orderBy = exprRewriter.rewriteSortConditionList(query.getOrderBy());
    VarExprList groupBy = exprRewriter.rewrite(query.getGroupBy());
    query.getHavingExprs().clear();
    query.getHavingExprs().addAll(having.getList());
    if (orderBy != null) {
        if (query.getOrderBy() == null) {
            for (SortCondition sc : orderBy) {
                query.addOrderBy(sc);
            }
        } else {
            query.getOrderBy().clear();
            query.getOrderBy().addAll(orderBy);
        }
    }
    query.getGroupBy().clear();
    query.getGroupBy().addAll(groupBy);
}
Also used : SortCondition(org.apache.jena.query.SortCondition) ExprRewriter(org.apache.jena.arq.querybuilder.rewriters.ExprRewriter) ExprList(org.apache.jena.sparql.expr.ExprList) VarExprList(org.apache.jena.sparql.core.VarExprList) VarExprList(org.apache.jena.sparql.core.VarExprList)

Aggregations

ExprRewriter (org.apache.jena.arq.querybuilder.rewriters.ExprRewriter)1 SortCondition (org.apache.jena.query.SortCondition)1 VarExprList (org.apache.jena.sparql.core.VarExprList)1 ExprList (org.apache.jena.sparql.expr.ExprList)1