Examples of ExpressionNode


Examples of com.jengine.utils.commons.expression.ExpressionNode

    /* SQL methods*/

    public SQLQuery.Table getMultiTable() {
        List<SQLQuery.TableItem> tableItems = getTableItems();
        ExpressionNode expressionNode  = makeSQLExpression();
        return new SQLQuery.Table(tableItems, expressionNode);
    }
View Full Code Here

Examples of com.jengine.utils.commons.expression.ExpressionNode

            String modelClassName = tree.getChild(0).getText();
            ModelClassBase modelClass = getDB().getModelClass(modelClassName);
            MultiModelItem item = add(new MultiModelItem(this, modelClass, makeItemName(modelClass)));
            return new MultiModelNode(item);
        } else if (tree.getType() == ExprParser.RIGHT_JOIN) {
            ExpressionNode operand1 = visit(tree.getChild(0));
            ExpressionNode operand2 = visit(tree.getChild(1));
            String[] keys = calcRestrictionKeys(getMultiModelItems(operand2), getMultiModelItems(operand1));
            keys = keys != null ?  keys : calcRestrictionKeys(getMultiModelItems(operand1), getMultiModelItems(operand2));
            RightJoin join = new RightJoin(operand1, operand2, fields.get(keys[0]), fields.get(keys[1]));
            operations.add(join);
            return join;
        } else if (tree.getType() == ExprParser.LEFT_JOIN) {
            ExpressionNode operand1 = visit(tree.getChild(0));
            ExpressionNode operand2 = visit(tree.getChild(1));
            String[] keys = calcRestrictionKeys(getMultiModelItems(operand1), getMultiModelItems(operand2));
            keys = keys != null ?  keys : calcRestrictionKeys(getMultiModelItems(operand2), getMultiModelItems(operand1));
            LeftJoin join = new LeftJoin(operand1, operand2, fields.get(keys[0]), fields.get(keys[1]));
            operations.add(join);
            return join;
        } else if (tree.getType() == ExprParser.FULL_JOIN) {
            ExpressionNode operand1 = visit(tree.getChild(0));
            ExpressionNode operand2 = visit(tree.getChild(1));
            String[] keys = calcRestrictionKeys(getMultiModelItems(operand1), getMultiModelItems(operand2));
            keys = keys != null ?  keys : calcRestrictionKeys(getMultiModelItems(operand2), getMultiModelItems(operand1));
            FullJoin join = new FullJoin(operand1, operand2, fields.get(keys[0]), fields.get(keys[1]));
            operations.add(join);
            return join;
        } else if (tree.getType() == ExprParser.INNER_JOIN) {
            ExpressionNode operand1 = visit(tree.getChild(0));
            ExpressionNode operand2 = visit(tree.getChild(1));
            String[] keys = calcRestrictionKeys(getMultiModelItems(operand1), getMultiModelItems(operand2));
            keys = keys != null ?  keys : calcRestrictionKeys(getMultiModelItems(operand2), getMultiModelItems(operand1));
            InnerJoin join = new InnerJoin(operand1, operand2, fields.get(keys[0]), fields.get(keys[1]));
            operations.add(join);
            return join;
        } else if (tree.getType() == ExprParser.AND) {
            ExpressionNode operand1 = visit(tree.getChild(0));
            ExpressionNode operand2 = visit(tree.getChild(1));
            return new And(operand1, operand2);
        }
        return null;
    }
View Full Code Here

