/**
   * Updates a oda result set definition.
   *
   * @param param
   */
  private void updateOrVerifyResultSetColumnAndHint(
      DataSetDesign setDesign, OdaDataSetHandle setHandle, boolean update)
      throws SemanticException {
    ResultSets sets = setDesign.getResultSets();
    ResultSetDefinition setDefn = (ResultSetDefinition) sets.getResultSetDefinitions().get(0);
    ColumnDefinition columnDef = setDefn.getResultSetColumns().getResultColumnDefinitions().get(0);

    DataElementAttributes dataAttrs = columnDef.getAttributes();
    DataElementUIHints dataUIHints = dataAttrs.getUiHints();
    OutputElementAttributes usageHints = columnDef.getUsageHints();
    if (columnDef.getMultiDimensionAttributes() == null) {
      columnDef.setMultiDimensionAttributes(DesignFactory.eINSTANCE.createAxisAttributes());
    }

    if (update) {
      dataAttrs.setNativeDataTypeCode(DataType.DECIMAL_TYPE);
      dataUIHints.setDisplayName("new display name for column 1"); // $NON-NLS-1$
      usageHints.setHelpText("new help text for column 1"); // $NON-NLS-1$
      ValueFormatHints format = DesignFactory.eINSTANCE.createValueFormatHints();
      format.setDisplayFormat("new format"); // $NON-NLS-1$
      usageHints.setFormattingHints(format);
      columnDef.setUsageHints(usageHints);
      columnDef.getMultiDimensionAttributes().setAxisType(AxisType.MEASURE_LITERAL);
      columnDef.getMultiDimensionAttributes().setOnColumnLayout(true);
    } else {
      assertEquals(DataType.DECIMAL_TYPE, dataAttrs.getNativeDataTypeCode());
      assertEquals("new display name for column 1", dataUIHints.getDisplayName());
      assertEquals("new help text for column 1", usageHints.getHelpText());
      assertEquals("new format", usageHints.getFormattingHints().getDisplayFormat());
      assertEquals(AxisType.MEASURE_LITERAL, columnDef.getMultiDimensionAttributes().getAxisType());
      assertTrue(columnDef.getMultiDimensionAttributes().isSetOnColumnLayout());
    }
  }
Exemple #2
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 oda result set definition.
   *
   * @param param
   */
  private void updateOrVerifyResultSetDefinition1(ResultSetDefinition setDefn, boolean update) {
    List columns = setDefn.getResultSetColumns().getResultColumnDefinitions();

    ColumnDefinition column1 = (ColumnDefinition) columns.get(0);
    ColumnDefinition column2 = (ColumnDefinition) columns.get(1);

    DataElementAttributes dataAttrs = column1.getAttributes();
    DataElementUIHints dataUIHints = dataAttrs.getUiHints();
    if (update) dataUIHints.setDisplayName("new display name for column 1"); // $NON-NLS-1$
    else assertEquals("new display name for column 1", dataUIHints.getDisplayName());

    OutputElementAttributes usageHints = column1.getUsageHints();
    if (update) usageHints.setHelpText("new help text for column 1"); // $NON-NLS-1$
    else assertEquals("new help text for column 1", usageHints.getHelpText());

    // Setting to null object
    if (update)
      usageHints.getFormattingHints().setDisplayFormat("new format for column 1"); // $NON-NLS-1$
    else assertEquals(null, usageHints.getFormattingHints().getDisplayFormat());

    if (update) {
      AxisAttributes axisAttrs = DesignFactory.eINSTANCE.createAxisAttributes();
      axisAttrs.setAxisType(AxisType.DIMENSION_MEMBER_LITERAL);
      axisAttrs.setOnColumnLayout(false);
      column1.setMultiDimensionAttributes(axisAttrs);
    } else {
      AxisAttributes axisAttrs = column1.getMultiDimensionAttributes();
      assertEquals(AxisType.DIMENSION_MEMBER_LITERAL, axisAttrs.getAxisType());
      assertFalse(axisAttrs.isOnColumnLayout());
    }

    // new display name and help text, etc.
    if (update) {
      dataUIHints = DesignFactory.eINSTANCE.createDataElementUIHints();
      dataUIHints.setDisplayName("new display name for column 2"); // $NON-NLS-1$
      dataAttrs = column2.getAttributes();
      dataAttrs.setUiHints(dataUIHints);
    } else {
      dataUIHints = column2.getAttributes().getUiHints();
      assertEquals("new display name for column 2", dataUIHints.getDisplayName());
    }

    if (update) {
      usageHints = DesignFactory.eINSTANCE.createOutputElementAttributes();
      usageHints.setHelpText("new help text for column 2"); // $NON-NLS-1$
      ValueFormatHints format = DesignFactory.eINSTANCE.createValueFormatHints();
      format.setDisplayFormat("new format for column 2"); // $NON-NLS-1$
      usageHints.setFormattingHints(format);
      column2.setUsageHints(usageHints);
    } else {
      usageHints = column2.getUsageHints();
      assertEquals("new help text for column 2", usageHints.getHelpText());
      ValueFormatHints format = usageHints.getFormattingHints();
      assertEquals("new format for column 2", format.getDisplayFormat());
    }
  }
Exemple #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);
    }
  }
Exemple #5
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;
  }