Package org.openrdf.query.algebra

Examples of org.openrdf.query.algebra.And


      /* first condition is that none are bound: this is the case where the subject
       * is not a restricted resource (and therefore has no associated attributes)
       *
       * And(Not(Bound(?acl_attr1)), Not(Bound(?acl_attr_1), ...)
       */
      And and = new And();
      for (Var attributeVar : attributeVars) {
        and.addArg(new Not(new Bound(attributeVar)));
      }

      if (and.getArgs().size() == 1) {
        filterConditions.addArg(and.getArg(0));
      }
      else {
        filterConditions.addArg(and);
      }

      if (permissions == null) {
        List<URI> roles = getRolesForUser(getCurrentUser());
        permissions = getAssignedPermissions(roles, ACL.VIEW);
      }

      // for each permission, we add an additional condition to the filter,
      // checking that either
      // team, or status, or both match.
      for (URI permission : permissions) {
        And permissionCondition = new And();

        for (int j = 0; j < attributes.size(); j++) {
          URI attribute = attributes.get(j);
          URI attributePermissionValue = getAttributeValueForPermission(permission, attribute);

          Compare attributeValueCompare = null;
          if (attributePermissionValue != null) {
            attributeValueCompare = new Compare(attributeVars.get(j), new Var("acl_attr_val_" + j,
                attributePermissionValue));
            permissionCondition.addArg(attributeValueCompare);
          }
        }

        if (permissionCondition.getNumberOfArguments() == 1) {
          filterConditions.addArg(permissionCondition.getArg(0));
        }
        else {
          // add the permission-defined condition to the set of Or-ed
          // filter conditions.
          filterConditions.addArg(permissionCondition);
View Full Code Here


    @Override
    public void meet(LeftJoin node) {
      super.meet(node);
      ValueExpr condition = node.getCondition();
      if (condition != null) {
        And and = new And();
        List<ValueExpr> constraints = new ArrayList<ValueExpr>(16);
        getConjunctiveConstraints(condition, constraints);

        for (int i = constraints.size() - 1; i >= 0; i--) {
          ValueExpr constraint = constraints.get(i);
          TupleExpr right = node.getRightArg();
          Set<String> filterVars = new VarFinder(constraint).getVars();
          if (right.getBindingNames().containsAll(filterVars)) {
            node.setRightArg(new Filter(right.clone(), constraint.clone()));
          }
          else {
            and.addArg(constraint);
          }
        }
        if (and.getNumberOfArguments() > 1) {
          node.setCondition(and);
        }
        else if (and.getNumberOfArguments() == 1) {
          node.setCondition(and.getArg(0));
        }
        else {
          node.setCondition(null);
        }
      }
View Full Code Here

      filter.setArg(filterArg);
    }

    protected void getConjunctiveConstraints(ValueExpr valueExpr, List<ValueExpr> conjunctiveConstraints) {
      if (valueExpr instanceof And) {
        And and = (And)valueExpr;
        for (ValueExpr arg : and.getArgs()) {
          getConjunctiveConstraints(arg, conjunctiveConstraints);
        }
      }
      else {
        conjunctiveConstraints.add(valueExpr);
View Full Code Here

  @Override
  public ValueExpr visit(ASTAnd node, Object data)
    throws VisitorException
  {
    And and = new And();

    for (ASTBooleanExpr expr : node.getOperandList()) {
      ValueExpr arg = (ValueExpr)expr.jjtAccept(this, null);
      and.addArg(arg);
    }

    return and;
  }
View Full Code Here

    if (constraints.isEmpty()) {
      leftJoin = new LeftJoin(leftArg, rightArg);
    }
    else {
      ValueExpr constraint = new And(constraints);

      leftJoin = new LeftJoin(leftArg, rightArg, constraint);
    }

    graphPattern = parentGP;
View Full Code Here

    if (constraints.isEmpty()) {
      optTE = new OptionalTupleExpr(tupleExpr);
    }
    else {
      ValueExpr constraint = new And(constraints);

      optTE = new OptionalTupleExpr(tupleExpr, constraint);
    }

    optionalTEs.add(optTE);
View Full Code Here

  public Object visit(ASTAnd node, Object data)
    throws VisitorException
  {
    ValueExpr leftArg = (ValueExpr)node.jjtGetChild(0).jjtAccept(this, null);
    ValueExpr rightArg = (ValueExpr)node.jjtGetChild(1).jjtAccept(this, null);
    return new And(leftArg, rightArg);
  }
View Full Code Here

        catch (UnsupportedRdbmsOperatorException e) {
          if (condition == null) {
            condition = expr;
          }
          else {
            condition = new And(condition, expr);
          }
        }
      }
      if (condition == null) {
        node.replaceWith(node.getArg());
View Full Code Here

    return flatten(condition, new ArrayList<ValueExpr>());
  }

  private List<ValueExpr> flatten(ValueExpr condition, List<ValueExpr> conditions) {
    if (condition instanceof And) {
      And and = (And)condition;
      for (ValueExpr arg : and.getArgs()) {
        flatten(arg, conditions);
      }
    }
    else {
      conditions.add(condition);
View Full Code Here

   
    public ValueExpr joinConditions() {
        ValueExpr expr = null;
       
        for (ValueExpr ve : _conditions) {
            expr = (expr == null) ? ve : new And(expr, ve);
        }
       
        return expr;
    }
View Full Code Here

TOP

Related Classes of org.openrdf.query.algebra.And

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.