예제 #1
0
  /**
   * @param hint
   * @param designHandle
   * @return
   */
  private boolean isEmpty(ColumnHint hint, ModuleHandle designHandle) {
    String alias = (String) hint.getProperty(designHandle.getModule(), ColumnHint.ALIAS_MEMBER);
    String displayName =
        (String) hint.getProperty(designHandle.getModule(), ColumnHint.DISPLAY_NAME_MEMBER);
    String displayNameKey =
        (String) hint.getProperty(designHandle.getModule(), ColumnHint.DISPLAY_NAME_ID_MEMBER);
    String helpText =
        (String) hint.getProperty(designHandle.getModule(), ColumnHint.HELP_TEXT_MEMBER);
    String analysis =
        (String) hint.getProperty(designHandle.getModule(), ColumnHint.ANALYSIS_MEMBER);

    return ((alias == null || alias.trim().length() == 0)
        && (displayName == null || displayName.trim().length() == 0)
        && (displayNameKey == null || displayNameKey.trim().length() == 0)
        && (helpText == null || helpText.trim().length() == 0)
        && (analysis == null || analysis.trim().length() == 0));
  }
 public static void handleInitialize(ModuleHandle design, ExecutionContext context) {
   try {
     String scriptText = design.getInitialize();
     Expression.Script scriptExpr = null;
     if (null != scriptText) {
       String id =
           ModuleUtil.getScriptUID(design.getPropertyHandle(IModuleModel.INITIALIZE_METHOD));
       scriptExpr = Expression.newScript(scriptText);
       scriptExpr.setFileName(id);
     }
     if (handleScript(null, scriptExpr, context).didRun()) return;
     IReportEventHandler eh = (IReportEventHandler) getInstance(design, context);
     if (eh != null) eh.initialize(context.getReportContext());
   } catch (Exception e) {
     addException(context, e, design);
   }
 }
예제 #3
0
  OdaDataSetHandle createDataSetHandle(DataSetDesign setDesign, ModuleHandle module)
      throws SemanticException, IllegalStateException {
    if (setDesign == null) return null;

    // validate the source design to make sure it is valid

    DesignUtil.validateObject(setDesign);

    OdaDataSetHandle setHandle =
        module
            .getElementFactory()
            .newOdaDataSet(setDesign.getName(), setDesign.getOdaExtensionDataSetId());

    if (setHandle == null) return null;

    adaptDataSetDesign(setDesign, setHandle);
    return setHandle;
  }
예제 #4
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);
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.birt.report.engine.api2.IParameterSelectionChoice#getLabel()
   */
  public String getLabel() {
    if (labelKey == null) return label;

    String ret = design.getMessage(labelKey, (locale == null) ? Locale.getDefault() : locale);
    return (ret == null || ret.length() == 0) ? label : ret;
  }
