예제 #1
0
  /**
   * Returns the matched oda result set column with the specified name and position.
   *
   * @param columns the iterator that includes oda result set columns
   * @param paramName the result set column name
   * @param position the position
   * @return the matched oda result set column
   */
  static OdaResultSetColumnHandle findOdaResultSetColumn(
      Iterator columns,
      String paramName,
      Integer position,
      Integer nativeDataType,
      Boolean duplicate) {
    if (position == null || nativeDataType == null) return null;

    while (columns.hasNext()) {
      OdaResultSetColumnHandle column = (OdaResultSetColumnHandle) columns.next();

      Integer tmpNativeDataType = column.getNativeDataType();
      String nativeName = column.getNativeName();
      // if the column name is unique, not necessary to check position
      if (duplicate == Boolean.FALSE) {
        if (!StringUtil.isBlank(nativeName)
            && nativeName.equalsIgnoreCase(paramName)
            && (tmpNativeDataType == null || nativeDataType.equals(tmpNativeDataType))) {
          return column;
        }
      }
      // if same column name appears in more than one table or oda native name
      // is missing, column position needs to be checked
      if ((StringUtil.isBlank(nativeName) || nativeName.equalsIgnoreCase(paramName))
          && (position.equals(column.getPosition()))
          && (tmpNativeDataType == null || nativeDataType.equals(tmpNativeDataType))) return column;
    }
    return null;
  }
예제 #2
0
  /**
   * Returns the rom data type in string.
   *
   * @param dataSourceId the id of the data source
   * @param dataSetId the ide of the data set
   * @param column the rom data set parameter
   * @param setHandleParams params defined in data set handle
   * @return the rom data type in string
   */
  private String getROMDataType(String dataSourceId, String dataSetId, OdaResultSetColumn column) {
    String name = column.getNativeName();
    Integer position = column.getPosition();
    Integer nativeDataType = column.getNativeDataType();

    OdaResultSetColumnHandle tmpParam =
        findOdaResultSetColumn(setDefinedResults.iterator(), name, position, nativeDataType);

    if (tmpParam == null)
      return AdapterUtil.convertNativeTypeToROMDataType(
          dataSourceId, dataSetId, column.getNativeDataType().intValue(), null);

    Integer tmpPosition = tmpParam.getPosition();
    if (tmpPosition == null)
      return AdapterUtil.convertNativeTypeToROMDataType(
          dataSourceId, dataSetId, column.getNativeDataType().intValue(), null);

    if (!tmpPosition.equals(column.getPosition()))
      return AdapterUtil.convertNativeTypeToROMDataType(
          dataSourceId, dataSetId, column.getNativeDataType().intValue(), null);

    Integer tmpNativeCodeType = tmpParam.getNativeDataType();
    if (tmpNativeCodeType == null || tmpNativeCodeType.equals(column.getNativeDataType()))
      return tmpParam.getDataType();

    String oldDataType = tmpParam.getDataType();
    return AdapterUtil.convertNativeTypeToROMDataType(
        dataSourceId, dataSetId, column.getNativeDataType().intValue(), oldDataType);
  }
예제 #3
0
  /**
   * Returns the matched oda result set column with the specified name and position.
   *
   * @param columns the iterator that includes oda result set columns
   * @param paramName the result set column name
   * @param position the position
   * @return the matched oda result set column
   */
  static OdaResultSetColumnHandle findOdaResultSetColumn(
      Iterator columns, String paramName, Integer position, Integer nativeDataType) {
    if (position == null || nativeDataType == null) return null;

    while (columns.hasNext()) {
      OdaResultSetColumnHandle column = (OdaResultSetColumnHandle) columns.next();

      Integer tmpNativeDataType = column.getNativeDataType();
      String nativeName = column.getNativeName();
      if ((StringUtil.isBlank(nativeName) || nativeName.equalsIgnoreCase(paramName))
          && position.equals(column.getPosition())
          && (tmpNativeDataType == null || nativeDataType.equals(tmpNativeDataType))) return column;
    }
    return null;
  }
예제 #4
0
  /** Updates hint-related information on ODA column definitions. */
  void updateOdaColumnHints() {

    ResultSetDefinition columnDefns = setDesign.getPrimaryResultSet();
    if (columnDefns == null) return;

    for (int i = 0; i < setDefinedColumnHints.size(); i++) {
      ColumnHintHandle hint = (ColumnHintHandle) setDefinedColumnHints.get(i);
      OdaResultSetColumnHandle column =
          (OdaResultSetColumnHandle) findColumn(hint.getColumnName(), setDefinedResults.iterator());

      if (column == null) continue;

      ColumnDefinition odaColumn =
          findColumnDefinition(
              columnDefns.getResultSetColumns(), column.getNativeName(), column.getPosition());

      if (odaColumn == null) continue;

      updateOdaColumnHint(odaColumn, hint);
    }
  }
예제 #5
0
  /**
   * Creates a ResultSetDefinition with the given ROM ResultSet columns.
   *
   * @return the created ResultSetDefinition
   */
  private ResultSetDefinition newOdaResultSetDefinition() {
    Iterator romSets = setDefinedResults.iterator();
    String name = setHandle.getResultSetName();

    if (!romSets.hasNext()) return null;

    ResultSetDefinition odaSetDefn = null;
    ResultSetColumns odaSetColumns = null;

    if (!StringUtil.isBlank(name)) {
      odaSetDefn = designFactory.createResultSetDefinition();
      odaSetDefn.setName(name);
    }

    while (romSets.hasNext()) {
      if (odaSetDefn == null) odaSetDefn = designFactory.createResultSetDefinition();

      if (odaSetColumns == null) odaSetColumns = designFactory.createResultSetColumns();

      OdaResultSetColumnHandle setColumn = (OdaResultSetColumnHandle) romSets.next();

      // get the colum hint

      ColumnHintHandle hint =
          AdapterUtil.findColumnHint(
              (OdaResultSetColumn) setColumn.getStructure(), setDefinedColumnHints.iterator());

      ColumnDefinition columnDefn = designFactory.createColumnDefinition();

      DataElementAttributes dataAttrs = designFactory.createDataElementAttributes();

      String newName = setColumn.getNativeName();
      dataAttrs.setName(newName);

      Integer position = setColumn.getPosition();
      if (position != null) dataAttrs.setPosition(setColumn.getPosition().intValue());

      Integer nativeDataType = setColumn.getNativeDataType();
      if (nativeDataType != null) dataAttrs.setNativeDataTypeCode(nativeDataType.intValue());

      columnDefn.setAttributes(dataAttrs);
      odaSetColumns.getResultColumnDefinitions().add(columnDefn);

      if (hint == null) continue;

      updateOdaColumnHint(columnDefn, hint);
    }

    if (odaSetDefn != null) odaSetDefn.setResultSetColumns(odaSetColumns);

    return odaSetDefn;
  }
  /**
   * Updates a ROM result set definition. To make sure that convertNativeTypeToROMDataType() will be
   * called. So that can verify blob conversion.
   *
   * @param param
   */
  private void updateResultSetDefinition2(OdaDataSetHandle setHandle) throws SemanticException {
    Iterator iter1 = setHandle.resultSetIterator();
    OdaResultSetColumnHandle column = (OdaResultSetColumnHandle) iter1.next();

    column.setNativeDataType(new Integer(10));
  }