Examples of it.eng.qbe.query.ExpressionNode

   * @param optionalUserFilters
   * @throws JSONException
   */
  public static void applyOptionalFilters(Query query, JSONObject optionalUserFilters) throws JSONException{
    String[] fields = JSONObject.getNames(optionalUserFilters);
    ExpressionNode leftExpression = query.getWhereClauseStructure();
    for(int i=0; i<fields.length; i++){
      String fieldName = fields[i];
      JSONArray valuesArray = optionalUserFilters.getJSONArray(fieldName);

      //if the filter has some value
      if(valuesArray.length()>0){

        String[] values = new String[1];
        values[0] =fieldName;

        Operand leftOperand = new Operand(values,fieldName, AbstractStatement.OPERAND_TYPE_FIELD, values,values);

        values = new String[valuesArray.length()];
        for(int j=0; j<valuesArray.length(); j++){
          values[j] = valuesArray.getString(j);
        }

        Operand rightOperand = new Operand(values,fieldName, AbstractStatement.OPERAND_TYPE_STATIC, values, values);

        String operator = "NOT EQUALS TO";
        if(valuesArray.length()>0){
          operator="IN";
        }

        query.addWhereField("OptionalFilter"+i, "OptionalFilter"+i, false, leftOperand, operator, rightOperand, "AND");



        ExpressionNode filterNode = new ExpressionNode("NO_NODE_OP","$F{OptionalFilter"+i+"}");

        //build the where clause tree
        if(leftExpression==null){
          leftExpression = filterNode;
        }else{
          ExpressionNode operationNode = new ExpressionNode("NODE_OP", "AND");
          operationNode.addChild(leftExpression);
          operationNode.addChild(filterNode);
          leftExpression = operationNode;
        }
      }
    }
    query.setWhereClauseStructure(leftExpression);
View Full Code Here

Examples of jsynoptic.parser.ExpressionNode

                }
                if ((exp == null) || exp.equals("")) {
                    JOptionPane.showMessageDialog(JSynoptic.gui.getOwner(),resources.getString("PleaseEnterAMathematicalExpression"),resources.getString("Error"),JOptionPane.ERROR_MESSAGE);
                    return;
                }
                ExpressionNode node = null;
                try {
                    ExpressionParser ep = new ExpressionParser(exp);
                    // Add the data sources as variables
                    // start by looping through collections
                    Set collections = DataSourcePool.global.dataSourceCollections();
View Full Code Here

Examples of jsynoptic.parser.ExpressionNode

                if (!conflictsOK) {
                    return null; // cancel => do not create the source
                }
            }
        }
        ExpressionNode node = null;
        try {
            ExpressionParser ep = new ExpressionParser(expression);
            // Add the data sources as variables, once conflicts are resolved
            for (int i = 0; i < clm.size(); ++i) {
                VariableConflict vc = (VariableConflict) clm.get(i);
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

    this();
    this.context = context;
  }

  public ExpressionNode parseCondition(String expression) {
    ExpressionNode logicalExpression = null;
    if (USE_CACHE) {
      logicalExpression = cache.get(expression);
    }

    if (logicalExpression == null) {
      Tokenizer tokenizer = Tokenizer.getExpressionTokenizer();
      tokenizer.tokenize(expression);
      LinkedList<Token> tokens = tokenizer.getTokens();
      logicalExpression = parseCondition(tokens);
      if (USE_CACHE) {
        cache.put(expression, logicalExpression);
      }
    } else {
      logicalExpression.accept(new SetContextVisitor(context));
    }

    return logicalExpression;
  }
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

  public ExpressionNode parseCondition(LinkedList<Token> tokens) {
    this.tokens = new LinkedList<Token>(tokens);
    lookahead = this.tokens.getFirst();

    ExpressionNode logicalExpression = logicalExpression();
    logicalExpression.accept(new SetContextVisitor(context));

    return logicalExpression;
  }
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

   *            the string holding the input
   * @return the internal representation of the expression in form of an expression tree made out of ExpressionNode
   *         objects
   */
  public ExpressionNode parseExpression(String expression) {
    ExpressionNode mathematicalExpression = null;
    if (USE_CACHE) {
      mathematicalExpression = cache.get(expression);
    }

    if (mathematicalExpression == null) {
      Tokenizer tokenizer = Tokenizer.getExpressionTokenizer();
      tokenizer.tokenize(expression);
      LinkedList<Token> tokens = tokenizer.getTokens();
      mathematicalExpression = parseExpression(tokens);
      if (USE_CACHE) {
        cache.put(expression, mathematicalExpression);
      }
    } else {
      mathematicalExpression.accept(new SetContextVisitor(context));
    }

    return mathematicalExpression;
  }
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

   */
  public ExpressionNode parseExpression(LinkedList<Token> tokens) {
    this.tokens = new LinkedList<Token>(tokens);
    lookahead = this.tokens.getFirst();

    ExpressionNode mathematicalExpression = mathematicalExpression();
    mathematicalExpression.accept(new SetContextVisitor(context));

    return mathematicalExpression;
  }
View Full Code Here

Examples of net.mitza.rel.parser.expression.ExpressionNode

  // logical -> or_term or_op
  private ExpressionNode logicalExpression() {
    // only one rule
    // logical -> or_term or_op
    ExpressionNode expression = orTerm();
    expression = orOperation(expression);
    return expression;
  }
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.