/* (non-Javadoc)
   * @see org.eclipse.datatools.connectivity.oda.design.ParameterDefinition#addDefaultValue(java.lang.Object)
   * @generated NOT
   */
  public void addDefaultValue(Object aValue) {
    if (!isInput()) return; // ignore specified value

    InputElementAttributes inputAttributes = getEditableInputElementAttributes();

    inputAttributes.addDefaultValue(aValue);
  }
  /* (non-Javadoc)
   * @see org.eclipse.datatools.connectivity.oda.design.ParameterDefinition#setDefaultScalarValue(java.lang.String)
   * @generated NOT
   */
  public void setDefaultScalarValue(String value) {
    if (!isInput() || !isScalar()) return; // ignore specified value

    InputElementAttributes inputAttributes = getEditableInputElementAttributes();
    assert (inputAttributes != null);

    // use deprecated method that takes care of migrating value to a collection
    inputAttributes.setDefaultScalarValue(value);
  }
  /**
   * @param elementAttrs
   * @param cachedElementAttrs
   * @param reportParam
   * @throws SemanticException
   */
  protected void updateDefaultValueToReportParam(
      InputElementAttributes elementAttrs,
      InputElementAttributes cachedElementAttrs,
      AbstractScalarParameterHandle reportParam)
      throws SemanticException {
    // update default values.

    StaticValues defaultValues = elementAttrs.getDefaultValues();
    StaticValues cachedDefaultValues =
        cachedElementAttrs == null ? null : cachedElementAttrs.getDefaultValues();

    if (new EcoreUtil.EqualityHelper().equals(cachedDefaultValues, defaultValues) == false) {
      AdapterUtil.updateROMDefaultValues(defaultValues, reportParam);
    }
  }
  /**
   * @param inputAttrs
   * @param inputParamAttrs
   * @param paramHandle
   */
  protected void updateDefaultStaticValues(
      InputElementAttributes inputAttrs, AbstractScalarParameterHandle paramHandle) {
    // update default values.

    StaticValues newValues = null;
    List<Expression> tmpValues = paramHandle.getDefaultValueList();
    if (tmpValues != null) {
      for (int i = 0; i < tmpValues.size(); i++) {
        if (newValues == null) newValues = designFactory.createStaticValues();

        Expression tmpExpr = tmpValues.get(i);
        String odaValue = null;

        // for the constant, there is no need to remove quotes
        if (ExpressionType.CONSTANT.equalsIgnoreCase(tmpExpr.getType())) {
          odaValue = tmpExpr.getStringExpression();
        } else {
          odaValue =
              ParameterValueUtil.toODAValue(
                  tmpValues.get(i).getStringExpression(), paramHandle.getDataType());
        }
        newValues.add(odaValue);
      }
    }
    inputAttrs.setDefaultValues(newValues);
  }
Ejemplo n.º 5
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);
      }
    }
  }
  /**
   * Updates values in InputElementAttributes to the given report parameter.
   *
   * @param elementAttrs the latest input element attributes
   * @param cachedElementAttrs the cached input element attributes
   * @param reportParam the report parameter
   * @param setHandle the ROM data set that has the corresponding data set parameter
   * @throws SemanticException
   */
  protected void updateInputElementAttrsToReportParam(
      InputElementAttributes elementAttrs,
      InputElementAttributes cachedElementAttrs,
      AbstractScalarParameterHandle reportParam,
      OdaDataSetHandle setHandle)
      throws SemanticException {
    if (elementAttrs == null) return;

    // update default values.

    updateDefaultValueToReportParam(elementAttrs, cachedElementAttrs, reportParam);

    // update isOptional value
    Boolean isOptional = Boolean.valueOf(elementAttrs.isOptional());
    Boolean cachedIsOptional =
        cachedElementAttrs == null ? null : Boolean.valueOf(cachedElementAttrs.isOptional());
    if (!CompareUtil.isEquals(cachedIsOptional, isOptional))
      setReportParamIsRequired(reportParam, ALLOW_BLANK_PROP_NAME, isOptional.booleanValue());

    // update selection choices
    updateROMSelectionList(
        elementAttrs.getStaticValueChoices(),
        cachedElementAttrs == null ? null : cachedElementAttrs.getStaticValueChoices(),
        reportParam);

    // update dynamic list
    DynamicValuesQuery valueQuery = elementAttrs.getDynamicValueChoices();
    AdapterUtil.updateROMDyanmicList(
        valueQuery,
        cachedElementAttrs == null ? null : cachedElementAttrs.getDynamicValueChoices(),
        reportParam,
        setHandle);

    // for dynamic parameter, the flag is in DynamicValuesQuery is true
    // for static parameter, the DynamicValuesQuery is null or the flag is
    // false

    DynamicValuesQuery cachedValueQuery =
        cachedElementAttrs == null ? null : cachedElementAttrs.getDynamicValueChoices();

    boolean isEnabled = (valueQuery == null) ? false : valueQuery.isEnabled();

    if (reportParam.getContainer() != null
        && reportParam.getContainer() instanceof CascadingParameterGroupHandle) isEnabled = true;

    if (cachedValueQuery == null || cachedValueQuery.isEnabled() != isEnabled) {
      if (isEnabled) reportParam.setValueType(DesignChoiceConstants.PARAM_VALUE_TYPE_DYNAMIC);
      else reportParam.setValueType(DesignChoiceConstants.PARAM_VALUE_TYPE_STATIC);
    }
  }
  /**
   * 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;
  }