Package org.teiid.metadata

Examples of org.teiid.metadata.Column


        Create copy = new Create();     
        GroupSymbol copyTable = table.clone();   
        copy.setTable(copyTable);
        copy.columns = new ArrayList<Column>(columns.size());
        for (Column column : columns) {
      Column copyColumn = new Column();
      copyColumn.setName(column.getName());
      copyColumn.setRuntimeType(column.getRuntimeType());
      copyColumn.setAutoIncremented(column.isAutoIncremented());
      copyColumn.setNullType(column.getNullType());
      copy.columns.add(copyColumn);
    }
        copy.primaryKey = LanguageObject.Util.deepClone(primaryKey, ElementSymbol.class);
        copyMetadataState(copy);
        return copy;
View Full Code Here


    }

    public void setElementSymbolsAsColumns(List<ElementSymbol> columns) {
      this.columns.clear();
      for (ElementSymbol elementSymbol : columns) {
        Column c = new Column();
        c.setName(elementSymbol.getName());
        c.setRuntimeType(DataTypeManager.getDataTypeName(elementSymbol.getType()));
        c.setNullType(NullType.Nullable);
        this.columns.add(c);
    }
    }
View Full Code Here

        if (other.columns.size() != this.columns.size()) {
          return false;
        }
       
        for (int i = 0; i < this.columns.size(); i++) {
          Column c = this.columns.get(i);
          Column o = other.columns.get(i);
          if (!c.getName().equalsIgnoreCase(o.getName())
            || DataTypeManager.getDataTypeClass(c.getRuntimeType().toLowerCase()) != DataTypeManager.getDataTypeClass(o.getRuntimeType().toLowerCase())
            || c.isAutoIncremented() != o.isAutoIncremented()
            || c.getNullType() != o.getNullType()) {
            return false;
          }
    }
       
        return EquivalenceUtil.areEqual(getTable(), other.getTable()) &&
View Full Code Here

    }
   
  private void loadColumnSetRecords(ColumnSet<?> indexRecord, Map<String, Column> columns) {
    for (int i = 0; i < indexRecord.getColumns().size(); i++) {
      String uuid = indexRecord.getColumns().get(i).getUUID();
      Column c = null;
      if (columns != null) {
        c = columns.get(uuid);
      } else {
        c = findElement(uuid);
        c.setName(RecordFactory.getShortName(c.getName()));
      }
      indexRecord.getColumns().set(i, c);
      if (columns == null) {
        c.setParent(indexRecord);
      }
    }
  }
View Full Code Here

    }

  private static List<Column> createColumns(List<String> uuids) {
    List<Column> columns = new ArrayList<Column>(uuids.size());
        for (String uuid : uuids) {
          Column column = new Column();
          column.setUUID(uuid);
      columns.add(column);
    }
    return columns;
  }
View Full Code Here

     * Create a ColumnRecord instance from the specified index record
     */
    public Column createColumnRecord(final char[] record) {
        final String str = new String(record);
        final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
        final Column column = new Column();

        // Extract the index version information from the record
        int indexVersion = getIndexVersion(record);

        // The tokens are the standard header values
        int tokenIndex = 0;
        setRecordHeaderValues(column, tokens.get(tokenIndex++), tokens.get(tokenIndex++),
                             tokens.get(tokenIndex++), tokens.get(tokenIndex++),
                             tokens.get(tokenIndex++), tokens.get(tokenIndex++));

        // The next token are the supports flags
        char[] supportFlags = (tokens.get(tokenIndex++)).toCharArray();
        column.setSelectable(getBooleanValue(supportFlags[0]));
        column.setUpdatable(getBooleanValue(supportFlags[1]));
        column.setAutoIncremented(getBooleanValue(supportFlags[2]));
        column.setCaseSensitive(getBooleanValue(supportFlags[3]));
        column.setSigned(getBooleanValue(supportFlags[4]));
        column.setCurrency(getBooleanValue(supportFlags[5]));
        column.setFixedLength(getBooleanValue(supportFlags[6]));

        // The next token is the search type
        column.setNullType(NullType.values()[Integer.parseInt(tokens.get(tokenIndex++))]);

        // The next token is the search type
        column.setSearchType(SearchType.values()[3 - Integer.parseInt(tokens.get(tokenIndex++))]);

        // The next token is the length
        column.setLength( Integer.parseInt(tokens.get(tokenIndex++)) );

        // The next token is the scale
        column.setScale( Integer.parseInt(tokens.get(tokenIndex++)) );

        // The next token is the precision
        column.setPrecision( Integer.parseInt(tokens.get(tokenIndex++)) );

        // The next token is the precision
        column.setPosition( Integer.parseInt(tokens.get(tokenIndex++)) );

        // The next token is the charOctetLength
        column.setCharOctetLength( Integer.parseInt(tokens.get(tokenIndex++)) );

        // The next token is the radix
        column.setRadix( Integer.parseInt(tokens.get(tokenIndex++)) );

        if (includeColumnNullDistinctValues(indexVersion)) {
            // The next token is the distinct value
            column.setDistinctValues(Integer.parseInt(tokens.get(tokenIndex++)) );
            // The next token is the null value
            column.setNullValues(Integer.parseInt(tokens.get(tokenIndex++)) );           
        }

        // The next token is the min value
        column.setMinimumValue( getObjectValue(tokens.get(tokenIndex++)) );

        // The next token is the max value
        column.setMaximumValue( getObjectValue(tokens.get(tokenIndex++)) );

        // The next token is the format value
        column.setFormat( getObjectValue(tokens.get(tokenIndex++)) );

        // The next token is the runtime type
        column.setRuntimeType( getObjectValue(tokens.get(tokenIndex++)) );

        if(includeColumnNativeType(indexVersion)) {
          // The next token is the native type
          column.setNativeType( getObjectValue(tokens.get(tokenIndex++)) );
        }

        // The next token is the datatype ObjectID
        column.setDatatypeUUID( getObjectValue(tokens.get(tokenIndex++)) );

        // The next token is the default value
        column.setDefaultValue( getObjectValue(tokens.get(tokenIndex++)) );

    // The next tokens are footer values
    setRecordFooterValues(column, tokens, tokenIndex);

        return column;
View Full Code Here

    }
    return datatypeCache;
  }
 
  private Column findElement(String fullName) {
        Column columnRecord = (Column)getRecordByType(fullName, MetadataConstants.RECORD_TYPE.COLUMN);
      columnRecord.setDatatype(getDatatypeCache().get(columnRecord.getDatatypeUUID()));
        return columnRecord;
    }
