コード例 #1
0
  /**
   * Creates an DataElementAttributes with the given ROM report parameter.
   *
   * @param paramHandle the ROM report parameter.
   * @return the created DataElementAttributes
   */
  private DataElementAttributes updateDataElementAttrs(
      DataElementAttributes dataAttrs, AbstractScalarParameterHandle paramHandle) {
    DataElementAttributes retDataAttrs = dataAttrs;

    if (retDataAttrs == null) retDataAttrs = designFactory.createDataElementAttributes();

    // retDataAttrs.setNullability( DataSetParameterAdapter
    // .newElementNullability( paramHandle.allowNll( ) ) );

    retDataAttrs.setNullability(
        DataSetParameterAdapter.newElementNullability(
            getReportParamAllowMumble(paramHandle, ALLOW_NULL_PROP_NAME)));

    DataElementUIHints uiHints = designFactory.createDataElementUIHints();

    String text = paramHandle.getPromptText();
    String textKey = paramHandle.getPromptTextID();

    if (text != null || textKey != null) {
      uiHints.setDisplayName(text);
      uiHints.setDisplayNameKey(textKey);
    }

    text = paramHandle.getHelpText();
    textKey = paramHandle.getHelpTextKey();

    if (text != null || textKey != null) {
      uiHints.setDescription(text);
      uiHints.setDescriptionKey(textKey);
    }

    retDataAttrs.setUiHints(uiHints);

    return retDataAttrs;
  }
コード例 #2
0
ファイル: ResultSetsAdapter.java プロジェクト: WPCode/birt
  /**
   * Creates a ResultSetDefinition with the given ROM ResultSet columns.
   *
   * @return the created ResultSetDefinition
   */
  private ResultSetDefinition newOdaResultSetDefinition() {
    Iterator romSets = setDefinedResults.iterator();
    String name = setHandle.getResultSetName();

    if (!romSets.hasNext()) return null;

    ResultSetDefinition odaSetDefn = null;
    ResultSetColumns odaSetColumns = null;

    if (!StringUtil.isBlank(name)) {
      odaSetDefn = designFactory.createResultSetDefinition();
      odaSetDefn.setName(name);
    }

    while (romSets.hasNext()) {
      if (odaSetDefn == null) odaSetDefn = designFactory.createResultSetDefinition();

      if (odaSetColumns == null) odaSetColumns = designFactory.createResultSetColumns();

      OdaResultSetColumnHandle setColumn = (OdaResultSetColumnHandle) romSets.next();

      // get the colum hint

      ColumnHintHandle hint =
          AdapterUtil.findColumnHint(
              (OdaResultSetColumn) setColumn.getStructure(), setDefinedColumnHints.iterator());

      ColumnDefinition columnDefn = designFactory.createColumnDefinition();

      DataElementAttributes dataAttrs = designFactory.createDataElementAttributes();

      String newName = setColumn.getNativeName();
      dataAttrs.setName(newName);

      Integer position = setColumn.getPosition();
      if (position != null) dataAttrs.setPosition(setColumn.getPosition().intValue());

      Integer nativeDataType = setColumn.getNativeDataType();
      if (nativeDataType != null) dataAttrs.setNativeDataTypeCode(nativeDataType.intValue());

      columnDefn.setAttributes(dataAttrs);
      odaSetColumns.getResultColumnDefinitions().add(columnDefn);

      if (hint == null) continue;

      updateOdaColumnHint(columnDefn, hint);
    }

    if (odaSetDefn != null) odaSetDefn.setResultSetColumns(odaSetColumns);

    return odaSetDefn;
  }
コード例 #3
0
  /**
   * @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);
  }
コード例 #4
0
  protected DynamicValuesQuery updateDynamicValueQuery(
      DataSetHandle setHandle,
      Object valueColumn,
      Object labelColumn,
      DataSetDesign dataSetDesign,
      boolean isEnabled) {
    DynamicValuesQuery valueQuery = null;

    if (setHandle instanceof OdaDataSetHandle && valueColumn != null) {
      valueQuery = designFactory.createDynamicValuesQuery();

      if (dataSetDesign != null) {
        DataSetDesign targetDataSetDesign = (DataSetDesign) EcoreUtil.copy(dataSetDesign);
        if (!setHandle.getName().equals(dataSetDesign.getName()))
          targetDataSetDesign =
              new ModelOdaAdapter().createDataSetDesign((OdaDataSetHandle) setHandle);
        valueQuery.setDataSetDesign(targetDataSetDesign);
      } else {
        DataSetDesign targetDataSetDesign =
            new ModelOdaAdapter().createDataSetDesign((OdaDataSetHandle) setHandle);
        valueQuery.setDataSetDesign(targetDataSetDesign);
      }
      valueQuery.setDisplayNameColumn(AdapterUtil.extractColumnName(labelColumn));
      valueQuery.setValueColumn(AdapterUtil.extractColumnName(valueColumn));
      valueQuery.setEnabled(isEnabled);
    }

    return valueQuery;
  }
コード例 #5
0
ファイル: ResultSetsAdapter.java プロジェクト: WPCode/birt
  /**
   * 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);
  }
コード例 #6
0
  /**
   * 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;
  }