Пример #1
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);
  }
Пример #2
0
  /**
   * Updates column hint values by given output element attributes.
   *
   * @param outputAttrs the latest output element attributes
   * @param cachedOutputAttrs the last(cached) output element attributes
   * @param newHint the column hint
   */
  private static void updateColumnHintFromUsageHints(
      OutputElementAttributes outputAttrs,
      OutputElementAttributes cachedOutputAttrs,
      ColumnHint newHint,
      OdaResultSetColumn column) {
    if (outputAttrs == null) return;

    // help text and key

    Object oldValue = cachedOutputAttrs == null ? null : cachedOutputAttrs.getHelpText();
    Object newValue = outputAttrs.getHelpText();
    if (!CompareUtil.isEquals(oldValue, newValue)) {
      newHint.setProperty(ColumnHint.HELP_TEXT_MEMBER, newValue);
    }

    oldValue = cachedOutputAttrs == null ? null : cachedOutputAttrs.getHelpTextKey();
    newValue = outputAttrs.getHelpTextKey();
    if (!CompareUtil.isEquals(oldValue, newValue)) {
      newHint.setProperty(ColumnHint.HELP_TEXT_ID_MEMBER, newValue);
    }

    // m_label maps to heading

    oldValue = cachedOutputAttrs == null ? null : cachedOutputAttrs.getLabel();
    newValue = outputAttrs.getLabel();
    if (!CompareUtil.isEquals(oldValue, newValue)) {
      newHint.setProperty(ColumnHint.HEADING_MEMBER, newValue);
    }

    oldValue = cachedOutputAttrs == null ? null : cachedOutputAttrs.getLabelKey();
    newValue = outputAttrs.getLabelKey();
    if (!CompareUtil.isEquals(oldValue, newValue)) {
      newHint.setProperty(ColumnHint.HEADING_ID_MEMBER, newValue);
    }

    // for values in formatting.

    ValueFormatHints formatHints = outputAttrs.getFormattingHints();
    if (formatHints == null) return;

    ValueFormatHints cachedFormatHints =
        cachedOutputAttrs == null ? null : cachedOutputAttrs.getFormattingHints();
    oldValue = cachedFormatHints == null ? null : cachedFormatHints.getDisplayFormat();

    // convert display format in oda to pattern part of value-format member
    newValue = formatHints.getDisplayFormat();
    if (!CompareUtil.isEquals(oldValue, newValue)) {
      FormatValue format = (FormatValue) newHint.getProperty(null, ColumnHint.VALUE_FORMAT_MEMBER);
      if (format == null && newValue != null) {
        format = StructureFactory.newFormatValue();
        newHint.setProperty(ColumnHint.VALUE_FORMAT_MEMBER, format);
      }

      // add logic to fix 32742: if the column is date-time, then do some
      // special handle for the format string in IO
      if (newValue != null
          && (column != null
              && DesignChoiceConstants.COLUMN_DATA_TYPE_DATETIME.equals(column.getDataType()))) {
        String formatValue = (String) newValue;
        newValue = formatValue.replaceFirst("mm/", "MM/"); // $NON-NLS-1$//$NON-NLS-2$
      }
      if (format != null) format.setPattern((String) newValue);
    }

    // not support display length
    /*
     * newValue = formatHints.getDisplaySize( ); oldValue =
     * cachedFormatHints == null ? null : cachedFormatHints .getDisplaySize(
     * ); if ( oldValue == null || !oldValue.equals( newValue ) ) {
     * newHint.setProperty( ColumnHint.DISPLAY_LENGTH_MEMBER, newValue ); }
     */

    newValue = formatHints.getHorizontalAlignment();
    oldValue = cachedFormatHints == null ? null : cachedFormatHints.getHorizontalAlignment();
    if (formatHints.isSetHorizontalAlignment() && !CompareUtil.isEquals(oldValue, newValue)) {
      newHint.setProperty(
          ColumnHint.HORIZONTAL_ALIGN_MEMBER,
          convertToROMHorizontalAlignment((HorizontalAlignment) newValue));
    }

    // not support word-wrap
    /*
     * newValue = formatHints.getTextWrapType( ); oldValue =
     * cachedFormatHints == null ? null : cachedFormatHints
     * .getTextWrapType( );
     *
     * if ( oldValue == null || !oldValue.equals( newValue ) ) {
     * newHint.setProperty( ColumnHint.WORD_WRAP_MEMBER,
     * convertToROMWordWrap( (TextWrapType) newValue ) ); }
     */

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