View Full Code Here

      return ((Table)groupID).getColumns();
    }

    public Object getGroupIDForElementID(final Object elementID) throws TeiidComponentException, QueryMetadataException {
        if(elementID instanceof Column) {
            Column columnRecord = (Column) elementID;
            AbstractMetadataRecord parent = columnRecord.getParent();
            if (parent instanceof Table) {
              return parent;
            }
        }
        throw createInvalidRecordTypeException(elementID);
View Full Code Here

    public boolean elementSupports(final Object elementID, final int elementConstant)
        throws TeiidComponentException, QueryMetadataException {
       
        if(elementID instanceof Column) {
            Column columnRecord = (Column) elementID;           
            switch(elementConstant) {
                case SupportConstants.Element.NULL:
                    return columnRecord.getNullType() == NullType.Nullable;
                case SupportConstants.Element.NULL_UNKNOWN:
                    return columnRecord.getNullType() == NullType.Unknown;
                case SupportConstants.Element.SEARCHABLE_COMPARE:
                    return (columnRecord.getSearchType() == SearchType.Searchable || columnRecord.getSearchType() == SearchType.All_Except_Like);
                case SupportConstants.Element.SEARCHABLE_LIKE:
                  return (columnRecord.getSearchType() == SearchType.Searchable || columnRecord.getSearchType() == SearchType.Like_Only);
                case SupportConstants.Element.SELECT:
                    return columnRecord.isSelectable();
                case SupportConstants.Element.UPDATE:
                    return columnRecord.isUpdatable();
                case SupportConstants.Element.DEFAULT_VALUE:
                    Object defaultValue = columnRecord.getDefaultValue();
                    if(defaultValue == null) {
                        return false;
                    }
                    return true;
                case SupportConstants.Element.AUTO_INCREMENT:
                    return columnRecord.isAutoIncremented();
                case SupportConstants.Element.CASE_SENSITIVE:
                    return columnRecord.isCaseSensitive();
                case SupportConstants.Element.SIGNED:
                    return columnRecord.isSigned();
                default:
                    throw new UnsupportedOperationException(QueryPlugin.Util.getString("TransformationMetadata.Unknown_support_constant___12") + elementConstant); //$NON-NLS-1$
            }
        } else if(elementID instanceof ProcedureParameter) {
            ProcedureParameter columnRecord = (ProcedureParameter) elementID;           
            switch(elementConstant) {
                case SupportConstants.Element.NULL:
                  return columnRecord.getNullType() == NullType.Nullable;
                case SupportConstants.Element.NULL_UNKNOWN:
                  return columnRecord.getNullType() == NullType.Unknown;
                case SupportConstants.Element.SEARCHABLE_COMPARE:
                case SupportConstants.Element.SEARCHABLE_LIKE:
                    return false;
                case SupportConstants.Element.SELECT:
                    return columnRecord.getType() != Type.In;
                case SupportConstants.Element.UPDATE:
                    return false;
                case SupportConstants.Element.DEFAULT_VALUE:
                    Object defaultValue = columnRecord.getDefaultValue();
                    if(defaultValue == null) {
                        return false;
                    }
                    return true;
                case SupportConstants.Element.AUTO_INCREMENT:
View Full Code Here

        List<Object[]> result) throws TranslatorException {
      Element typeElement = (Element) sObject.getElementsByTagName(SF_TYPE).item(0);
      String sObjectName = typeElement.getFirstChild().getNodeValue();
      Object[] row = new Object[visitor.getSelectSymbolCount()];
      for (int j = 0; j < visitor.getSelectSymbolCount(); j++) {
        Column element = visitor.getSelectSymbolMetadata(j);
        AbstractMetadataRecord parent = element.getParent();
        Table table;
        if(parent instanceof Table) {
          table = (Table)parent;
        } else {
          parent = parent.getParent();
          if(parent instanceof Table) {
            table = (Table)parent;
          } else {
            throw new TranslatorException("Could not resolve Table for column " + element.getName()); //$NON-NLS-1$
          }
        }
        if(table.getNameInSource().equals(sObjectName)) {
          Integer index = visitor.getSelectSymbolIndex(sObjectName + ':' + element.getNameInSource());
          // id gets dropped from the result if it is not the
          // first field in the querystring. Add it back in.
          if (null == index) {
            if (element.getNameInSource().equalsIgnoreCase("id")) { //$NON-NLS-1$
              setElementValueInColumn(j, sObject.getElementsByTagName(SF_ID), row);
            } else {
              throw new TranslatorException(SalesForcePlugin.Util.getString("SalesforceQueryExecutionImpl.missing.field")+ element.getNameInSource()); //$NON-NLS-1$
            }
          } else {
            Object cell;
            cell = sObject.getElementsByTagName("sf:" + element.getNameInSource()).item(0); //$NON-NLS-1$
            setElementValueInColumn(j, cell, row);
          }
        }
      }
      result.add(row);
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.