Example #1
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;
  }
Example #2
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);
    }
  }