Ejemplo n.º 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;
  }
Ejemplo n.º 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);
  }
Ejemplo n.º 3
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;
  }
Ejemplo n.º 4
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;
  }