예제 #6
0
  /**
   * Copies values of <code>setDesign</code> to <code>setHandle</code>. Values in <code>setDesign
   * </code> are validated before maps to values in OdaDataSetHandle.
   *
   * @param setDesign the ODA data set design
   * @param setHandle the Model handle
   * @throws SemanticException if any value is invalid.
   */
  private void adaptDataSetDesign(DataSetDesign setDesign, OdaDataSetHandle setHandle)
      throws SemanticException {

    Object value = null;

    // properties on ReportElement, like name, displayNames, etc.

    value = setDesign.getName();
    PropertyValueValidationUtil.validateProperty(setHandle, OdaDataSetHandle.NAME_PROP, value);
    setHandle.getElement().setName(setDesign.getName());

    // properties on ReportElement, like name, displayNames, etc.

    value = setDesign.getDisplayName();
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.DISPLAY_NAME_PROP, value);
    setHandle.getElement().setProperty(OdaDataSetHandle.DISPLAY_NAME_PROP, value);

    value = setDesign.getDisplayNameKey();
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.DISPLAY_NAME_ID_PROP, value);
    setHandle.getElement().setProperty(OdaDataSetHandle.DISPLAY_NAME_ID_PROP, value);

    // properties such as comments, extends, etc are kept in
    // DataSourceHandle, not DataSourceDesign.

    // scripts of DataSource are kept in
    // DataSourceHandle, not DataSourceDesign.

    // set null or empty list if the return list is empty.

    value = newROMPrivateProperties(setDesign.getPrivateProperties());
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.PRIVATE_DRIVER_PROPERTIES_PROP, value);
    setHandle.getElement().setProperty(OdaDataSetHandle.PRIVATE_DRIVER_PROPERTIES_PROP, value);

    updateROMPublicProperties(setDesign.getPublicProperties(), setHandle);

    DataSourceDesign sourceDesign = setDesign.getDataSourceDesign();
    String dataSourceName = null;
    if (sourceDesign != null) {
      dataSourceName = sourceDesign.getName();
      ModuleHandle moduleHandle = setHandle.getModuleHandle();
      DataSourceHandle sourceHandle = null;
      if (isLinkedParameter) {
        sourceHandle =
            moduleHandle
                .getElementFactory()
                .newOdaDataSource(dataSourceName, sourceDesign.getOdaExtensionDataSourceId());
        moduleHandle.getDataSources().add(sourceHandle);
      } else sourceHandle = moduleHandle.findDataSource(dataSourceName);
      if (sourceHandle != null && sourceHandle instanceof OdaDataSourceHandle) {
        new DataSourceAdapter()
            .updateDataSourceHandle(sourceDesign, (OdaDataSourceHandle) sourceHandle);
        dataSourceName = sourceHandle.getName();
      }
    } else dataSourceName = defaultDataSourceName;

    setHandle
        .getElement()
        .setProperty(
            OdaDataSetHandle.DATA_SOURCE_PROP,
            PropertyValueValidationUtil.validateProperty(
                setHandle, OdaDataSetHandle.DATA_SOURCE_PROP, dataSourceName));

    // set the data set parameter list.

    setHandle.getElement().clearProperty(OdaDataSetHandle.PARAMETERS_PROP);

    List dataSetParams = new DataSetParameterAdapter(setHandle, setDesign).newROMSetParams(null);
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.PARAMETERS_PROP, dataSetParams);
    setHandle.getElement().setProperty(OdaDataSetHandle.PARAMETERS_PROP, dataSetParams);

    // set the result sets

    ResultSetsAdapter tmpAdapter = new ResultSetsAdapter(setHandle, setDesign);
    List resultRetColumns = tmpAdapter.newROMResultSets(null);
    // add filter condition for the result set
    tmpAdapter.updateROMFilterCondition();

    List columns = null;
    List hints = null;

    // if the return value is null, do not create an empty list.

    if (resultRetColumns != null) {
      columns = new ArrayList();
      hints = new ArrayList();

      ResultSetColumnInfo.updateResultSetColumnList(resultRetColumns, columns, hints);
      if (hints.isEmpty()) hints = null;

      PropertyValueValidationUtil.validateProperty(
          setHandle, OdaDataSetHandle.RESULT_SET_PROP, columns);
      PropertyValueValidationUtil.validateProperty(
          setHandle, OdaDataSetHandle.COLUMN_HINTS_PROP, hints);
    }
    setHandle.getElement().setProperty(OdaDataSetHandle.COLUMN_HINTS_PROP, hints);
    setHandle.getElement().setProperty(OdaDataSetHandle.RESULT_SET_PROP, columns);

    // set the query text.

    String queryText = setDesign.getQueryText();
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.QUERY_TEXT_PROP, queryText);
    setHandle.getElement().setProperty(OdaDataSetHandle.QUERY_TEXT_PROP, queryText);

    // set the result name

    String resultSetName = setDesign.getPrimaryResultSetName();
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.RESULT_SET_NAME_PROP, queryText);
    setHandle.getElement().setProperty(OdaDataSetHandle.RESULT_SET_NAME_PROP, resultSetName);

    // convert data set paramters and result set columns first. Then update
    // designer values.

    String odaValues = serializeOdaValues(setDesign);
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.DESIGNER_VALUES_PROP, odaValues);
    setHandle.getElement().setProperty(OdaDataSetHandle.DESIGNER_VALUES_PROP, odaValues);

    updateROMMessageFile(setDesign.getDataSourceDesign(), setHandle.getModuleHandle());
  }
예제 #7
0
 /**
  * Eventually, this method will call {@link ReportDesignHandle#serialize(java.io.OutputStream)}to
  * save the output file of some unit test.
  *
  * @param moduleHandle the module to save, either a report design or a library
  * @throws IOException if error occurs while saving the file.
  */
 protected void save(ModuleHandle moduleHandle) throws IOException {
   os = new ByteArrayOutputStream();
   if (moduleHandle != null) moduleHandle.serialize(os);
   os.close();
 }