Search in sources :

Example 1 with Not

use of org.eclipse.rdf4j.query.algebra.Not in project rdf4j by eclipse.

the class QueryModelBuilder method visit.

@Override
public List<Var> visit(ASTNode node, Object data) throws VisitorException {
    List<Var> nodeVars = new ArrayList<Var>();
    for (ASTNodeElem nodeElem : node.getNodeElemList()) {
        Var nodeVar = (Var) nodeElem.jjtAccept(this, null);
        nodeVars.add(nodeVar);
    }
    // Create any implicit unequalities
    for (int i = 0; i < nodeVars.size() - 1; i++) {
        Var var1 = nodeVars.get(i);
        for (int j = i + 1; j < nodeVars.size(); j++) {
            Var var2 = nodeVars.get(j);
            // for the unequality to make any sense:
            if (!var1.hasValue() || !var2.hasValue()) {
                graphPattern.addConstraint(new Not(new SameTerm(var1, var2)));
            }
        }
    }
    return nodeVars;
}
Also used : ASTNot(org.eclipse.rdf4j.query.parser.serql.ast.ASTNot) Not(org.eclipse.rdf4j.query.algebra.Not) ASTVar(org.eclipse.rdf4j.query.parser.serql.ast.ASTVar) Var(org.eclipse.rdf4j.query.algebra.Var) ASTSameTerm(org.eclipse.rdf4j.query.parser.serql.ast.ASTSameTerm) SameTerm(org.eclipse.rdf4j.query.algebra.SameTerm) ArrayList(java.util.ArrayList) ASTNodeElem(org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem)

Example 2 with Not

use of org.eclipse.rdf4j.query.algebra.Not in project rdf4j by eclipse.

the class TupleExprBuilder method visit.

@Override
public Not visit(ASTNotExistsFunc node, Object data) throws VisitorException {
    GraphPattern parentGP = graphPattern;
    graphPattern = new GraphPattern(parentGP);
    Exists e = new Exists();
    node.jjtGetChild(0).jjtAccept(this, e);
    TupleExpr te = graphPattern.buildTupleExpr();
    e.setSubQuery(te);
    graphPattern = parentGP;
    return new Not(e);
}
Also used : Not(org.eclipse.rdf4j.query.algebra.Not) Exists(org.eclipse.rdf4j.query.algebra.Exists) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr)

Aggregations

Not (org.eclipse.rdf4j.query.algebra.Not)2 ArrayList (java.util.ArrayList)1 Exists (org.eclipse.rdf4j.query.algebra.Exists)1 SameTerm (org.eclipse.rdf4j.query.algebra.SameTerm)1 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)1 Var (org.eclipse.rdf4j.query.algebra.Var)1 ASTNodeElem (org.eclipse.rdf4j.query.parser.serql.ast.ASTNodeElem)1 ASTNot (org.eclipse.rdf4j.query.parser.serql.ast.ASTNot)1 ASTSameTerm (org.eclipse.rdf4j.query.parser.serql.ast.ASTSameTerm)1 ASTVar (org.eclipse.rdf4j.query.parser.serql.ast.ASTVar)1