/**
   * 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());
    }
  }
  /**
   * 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 #3
0
  /**
   * Updates hint-related information on the ODA <code>columnDefn</code>.
   *
   * @param columnDefn
   * @param hint
   */
  private void updateOdaColumnHint(ColumnDefinition columnDefn, ColumnHintHandle hint) {
    DataElementAttributes dataAttrs = columnDefn.getAttributes();

    DataElementUIHints uiHints = null;
    // update display name

    String displayName = hint.getDisplayName();
    String displayNameKey = hint.getDisplayNameKey();

    if (displayName != null || displayNameKey != null) {
      uiHints = designFactory.createDataElementUIHints();

      uiHints.setDisplayName(displayName);
      uiHints.setDisplayNameKey(displayNameKey);
    }

    // description maps to the description in data element UI hints.
    // String desc = hint.getDescription( );
    // String descKey = hint.getDescriptionKey( );
    /*
     * if ( desc != null || descKey != null ) { if ( uiHints == null )
     * uiHints = designFactory.createDataElementUIHints( );
     *
     * uiHints.setDescription( desc ); uiHints.setDescriptionKey( descKey );
     * }
     */

    dataAttrs.setUiHints(uiHints);

    // update usage hints.

    OutputElementAttributes outputAttrs = null;

    String helpText = hint.getHelpText();
    String helpTextKey = hint.getHelpTextKey();

    if (helpText != null || helpTextKey != null) {
      outputAttrs = designFactory.createOutputElementAttributes();
      if (helpText != null || helpTextKey != null) {
        outputAttrs.setHelpText(helpText);
        outputAttrs.setHelpTextKey(helpTextKey);
      }
    }

    // heading maps to m_label

    String heading = hint.getHeading();
    String headingKey = hint.getHeadingKey();
    if (heading != null || headingKey != null) {
      if (outputAttrs == null) outputAttrs = designFactory.createOutputElementAttributes();
      if (heading != null || headingKey != null) {
        outputAttrs.setLabel(heading);
        outputAttrs.setLabelKey(headingKey);
      }
    }

    // formatting related.

    FormatValue format = hint.getValueFormat();
    // int displayLength = hint.getDisplayLength( );
    // boolean wordWrap = hint.wordWrap( );
    String horizontalAlign = hint.getHorizontalAlign();

    if ((format != null && format.getPattern() != null) || horizontalAlign != null) {
      if (outputAttrs == null) outputAttrs = designFactory.createOutputElementAttributes();

      ValueFormatHints formatHint = designFactory.createValueFormatHints();

      if (format != null) formatHint.setDisplayFormat(format.getPattern());
      // formatHint.setDisplaySize( displayLength );
      formatHint.setHorizontalAlignment(convertToOdaHorizontalAlignment(horizontalAlign));
      // formatHint.setTextWrapType( convertToROMWordWrap( wordWrap ) );

      // cannot handle text format since two objects in ODA and ROM are
      // different.

      outputAttrs.setFormattingHints(formatHint);
    }

    columnDefn.setUsageHints(outputAttrs);

    // update axis attributes

    AxisAttributes axisAttrs = null;

    String analysisType = hint.getAnalysis();
    AxisType axisType = convertAnalysisTypeToAxisType(analysisType);

    if (axisType != null) {
      axisAttrs = designFactory.createAxisAttributes();
      axisAttrs.setAxisType(axisType);
      axisAttrs.setOnColumnLayout(hint.isOnColumnLayout());
      String analysisColumnName = hint.getAnalysisColumn();
      if (!StringUtil.isBlank(analysisColumnName)) {
        ResultSubset relatedColumns = designFactory.createResultSubset();
        relatedColumns.addColumnIdentifier(analysisColumnName);
        axisAttrs.setRelatedColumns(relatedColumns);
      }
    }

    columnDefn.setMultiDimensionAttributes(axisAttrs);
  }