Search in sources :

Example 26 with ExprList

use of org.apache.jena.sparql.expr.ExprList in project jena by apache.

the class ProcedureEval method exec.

@Override
public QueryIterator exec(Binding binding, Node name, ExprList args, ExecutionContext execCxt) {
    // Eval if possible.
    ExprList evalArgs = new ExprList();
    for (Expr e : args) {
        if (e.isVariable()) {
            Var v = e.getExprVar().asVar();
            // Special case - allow unevaluated variables.
            if (binding.contains(v))
                evalArgs.add(e.eval(binding, execCxt));
            else
                evalArgs.add(e);
        } else {
            NodeValue x = e.eval(binding, execCxt);
            evalArgs.add(x);
        }
    }
    return execEval(binding, evalArgs, execCxt);
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) ExprList(org.apache.jena.sparql.expr.ExprList) Var(org.apache.jena.sparql.core.Var)

Example 27 with ExprList

use of org.apache.jena.sparql.expr.ExprList 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

ExprList (org.apache.jena.sparql.expr.ExprList)27 Op (org.apache.jena.sparql.algebra.Op)17 Expr (org.apache.jena.sparql.expr.Expr)15 Var (org.apache.jena.sparql.core.Var)11 Node (org.apache.jena.graph.Node)3 Triple (org.apache.jena.graph.Triple)3 HashSet (java.util.HashSet)2 OpFilter (org.apache.jena.sparql.algebra.op.OpFilter)2 BasicPattern (org.apache.jena.sparql.core.BasicPattern)2 Test (org.junit.Test)2 ExprRewriter (org.apache.jena.arq.querybuilder.rewriters.ExprRewriter)1 MockSecurityEvaluator (org.apache.jena.permissions.MockSecurityEvaluator)1 SecurityEvaluator (org.apache.jena.permissions.SecurityEvaluator)1 OpRewriter (org.apache.jena.permissions.query.rewriter.OpRewriter)1 SecuredFunction (org.apache.jena.permissions.query.rewriter.SecuredFunction)1 SortCondition (org.apache.jena.query.SortCondition)1 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)1 VarExprList (org.apache.jena.sparql.core.VarExprList)1 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)1 NodeValue (org.apache.jena.sparql.expr.NodeValue)1