/**
   * 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);
  }
  /* (non-Javadoc)
   * @see org.eclipse.datatools.connectivity.oda.design.ParameterDefinition#getEditableInputElementAttributes()
   * @generated NOT
   */
  public InputElementAttributes getEditableInputElementAttributes() {
    InputParameterAttributes paramAttributes = getInputAttributes();
    if (paramAttributes == null) {
      paramAttributes = DesignFactory.eINSTANCE.createInputParameterAttributes();
      setInputAttributes(paramAttributes);
    }

    InputElementAttributes inputAttributes = paramAttributes.getElementAttributes();
    if (inputAttributes == null) {
      inputAttributes = DesignFactory.eINSTANCE.createInputElementAttributes();
      paramAttributes.setElementAttributes(inputAttributes);
    }
    return inputAttributes;
  }
示例#3
0
  /**
   * Removes ODA data set parameter information that relates to the report parameter. In the design
   * value, do not need to save data for the report parameter.
   *
   * @param dsParams
   */
  private static void clearReportParameterRelatedValues(
      EList<DataSetParameter> params, ModuleHandle module) {
    if (params == null) return;

    for (int i = 0; i < params.size(); i++) {
      DataSetParameter adapterParam = params.get(i);
      ParameterDefinition param = adapterParam.getParameterDefinition();

      InputParameterAttributes paramAttrs = param.getInputAttributes();
      if (paramAttrs == null) continue;

      InputElementAttributes elementAttrs = paramAttrs.getElementAttributes();
      if (elementAttrs == null) continue;

      DynamicValuesQuery query = elementAttrs.getDynamicValueChoices();
      if (query == null) continue;

      DataSetDesign setDesign = query.getDataSetDesign();
      String setName = setDesign.getName();

      if (module.findDataSet(setName) != null) {
        // need to cache dynamic value query here. If the user breaks
        // the relationship between data set parameter and report
        // parameter. This cached value is used to update the dynamic
        // value in the new data set design

        DynamicList cachedDynamic = ModelFactory.eINSTANCE.createDynamicList();
        cachedDynamic.setDataSetName(setName);
        cachedDynamic.setValueColumn(query.getValueColumn());
        cachedDynamic.setLabelColumn(query.getDisplayNameColumn());

        adapterParam.setDynamicList(cachedDynamic);

        elementAttrs.setDynamicValueChoices(null);
      }
    }
  }
  /**
   * 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;
  }