Package org.teiid.language

Examples of org.teiid.language.Expression


      if (!firstTime) {
        result.append(", ");
      } else {
        firstTime = false;
      }
      Expression expression = symbol.getExpression();
      if (expression instanceof ColumnReference) {
        Column element = ((ColumnReference) expression).getMetadataObject();
        AbstractMetadataRecord parent = element.getParent();
        Table table;
        if(parent instanceof Table) {
View Full Code Here


      LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing compare criteria."); //$NON-NLS-1$
      Comparison.Operator op = ((Comparison) criteria).getOperator();
     
      isNegated = op == Operator.NE || op == Operator.GT || op == Operator.LT;
     
      Expression lhs = ((Comparison) criteria).getLeftExpression();
      Expression rhs = ((Comparison) criteria).getRightExpression();
   
      String lhsString = getExpressionString(lhs);
      String rhsString = getExpressionString(rhs);
      if(lhsString == null || rhsString == null) {
              final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.missingNISError"); //$NON-NLS-1$
        throw new TranslatorException(msg);
      }
     
      addCompareCriteriaToList(filterList, op, lhsString, rhsString);
    // Base case
    } else if(criteria instanceof Exists) {
      LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing EXISTS criteria: NOT IMPLEMENTED YET"); //$NON-NLS-1$
      // TODO Exists should be supported in a future release.
    // Base case
    } else if(criteria instanceof Like) {
      LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing LIKE criteria."); //$NON-NLS-1$
      isNegated = ((Like) criteria).isNegated();
      // Convert LIKE to Equals, where any "%" symbol is replaced with "*".
      Comparison.Operator op = Operator.EQ;
      Expression lhs = ((Like) criteria).getLeftExpression();
      Expression rhs = ((Like) criteria).getRightExpression();
   
      String lhsString = getExpressionString(lhs);
      String rhsString = getExpressionString(rhs);
      rhsString = rhsString.replace("%", "*"); //$NON-NLS-1$ //$NON-NLS-2$
      addCompareCriteriaToList(filterList, op, lhsString, rhsString);
     
    // Base case
    } else if(criteria instanceof In) {
      LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing IN criteria."); //$NON-NLS-1$
      isNegated = ((In) criteria).isNegated();
      Expression lhs = ((In)criteria).getLeftExpression();
      List<Expression> rhsList = ((In)criteria).getRightExpressions();
      // Recursively add each IN expression to the filter list.
      processInCriteriaList(filterList, rhsList, lhs);
    } else if (criteria instanceof Not) {
      LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing NOT criteria."); //$NON-NLS-1$
View Full Code Here

  @Override
  public void visit(Comparison criteria) {
   
    // Find the criteria that joins the two tables
    try {
      Expression rExp = criteria.getRightExpression();
      if (rExp instanceof ColumnReference) {
        Expression lExp = criteria.getLeftExpression();
        if (isIdColumn(rExp) || isIdColumn(lExp)) {

          Column rColumn = ((ColumnReference) rExp).getMetadataObject();
          String rTableName = rColumn.getParent().getNameInSource();

          Column lColumn = ((ColumnReference) lExp).getMetadataObject();
          String lTableName = lColumn.getParent().getNameInSource();

          if (leftTableInJoin.getNameInSource().equals(rTableName)
              || leftTableInJoin.getNameInSource().equals(lTableName)
              && rightTableInJoin.getNameInSource().equals(rTableName)
              || rightTableInJoin.getNameInSource().equals(lTableName)
              && !rTableName.equals(lTableName)) {
            // This is the join criteria, the one that is the ID is the parent.
            Expression fKey = !isIdColumn(lExp) ? lExp : rExp;
            table = childTable =  (Table)((ColumnReference) fKey).getMetadataObject().getParent();
          } else {
            // Only add the criteria to the query if it is not the join criteria.
            // The join criteria is implicit in the salesforce syntax.
            super.visit(criteria);
View Full Code Here

  }

  void addSelect(String tableNameInSource, StringBuffer result, boolean addComma) {
    boolean firstTime = true;
    for (DerivedColumn symbol : selectSymbols) {
      Expression expression = symbol.getExpression();
      if (expression instanceof ColumnReference) {
        Column element = ((ColumnReference) expression).getMetadataObject();
        String tableName = element.getParent().getNameInSource();
        if(!isParentToChildJoin() && tableNameInSource.equals(tableName) ||
            isParentToChildJoin()) {
View Full Code Here

  }

    @Override
    public void visit( In criteria ) {
        try {
            Expression lExpr = criteria.getLeftExpression();
            if (lExpr instanceof ColumnReference) {
              ColumnReference cr = (ColumnReference)lExpr;
                Column column = cr.getMetadataObject();
                if (column != null && (MULTIPICKLIST.equalsIgnoreCase(column.getNativeType()) || RESTRICTEDMULTISELECTPICKLIST.equalsIgnoreCase(column.getNativeType()))) {
                    appendMultiselectIn(column, criteria);
View Full Code Here

    private void generateMultiSelect( Function func,
                                      String funcName ) throws TranslatorException {
        List<Expression> expressions = func.getParameters();
        validateFunction(expressions);
        Expression columnExpression = expressions.get(0);
        Column column = ((ColumnReference)columnExpression).getMetadataObject();
        StringBuffer criterion = new StringBuffer();
        criterion.append(column.getNameInSource()).append(SPACE).append(funcName);
        addFunctionParams((Literal)expressions.get(1), criterion);
        criteriaList.add(criterion.toString());
View Full Code Here

        result.append('(');
        List<Expression> rightExpressions = criteria.getRightExpressions();
        Iterator<Expression> iter = rightExpressions.iterator();
        boolean first = true;
        while (iter.hasNext()) {
            Expression rightExpression = iter.next();
            if (first) {
                result.append(rightExpression.toString());
                first = false;
            } else {
                result.append(COMMA).append(rightExpression.toString());
            }

        }
        result.append(')');
        criteriaList.add(result.toString());
View Full Code Here

        criterion.append(CLOSE);
    }

    protected void addCompareCriteria( List criteriaList,
                                       Comparison compCriteria ) throws TranslatorException {
        Expression lExpr = compCriteria.getLeftExpression();
        if (lExpr instanceof Function) {
            parseFunction((Function)lExpr);
        } else {
            ColumnReference left = (ColumnReference)lExpr;
            Column column = left.getMetadataObject();
            String columnName = column.getNameInSource();
            StringBuffer queryString = new StringBuffer();
            queryString.append(column.getParent().getNameInSource());
            queryString.append('.');
            queryString.append(columnName).append(SPACE);
            queryString.append(comparisonOperators.get(compCriteria.getOperator()));
            queryString.append(' ');
            Expression rExp = compCriteria.getRightExpression();
            if(rExp instanceof Literal) {
              Literal literal = (Literal)rExp;
              if (column.getJavaType().equals(Boolean.class)) {
                queryString.append(((Boolean)literal.getValue()).toString());
              } else if (column.getJavaType().equals(java.sql.Timestamp.class)) {
View Full Code Here

        }
    }

    private void appendCriteria( In criteria ) throws TranslatorException {
        StringBuffer queryString = new StringBuffer();
        Expression leftExp = criteria.getLeftExpression();
        if(isIdColumn(leftExp)) {
          idInCriteria  = criteria;
        }
        queryString.append(getValue(leftExp));
        queryString.append(' ');
View Full Code Here

    // When we start filtering out DN changes (which would need to
    // be performed separately using Context.rename()), we will
    // need to account for this in determining this list size.
    ModificationItem[] updateMods = new ModificationItem[updateList.size()];
    ColumnReference leftElement;
    Expression rightExpr;
    String nameLeftElement;
    Object valueRightExpr;
    // iterate through the supplied list of updates (each of
    // which is an ICompareCriteria with an IElement on the left
    // side and an IExpression on the right, per the Connector
View Full Code Here

TOP

Related Classes of org.teiid.language.Expression

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.