Exemple #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;
  }
Exemple #2
0
  /**
   * Returns the matched column definition with the specified name and position.
   *
   * @param columns the ODA defined result set column definitions
   * @param paramName the result set column name
   * @param position the position
   * @return the matched oda result set column
   */
  private static ColumnDefinition findColumnDefinition(
      ResultSetColumns columns, String columnName, Integer position) {
    if (columns == null || columnName == null) return null;

    EList odaColumns = columns.getResultColumnDefinitions();
    if (odaColumns == null || odaColumns.isEmpty()) return null;

    for (int i = 0; i < odaColumns.size(); i++) {
      ColumnDefinition columnDefn = (ColumnDefinition) odaColumns.get(i);

      DataElementAttributes dataAttrs = columnDefn.getAttributes();
      if (dataAttrs == null) continue;

      if (columnName.equals(dataAttrs.getName())
          && (position == null || position.intValue() == dataAttrs.getPosition()))
        return columnDefn;
    }

    return null;
  }
Exemple #3
0
  /**
   * Creates a list containing ROM ResultSetColumn according to given ODA ResultSets.
   *
   * @param setDesign the data set design
   * @param setHandle the data set handle
   * @param cachedSetDefn the ODA result set in designer values
   * @return a list containing ROM ResultSetColumn.
   * @throws SemanticException
   */
  List<ResultSetColumnInfo> newROMResultSets(ResultSetDefinition cachedSetDefn)
      throws SemanticException {
    ResultSetColumns cachedSetColumns =
        cachedSetDefn == null ? null : cachedSetDefn.getResultSetColumns();

    ResultSetDefinition resultDefn = setDesign.getPrimaryResultSet();
    if (resultDefn == null) {
      ResultSets resultSets = setDesign.getResultSets();
      if (resultSets != null && !resultSets.getResultSetDefinitions().isEmpty())
        resultDefn = (ResultSetDefinition) resultSets.getResultSetDefinitions().get(0);
    }

    if (resultDefn == null) return null;

    ResultSetColumns setColumns = resultDefn.getResultSetColumns();
    if (setColumns == null) return null;

    EList<ColumnDefinition> odaSetColumns = setColumns.getResultColumnDefinitions();
    if (odaSetColumns.isEmpty()) return null;

    List<ColumnDefinition> oldColumnDefns = new ArrayList<ColumnDefinition>();
    if (cachedSetColumns != null) {
      EList<ColumnDefinition> tmpDefns = cachedSetColumns.getResultColumnDefinitions();
      for (int i = 0; i < tmpDefns.size(); i++) oldColumnDefns.add(tmpDefns.get(i));
    }

    List<OdaResultSetColumnHandle> oldColumns = new ArrayList<OdaResultSetColumnHandle>();
    for (int i = 0; i < setDefinedResults.size(); i++)
      oldColumns.add((OdaResultSetColumnHandle) setDefinedResults.get(i));

    List<ColumnHintHandle> oldColumnHints = new ArrayList<ColumnHintHandle>();
    for (int i = 0; i < setDefinedColumnHints.size(); i++)
      oldColumnHints.add((ColumnHintHandle) setDefinedColumnHints.get(i));

    List<ColumnDefinition> newColumnDefns = new ArrayList<ColumnDefinition>();
    for (int i = 0; i < odaSetColumns.size(); i++) newColumnDefns.add(odaSetColumns.get(i));

    ROMResultSetsHelper resultSetHelper =
        new ROMResultSetsHelper(
            oldColumnDefns,
            oldColumns,
            oldColumnHints,
            newColumnDefns,
            setDesign.getOdaExtensionDataSourceId(),
            setDesign.getOdaExtensionDataSetId());

    List<ResultSetColumnInfo> retList = new ArrayList<ResultSetColumnInfo>();
    ResultSetColumnInfo setInfo = null;

    for (int i = 0; i < newColumnDefns.size(); i++) {
      ROMResultColumnHelper columnHelper = resultSetHelper.getColumnHelper(i);
      OdaResultSetColumn newColumn = resultSetHelper.getNewColumn(i);
      ColumnDefinition newColumnDefn = columnHelper.getNewColumnDefn();
      ColumnHintHandle oldColumnHintHandle = columnHelper.getOldColumnHint();
      ColumnHint oldColumnHint =
          oldColumnHintHandle == null ? null : (ColumnHint) oldColumnHintHandle.getStructure();

      ColumnHint newColumnHint =
          newROMColumnHintFromColumnDefinition(newColumnDefn, null, oldColumnHint, newColumn);
      setInfo = new ResultSetColumnInfo(newColumn, newColumnHint);
      retList.add(setInfo);
    }

    updateHintsForComputedColumn();

    return retList;
  }