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

    Object oldValue = cachedDataAttrs == null ? null : cachedDataAttrs.getName();
    Object newValue = dataAttrs.getName();
    // If column name in hint already matches column name in column, don't
    // update it even if
    // oda has a new column name. Column name in hint and column has to
    // match as model use column name
    // as identifier to relate column and hint
    if (!CompareUtil.isEquals(
            newHint.getProperty(null, ColumnHint.COLUMN_NAME_MEMBER), column.getColumnName())
        && !CompareUtil.isEquals(oldValue, newValue))
      newHint.setProperty(ColumnHint.COLUMN_NAME_MEMBER, newValue);

    DataElementUIHints dataUIHints = dataAttrs.getUiHints();
    if (dataUIHints == null) return;

    DataElementUIHints cachedDataUIHints =
        cachedDataAttrs == null ? null : cachedDataAttrs.getUiHints();
    oldValue = cachedDataUIHints == null ? null : cachedDataUIHints.getDisplayName();
    newValue = dataUIHints.getDisplayName();
    if (!CompareUtil.isEquals(oldValue, newValue)) {
      newHint.setProperty(ColumnHint.DISPLAY_NAME_MEMBER, newValue);
    }

    oldValue = cachedDataUIHints == null ? null : cachedDataUIHints.getDisplayNameKey();
    newValue = dataUIHints.getDisplayNameKey();
    if (!CompareUtil.isEquals(oldValue, newValue)) {
      newHint.setProperty(ColumnHint.DISPLAY_NAME_ID_MEMBER, newValue);
    }

    // description to description in data ui hints: not support now

    /*
     * oldValue = cachedDataUIHints == null ? null : cachedDataUIHints
     * .getDescription( ); newValue = dataUIHints.getDescription( ); if (
     * oldValue == null || !oldValue.equals( newValue ) ) {
     * newHint.setProperty( ColumnHint.DESCRIPTION_MEMBER, newValue ); }
     *
     * oldValue = cachedDataUIHints == null ? null : cachedDataUIHints
     * .getDescriptionKey( ); newValue = dataUIHints.getDescriptionKey( );
     * if ( oldValue == null || !oldValue.equals( newValue ) ) {
     * newHint.setProperty( ColumnHint.DESCRIPTION_ID_MEMBER, newValue ); }
     */

  }
  /**
   * Updates values in DataElementAttributes to the given report parameter.
   *
   * @param dataAttrs the latest data element attributes
   * @param cachedDataAttrs the cached data element attributes
   * @param reportParam the report parameter
   * @throws SemanticException
   */
  private void updateDataElementAttrsToReportParam(
      DataElementAttributes dataAttrs,
      DataElementAttributes cachedDataAttrs,
      AbstractScalarParameterHandle reportParam)
      throws SemanticException {

    if (dataAttrs == null) return;

    boolean allowsNull = dataAttrs.allowsNull();
    if (cachedDataAttrs == null || cachedDataAttrs.allowsNull() != allowsNull)
      setReportParamIsRequired(reportParam, ALLOW_NULL_PROP_NAME, dataAttrs.allowsNull());

    // reportParam.setAllowNull( dataAttrs.allowsNull( ) );

    DataElementUIHints dataUiHints = dataAttrs.getUiHints();
    DataElementUIHints cachedDataUiHints =
        (cachedDataAttrs == null ? null : cachedDataAttrs.getUiHints());
    if (dataUiHints != null) {
      String displayName = dataUiHints.getDisplayName();
      String cachedDisplayName =
          cachedDataUiHints == null ? null : cachedDataUiHints.getDisplayName();

      boolean isChanged = false;

      if (cachedDisplayName == null || !cachedDisplayName.equals(displayName)) {
        isChanged = true;
        reportParam.setPromptText(displayName);
        reportParam.setPromptTextID(dataUiHints.getDisplayNameKey());
      }
      if (!isChanged && cachedDataUiHints != null && cachedDisplayName != null) {
        reportParam.setPromptText(cachedDisplayName);
        reportParam.setPromptTextID(cachedDataUiHints.getDisplayNameKey());
      }

      isChanged = false;
      String description = dataUiHints.getDescription();
      String cachedDescription =
          cachedDataUiHints == null ? null : cachedDataUiHints.getDescription();
      if (cachedDescription == null || !cachedDescription.equals(description)) {
        isChanged = true;
        reportParam.setHelpText(description);
        reportParam.setHelpTextKey(dataUiHints.getDescriptionKey());
      }

      if (!isChanged && cachedDataUiHints != null && cachedDescription != null) {
        reportParam.setHelpText(cachedDescription);
        reportParam.setHelpTextKey(cachedDataUiHints.getDescriptionKey());
      }
    }
  }
Пример #4
0
  /**
   * Checks whether there are values for newly created column hint.
   *
   * @param dataUIHints the latest data ui hints
   * @param outputAttrs the latest output element attributes
   * @return <code>true</code> if no column hint value is set. Otherwise <code>false</code>.
   */
  private static boolean hasColumnHintValue(
      DataElementUIHints dataUIHints,
      OutputElementAttributes outputAttrs,
      AxisAttributes axisAttrs) {
    if (dataUIHints == null && outputAttrs == null && axisAttrs == null) return false;

    boolean isValueSet = false;
    if (dataUIHints != null) {
      if (dataUIHints.getDisplayName() != null) isValueSet = true;
    }

    if (!isValueSet && outputAttrs != null) {
      if (outputAttrs.getHelpText() != null) isValueSet = true;

      if (!isValueSet) {
        ValueFormatHints formatHints = outputAttrs.getFormattingHints();
        if (formatHints != null) isValueSet = true;
      }
    }

    if (!isValueSet && axisAttrs != null) {
      isValueSet = axisAttrs.isSetAxisType();

      if (!isValueSet) {
        isValueSet = axisAttrs.isSetOnColumnLayout();
      }
    }
    return isValueSet;
  }
  /**
   * 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());
    }
  }