/**
   * Updates values in InputParameterAttributes to the given report parameter.
   *
   * @param dataAttrs the latest input parameter attributes
   * @param cachedDataAttrs the cached input parameter attributes
   * @param reportParam the report parameter
   * @param setHandle the ROM data set that has the corresponding data set parameter
   * @throws SemanticException
   */
  private void updateInputParameterAttrsToReportParam(
      InputParameterAttributes inputParamAttrs,
      InputParameterAttributes cachedInputParamAttrs,
      AbstractScalarParameterHandle reportParam,
      OdaDataSetHandle setHandle)
      throws SemanticException {
    if (inputParamAttrs == null) return;

    InputParameterUIHints paramUiHints = inputParamAttrs.getUiHints();
    if (paramUiHints != null && reportParam.getContainer() instanceof ParameterGroupHandle) {
      ParameterGroupHandle paramGroup = (ParameterGroupHandle) reportParam.getContainer();

      InputParameterUIHints cachedParamUiHints =
          cachedInputParamAttrs == null ? null : cachedInputParamAttrs.getUiHints();

      String cachedGroupPromptDisplayName =
          cachedParamUiHints == null ? null : cachedParamUiHints.getGroupPromptDisplayName();

      String groupPromptDisplayName = paramUiHints.getGroupPromptDisplayName();

      if (cachedGroupPromptDisplayName == null
          || !cachedGroupPromptDisplayName.equals(groupPromptDisplayName)) {
        paramGroup.setDisplayName(groupPromptDisplayName);

        paramGroup.setDisplayNameKey(paramUiHints.getGroupPromptDisplayNameKey());
      }
    }

    updateInputElementAttrsToReportParam(
        inputParamAttrs.getElementAttributes(),
        cachedInputParamAttrs == null ? null : cachedInputParamAttrs.getElementAttributes(),
        reportParam,
        setHandle);
  }
  /**
   * Creates a ODA InputParameterAttributes with the given ROM report parameter.
   *
   * @param inputParamAttrs
   * @param paramHandle the ROM report parameter.
   * @param dataSetDesign
   * @return the created <code>InputParameterAttributes</code>.
   */
  protected InputParameterAttributes updateInputElementAttrs(
      InputParameterAttributes inputParamAttrs,
      AbstractScalarParameterHandle paramHandle,
      DataSetDesign dataSetDesign) {
    InputParameterAttributes retInputParamAttrs = inputParamAttrs;

    if (inputParamAttrs == null)
      retInputParamAttrs = designFactory.createInputParameterAttributes();

    InputElementAttributes inputAttrs = retInputParamAttrs.getElementAttributes();
    if (inputAttrs == null) inputAttrs = designFactory.createInputElementAttributes();

    // update default values.

    updateDefaultStaticValues(inputAttrs, paramHandle);

    // inputAttrs.setOptional( paramHandle.allowBlank( ) );
    inputAttrs.setOptional(getReportParamAllowMumble(paramHandle, ALLOW_BLANK_PROP_NAME));

    ScalarValueChoices staticChoices = null;
    Iterator selectionList = paramHandle.choiceIterator();
    while (selectionList.hasNext()) {
      if (staticChoices == null) staticChoices = designFactory.createScalarValueChoices();
      SelectionChoiceHandle choice = (SelectionChoiceHandle) selectionList.next();

      ScalarValueDefinition valueDefn = designFactory.createScalarValueDefinition();
      valueDefn.setValue(choice.getValue());

      String label = choice.getLabel();
      String labelKey = choice.getLabelKey();

      if (label != null || labelKey != null) {
        valueDefn.setDisplayName(label);
        valueDefn.setDisplayNameKey(labelKey);
      }

      staticChoices.getScalarValues().add(valueDefn);
    }
    inputAttrs.setStaticValueChoices(staticChoices);

    ExpressionHandle valueExpr =
        paramHandle.getExpressionProperty(IAbstractScalarParameterModel.VALUE_EXPR_PROP);
    ExpressionHandle labelExpr =
        paramHandle.getExpressionProperty(IAbstractScalarParameterModel.LABEL_EXPR_PROP);

    DynamicValuesQuery valueQuery =
        updateDynamicValueQuery(
            paramHandle.getDataSet(),
            valueExpr.getValue(),
            labelExpr.getValue(),
            dataSetDesign,
            DesignChoiceConstants.PARAM_VALUE_TYPE_DYNAMIC.equalsIgnoreCase(
                paramHandle.getValueType()));
    inputAttrs.setDynamicValueChoices(valueQuery);

    if (paramHandle.getContainer() instanceof ParameterGroupHandle) {
      ParameterGroupHandle groupHandle = (ParameterGroupHandle) paramHandle.getContainer();

      InputParameterUIHints paramUiHints = designFactory.createInputParameterUIHints();

      String text = groupHandle.getDisplayName();
      String textKey = groupHandle.getDisplayNameKey();

      if (text != null || textKey != null) {
        paramUiHints.setGroupPromptDisplayName(text);
        paramUiHints.setGroupPromptDisplayNameKey(textKey);
      }

      retInputParamAttrs.setUiHints(paramUiHints);
    }

    retInputParamAttrs.setElementAttributes(inputAttrs);
    return retInputParamAttrs;
  }