Package org.teiid.metadata

Examples of org.teiid.metadata.Column


  private String getExpressionString(Expression e) throws TranslatorException {
    String expressionName = null;
    // GHH 20080326 - changed around the IElement handling here
    // - the rest of this method is unchanged
    if(e instanceof ColumnReference) {
      Column mdIDElement = ((ColumnReference)e).getMetadataObject();
      expressionName = mdIDElement.getNameInSource();
      if(expressionName == null || expressionName.equals("")) {  //$NON-NLS-1$
        expressionName = mdIDElement.getName();
      }
    } else if(e instanceof Literal) {
      try {
        if(((Literal)e).getType().equals(Class.forName(Timestamp.class.getName()))) {
          LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Found an expression that uses timestamp; converting to LDAP string format."); //$NON-NLS-1$
View Full Code Here


  private ArrayList<Column> getElementsFromSelectSymbols(Select query) {
    ArrayList<Column> selectElementList = new ArrayList<Column>();
    Iterator<DerivedColumn> selectSymbolItr = query.getDerivedColumns().iterator();

    while(selectSymbolItr.hasNext()) {
      Column e = getElementFromSymbol(selectSymbolItr.next());
      selectElementList.add(e);
    }
    return selectElementList;
  }
View Full Code Here

    ArrayList<BasicAttribute> ldapAttributeList = new ArrayList<BasicAttribute>();
     
    Iterator<DerivedColumn> selectSymbolItr = query.getDerivedColumns().iterator();
    int i=0;
    while(selectSymbolItr.hasNext()) {
      Column e = getElementFromSymbol(selectSymbolItr.next());
      String ldapAttributeName = this.getNameFromElement(e);
      Object ldapAttributeClass = e.getJavaType();

      // Store the element's name and class type, so that we know what to look for in the search results.
      BasicAttribute newAttr = new BasicAttribute(ldapAttributeName, ldapAttributeClass);
      ldapAttributeList.add(newAttr);
      i++;
View Full Code Here

      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)
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()) {
          if (!firstTime) {
            result.append(", "); //$NON-NLS-1$           
          } else {
            firstTime = false;
          }
          result.append(tableName);
          result.append('.');
          result.append(element.getNameInSource());
        } else {
          continue;
        }
      } else if (expression instanceof AggregateFunction) {
        if (!firstTime) {
View Full Code Here

        // Columns clause
        List<Column> columns = obj.getColumns();
        append("("); //$NON-NLS-1$
        Iterator<Column> iter = columns.iterator();
        while (iter.hasNext()) {
            Column element = iter.next();
            outputDisplayName(element.getName());
            append(SPACE);
            if (element.isAutoIncremented()) {
              append(NonReserved.SERIAL);
            } else {
              append(element.getRuntimeType());
              if (element.getNullType() == NullType.No_Nulls) {
                append(NOT);
                append(SPACE);
                append(NULL);
              }
            }
View Full Code Here

        throw new TranslatorException("Error:  columns.size and values.size are not the same.");
      }
     
      for(int i = 0; i < columns.size(); i++) {
        ColumnReference element = columns.get(i);
        Column column = element.getMetadataObject();
        Object value = values.get(i);
        String val;
        if(value instanceof Literal) {
          Literal literalValue = (Literal)value;
          val = literalValue.getValue().toString();
          if(null != val && !val.isEmpty()) {
            val = this.stripQutes(val);
          }
        } else {
          val = value.toString();
        }
        QName qname = new QName(column.getNameInSource());
          @SuppressWarnings( "unchecked" )
          JAXBElement jbe = new JAXBElement( qname, stringClazz, val );
        elements.add(jbe);
      }
     
View Full Code Here

    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);
                } else {
                    appendCriteria(criteria);
                }
            } else {
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

        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)) {
                Timestamp datetime = (java.sql.Timestamp)literal.getValue();
                String value = Util.getSalesforceDateTimeFormat().format(datetime);
                String zoneValue = Util.getTimeZoneOffsetFormat().format(datetime);
                queryString.append(value).append(zoneValue.subSequence(0, 3)).append(':').append(zoneValue.subSequence(3, 5));
              } else if (column.getJavaType().equals(java.sql.Time.class)) {
                String value = Util.getSalesforceDateTimeFormat().format((java.sql.Time)literal.getValue());
                queryString.append(value);
              } else if (column.getJavaType().equals(java.sql.Date.class)) {
                String value = Util.getSalesforceDateFormat().format((java.sql.Date)literal.getValue());
                queryString.append(value);
              } else {
                queryString.append(compCriteria.getRightExpression().toString());
              }
            } else if(rExp instanceof ColumnReference) {
              ColumnReference right = (ColumnReference)lExpr;
                column = left.getMetadataObject();
                columnName = column.getNameInSource();
                queryString.append(columnName);
            }

            criteriaList.add(queryString.toString());
View Full Code Here

TOP

Related Classes of org.teiid.metadata.Column

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.