Ejemplo n.º 1
0
  @SuppressWarnings("unchecked")
  private void prepareReportParams(RptProperties properties) {
    externalParams = new HashSet<String>();
    reportParams =
        new LinkedHashMap<
            String,
            ReportParameter>(); // use LinkedHashMap
                                // http://issues.m-g.ru/bugzilla/show_bug.cgi?id=4577
    IGetParameterDefinitionTask paramTask = engine.createGetParameterDefinitionTask(design);
    try {
      Collection<IParameterDefnBase> paramsC = paramTask.getParameterDefns(true);
      for (IParameterDefnBase param : paramsC) {
        if (param instanceof IParameterGroupDefn)
          addGroupReportParameter(
              properties, param.getName(), (IParameterGroupDefn) param, paramTask);
        else if (param instanceof IScalarParameterDefn)
          addReportParameter(
              properties,
              param.getName(),
              (IScalarParameterDefn) param,
              null,
              paramTask.getDefaultValue(param));
      }
    } finally {
      paramTask.close();
    }

    /*
     * BIRT не даёт работать с поименованными параметрами, приходится
     * обходить
     */
    List<DataSetHandle> dshL =
        (List<DataSetHandle>) design.getDesignHandle().getModuleHandle().getAllDataSets();

    for (DataSetHandle dsH : dshL) {
      if (dsH instanceof OdaDataSetHandle
          && MERP_DATASET_ID.equals(((OdaDataSetHandle) dsH).getExtensionID())) {
        ArrayList<String> paramNames = new ArrayList<String>();
        ArrayList<DataSetParameter> prms =
            (ArrayList<DataSetParameter>) dsH.getListProperty("parameters");
        if (prms != null) {
          for (DataSetParameter prm : prms) paramNames.add(prm.getName());

          datasetParams.put(dsH.getStringProperty(BAI_CODE), paramNames);
        }
      }
    }
    // *********************************************************//
  }
Ejemplo n.º 2
0
 @SuppressWarnings("unchecked")
 private void addGroupReportParameter(
     RptProperties properties,
     String name,
     IParameterGroupDefn param,
     IGetParameterDefinitionTask paramTask) {
   Collection<IParameterDefnBase> elements = ((IParameterGroupDefn) param).getContents();
   for (IParameterDefnBase param2 : elements)
     if (param2 instanceof IParameterGroupDefn)
       addGroupReportParameter(
           properties, param2.getName(), (IParameterGroupDefn) param2, paramTask);
     else if (param2 instanceof IScalarParameterDefn)
       addReportParameter(
           properties,
           param2.getName(),
           (IScalarParameterDefn) param2,
           (IParameterGroupDefn) param,
           paramTask.getDefaultValue(param2));
 }