Examples of Var


Examples of org.openquark.cal.compiler.SourceModel.Expr.Var

         * @return true if expression is a Var that refers to Parameter (assuming that there are
         *          no intermediate same-name bindings between parameter's scope and expression's).
         */
        private boolean isParameterVar(Parameter parameter, Expr expression) {
            if(expression instanceof Var) {
                Var var = (Var)expression;
               
                return (var.getVarName().getUnqualifiedName().equals(parameter.getName()) &&
                        (var.getVarName().getModuleName() == null || super.resolveModuleName(var.getVarName().getModuleName()).equals(super.currentModule)));
               
            }
           
            return false;
        }
View Full Code Here

Examples of org.openrdf.query.algebra.Var

    throws StoreException
  {
    Map<String, Set<TupleExpr>> localJoins = new HashMap<String, Set<TupleExpr>>();

    for (TupleExpr joinArg : join.getArgs()) {
      Var subj = getLocalSubject(joinArg);

      if (subj != null) {
        Set<TupleExpr> localJoin = localJoins.get(subj.getName());
        if (localJoin == null) {
          localJoin = new HashSet<TupleExpr>();
          localJoins.put(subj.getName(), localJoin);
        }
        localJoin.add(joinArg);
      }
    }
View Full Code Here

Examples of org.openrdf.query.algebra.Var

  public void meet(LeftJoin leftJoin)
    throws StoreException
  {
    super.meet(leftJoin);

    Var leftSubject = getLocalSubject(leftJoin.getLeftArg());
    Var rightSubject = getLocalSubject(leftJoin.getRightArg());
    // if local then left and right can be combined
    boolean local = leftSubject != null && leftSubject.equals(rightSubject);
    SignedConnection leftOwner = getSingleOwner(leftJoin.getLeftArg());
    SignedConnection rightOwner = getSingleOwner(leftJoin.getRightArg());
    addOwners(leftJoin, leftOwner, rightOwner, local);
View Full Code Here

Examples of org.openrdf.query.algebra.Var

      Resource subj = (Resource)sp.getSubjectVar().getValue();
      URI pred = (URI)sp.getPredicateVar().getValue();
      Value obj = sp.getObjectVar().getValue();

      Resource[] ctx;
      Var contextVar = sp.getContextVar();
      if (contextVar == null || !contextVar.hasValue()) {
        ctx = new Resource[0];
      }
      else {
        ctx = new Resource[] { (Resource)contextVar.getValue() };
      }

      for (SignedConnection member : members) {
        if (member.hasMatch(subj, pred, obj, true, ctx)) {
          owners.add(member);
View Full Code Here

Examples of org.openrdf.query.algebra.Var

     */
    public Var getLocalSubject(TupleExpr arg)
      throws StoreException
    {
      boolean local_stack = local;
      Var relative_stack = relative;
      try {
        local = true;
        relative = null;
        arg.visit(this);
        return relative;
View Full Code Here

Examples of org.openrdf.query.algebra.Var

      super.meet(statementPattern);

      // keep a reference to the original parent.
      QueryModelNode parent = statementPattern.getParentNode();

      Var subjectVar = statementPattern.getSubjectVar();
      if (handledSubjects.contains(subjectVar)) {
        // we have already expanded the query for this particular subject
        return;
      }

      handledSubjects.add(subjectVar);

      /*
       * Create this pattern:
       *
       *  ?subject ?predicate ?object. (= the original statementPattern)
       *  OPTIONAL {
       *             { ?subject foo:accessAttr1 ?accessAttrValue1. }
       *             UNION
       *             { ?subject foo:inheritanceProp ?S1 .
       *               ?S1 foo:accessAttr1 ?accessAttrValue1.
       *             }
       *             { ?subject foo:accessAttr2 ?accessAttrValue2. }
       *             UNION
       *             { ?subject foo:inheritanceProp ?S2 .
       *               ?S2 foo:accessAttr1 ?accessAttrValue2.
       *             }
       *             ...
       *            }
       *           
       *  or in terms of the algebra:
       *           
       *  LeftJoin(
       *    SP(?subject, ?predicate, ?object),
       *    Join(
       *      Union(
       *        SP(?subject, accessAttr_1, ?accessAttrValue_1),
       *        Join (
       *          SP(?subject, inheritProp ?S_1),
       *          SP(?S_1, acccessAttr_1, ?accessAttrValue_1)
       *        )),
       *      Union(
       *        SP(?subject, accessAttr_2, ?accessAttrValue_2),
       *        Join (
       *          SP(?subject, inheritProp ?S_2),
       *          SP(?S_2, acccessAttr_2, ?accessAttrValue_2)
       *        )),
       *       ...
       *     )
       *  )
       */
      List<URI> attributes = getAccessAttributes();

      if (attributes == null || attributes.size() == 0) {
        return;
      }

      // join of the attribute match expressions.
      Join joinOfAttributePatterns = new Join();

      URI inheritanceProp = getInheritanceProperty();
      Var inheritPredVar = new Var("-acl_inherit_pred", inheritanceProp);

      int i = 0;

      List<Var> attributeVars = new ArrayList<Var>();
      for (URI attribute : attributes) {
        Var attributeVar = new Var("-acl_attr_" + i++);
        attributeVars.add(attributeVar);

        Var attributePredVar = new Var("-acl_attr_pred_" + i, attribute);

        // SP(?subject, accessAttr_i, ?accessAttrValue_i)
        StatementPattern attributePattern = new StatementPattern(subjectVar, attributePredVar,
            attributeVar);

        if (inheritanceProp != null) {
          // create a union expression for this attribute.
          Union union = new Union();
          union.addArg(attributePattern);

          // the join for checking if the access attribute is inherited.
          Join inheritJoin = new Join();
          Var inheritVar = new Var("-acl_inherited_value" + i);
          // SP (?subject, inheritProp, ?S_i)
          StatementPattern inheritPattern = new StatementPattern(subjectVar, inheritPredVar, inheritVar);
          inheritJoin.addArg(inheritPattern);
          // SP (?S_i, accessAttr_i, ?accessAttrValue_i)
          StatementPattern inheritAttrPattern = new StatementPattern(inheritVar, attributePredVar,
              attributeVar);
          inheritJoin.addArg(inheritAttrPattern);

          union.addArg(inheritJoin);

          joinOfAttributePatterns.addArg(union);
        }
        else {
          // no inheritance: the attribute can be matched with a simple
          // statement pattern
          joinOfAttributePatterns.addArg(attributePattern);
        }
      }

      TupleExpr expandedPattern = null;

      if (joinOfAttributePatterns.getNumberOfArguments() == 1) {
        expandedPattern = new LeftJoin(statementPattern, joinOfAttributePatterns.getArg(0));
      }
      else {
        expandedPattern = new LeftJoin(statementPattern, joinOfAttributePatterns);
      }

      // build an Or-ed set of filter conditions on the status and team.
      Or filterConditions = new Or();

      /* 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);
          }
        }

View Full Code Here

Examples of org.openrdf.query.algebra.Var

      int result = 0;

      Map<Var, Integer> ownFreqMap = getVarFreqMap(ownUnboundVars, new HashMap<Var, Integer>());

      for (Map.Entry<Var, Integer> entry : ownFreqMap.entrySet()) {
        Var var = entry.getKey();
        int ownFreq = entry.getValue();
        result += varFreqMap.get(var) - ownFreq;
      }

      return result;
View Full Code Here

Examples of org.openrdf.query.algebra.Var

  /*---------*
   * Methods *
   *---------*/

  private Var createConstantVar(Value value) {
    Var var = new Var("-const-" + constantVarID++);
    var.setAnonymous(true);
    var.setValue(value);
    return var;
  }
View Full Code Here

Examples of org.openrdf.query.algebra.Var

        extension.addElement(new ExtensionElem(valueExpr, alias));
        projElemList.addElement(new ProjectionElem(alias));
      }
      else if (valueExpr instanceof Var) {
        // unaliased variable
        Var projVar = (Var)valueExpr;
        projElemList.addElement(new ProjectionElem(projVar.getName()));
      }
      else {
        throw new IllegalStateException("required alias for non-Var projection elements not found");
      }
    }
View Full Code Here

Examples of org.openrdf.query.algebra.Var

  @Override
  public Object visit(ASTFrom node, Object data)
    throws VisitorException
  {
    StatementPattern.Scope scope = StatementPattern.Scope.DEFAULT_CONTEXTS;
    Var contextVar = null;

    if (node.hasContextID()) {
      scope = StatementPattern.Scope.NAMED_CONTEXTS;
      ValueExpr contextID = (ValueExpr)node.getContextID().jjtAccept(this, null);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.