Пример #1
0
  private IResultClass mergeResultHint(List modelResultHints, IResultClass meta) {
    if (modelResultHints == null || modelResultHints.isEmpty()) return meta;
    IResultClass newResultClass;
    try {
      newResultClass = copyResultClass(meta);
    } catch (Exception ex) {
      return meta;
    }
    boolean changed = false;
    int count = newResultClass.getFieldCount();
    try {
      for (int i = 1; i <= count; i++) {
        String fieldName = newResultClass.getFieldName(i);
        Class odaType = newResultClass.getFieldMetaData(i).getDataType();
        for (int j = 0; j < modelResultHints.size(); j++) {
          if (((IColumnDefinition) modelResultHints.get(j)).getColumnName().equals(fieldName)) {
            int apiType = ((IColumnDefinition) modelResultHints.get(j)).getDataType();
            if (apiType > 0 && DataTypeUtil.toApiDataType(odaType) != apiType) {
              newResultClass.getFieldMetaData(i).setDataType(DataType.getClass(apiType));
              changed = true;
            }
            break;
          }
        }
      }
    } catch (Exception ex) {
    }

    if (changed) return newResultClass;
    else return meta;
  }
Пример #2
0
  /**
   * Remove old temp computed column metadatas from cache file and add new metadatas.
   *
   * @throws DataException
   */
  private void processResultClass() throws DataException {
    List metadataList = new ArrayList();
    this.realColumnCount = 0;

    ResultFieldMetadata metadata = null;
    int i = 0;
    for (i = 0; i < rsMeta.getFieldCount(); i++) {
      if (!isTempComputedColumn(rsMeta.getFieldName(i + 1))) {
        metadata =
            new ResultFieldMetadata(
                0,
                rsMeta.getFieldName(i + 1),
                rsMeta.getFieldLabel(i + 1),
                rsMeta.getFieldValueClass(i + 1),
                rsMeta.getFieldNativeTypeName(i + 1),
                rsMeta.isCustomField(i + 1),
                rsMeta.getAnalysisType(i + 1),
                rsMeta.getAnalysisColumn(i + 1),
                rsMeta.isIndexColumn(i + 1),
                rsMeta.isCompressedColumn(i + 1));
        metadata.setAlias(rsMeta.getFieldAlias(i + 1));
        metadataList.add(metadata);
        realColumnCount++;
      }
    }

    ComputedColumn tempComputedColumn = null;
    for (i = 0; i < addedTempComputedColumn.size(); i++) {
      tempComputedColumn = (ComputedColumn) (addedTempComputedColumn.get(i));
      metadata =
          new ResultFieldMetadata(
              0,
              tempComputedColumn.getName(),
              null,
              DataType.getClass(tempComputedColumn.getDataType()),
              null,
              true,
              -1);
      metadataList.add(metadata);
    }

    rsMeta = new ResultClass(metadataList);
  }
Пример #3
0
  private IResultClass copyResultClass(IResultClass meta) throws DataException {
    List<ResultFieldMetadata> list = new ArrayList<ResultFieldMetadata>();
    for (int i = 1; i <= meta.getFieldCount(); i++) {
      if (!meta.getFieldName(i).equals(ExprMetaUtil.POS_NAME)) {
        int m_driverPosition = meta.getFieldMetaData(i).getDriverPosition();
        String m_name = meta.getFieldMetaData(i).getName();
        String m_label = meta.getFieldMetaData(i).getLabel();
        Class m_dataType = meta.getFieldMetaData(i).getDataType();
        String m_nativeTypeName = meta.getFieldMetaData(i).getNativeTypeName();
        boolean m_isCustom = meta.getFieldMetaData(i).isCustom();
        Class m_driverProvidedDataType = meta.getFieldMetaData(i).getDriverProvidedDataType();
        int m_analysisType = meta.getFieldMetaData(i).getAnalysisType();
        String m_analysisColumn = meta.getFieldMetaData(i).getAnalysisColumn();
        boolean m_indexColumn = meta.getFieldMetaData(i).isIndexColumn();
        boolean m_compressedColumn = meta.getFieldMetaData(i).isCompressedColumn();

        ResultFieldMetadata metadata =
            new ResultFieldMetadata(
                m_driverPosition,
                m_name,
                m_label,
                m_dataType,
                m_nativeTypeName,
                m_isCustom,
                m_analysisType,
                m_analysisColumn,
                m_indexColumn,
                m_compressedColumn);
        metadata.setDriverProvidedDataType(m_driverProvidedDataType);
        metadata.setAlias(meta.getFieldMetaData(i).getAlias());

        list.add(metadata);
      }
    }
    IResultClass resultClass = new ResultClass(list);

    return resultClass;
  }