public boolean validateParameters(
      List<ReportParameterMap> reportParameters, Map<String, Object> parameters)
      throws ProviderException {
    parameters = new SingleValueMap(parameters);

    if (reportParameters != null && reportParameters.size() > 0) {
      Iterator<ReportParameterMap> iterator = reportParameters.iterator();
      while (iterator.hasNext()) {
        ReportParameterMap rpMap = iterator.next();

        ReportParameter param = rpMap.getReportParameter();

        if (!parameters.containsKey(param.getName()) && rpMap.isRequired()) {
          throw new ProviderException(LocalStrings.ERROR_PARAMETER_REQUIRED);
        }

        if (param.getType().equals(ReportParameter.TEXT_PARAM)
            || param.getType().equals(ReportParameter.DATE_PARAM)) {
          String value = (String) parameters.get(param.getName());

          if (value != null && value.length() > 0) {
            try {
              validateParameter(param, value);
            } catch (Exception e) {
              throw new ProviderException(e.getMessage());
            }
          } else if (rpMap.isRequired()) {
            throw new ProviderException(LocalStrings.ERROR_PARAMETER_REQUIRED);
          }
        }
      }
    }

    return true;
  }
  public List<ReportParameter> getReportParameters(Report report, String type)
      throws ProviderException {
    List<ReportParameter> parameters = new ArrayList<ReportParameter>();

    List<ReportParameterMap> allParameters = report.getParameters();

    if (allParameters != null) {
      Iterator<ReportParameterMap> iterator = allParameters.iterator();

      while (iterator.hasNext()) {
        ReportParameterMap rpMap = iterator.next();

        if (rpMap.getReportParameter().getType().equals(type)) {
          parameters.add(rpMap.getReportParameter());
        }
      }
    }

    return parameters;
  }
  public List<ReportParameter> getAvailableParameters(Report report) throws ProviderException {
    List<ReportParameter> parameters = getReportParameters();

    Iterator<ReportParameter> iterator = parameters.iterator();
    while (iterator.hasNext()) {
      ReportParameter rp = iterator.next();

      Iterator<ReportParameterMap> reportIterator = report.getParameters().iterator();
      while (reportIterator.hasNext()) {
        ReportParameterMap rpMap = reportIterator.next();

        if (rp.getId().equals(rpMap.getReportParameter().getId())) {
          parameters.remove(rp);
          iterator = parameters.iterator();
        }
      }
    }

    return parameters;
  }
  public Map<String, Object> getReportParametersMap(
      List<ReportParameterMap> reportParameters, Map<String, Object> origParameters)
      throws ProviderException {
    Map<String, Object> map = new HashMap<String, Object>();

    // if multiple selections, use origParameters; otherwise, use
    // parameters
    Map<String, Object> parameters = new SingleValueMap(origParameters);

    Iterator<ReportParameterMap> iterator = reportParameters.iterator();
    while (iterator.hasNext()) {
      ReportParameterMap rpMap = iterator.next();

      ReportParameter reportParameter = rpMap.getReportParameter();

      // if we are expecting multiple selections, convert the array of
      // parameters
      // into a comma-delimited string so that it can be used in the SQL
      // where
      // clause. Otherwise, just expect a simple String
      if (reportParameter.isMultipleSelect()) {
        Object[] values = (String[]) origParameters.get(reportParameter.getName());

        // load up the StringBuffer with the multiple selections.
        String s = buildMultipleSelectString(reportParameter, values);

        // save the parameter into the Map
        if (rpMap.isRequired() || s.length() > 0) {
          map.put(reportParameter.getName(), s);

          log.debug(reportParameter.getName() + " => " + map.get(reportParameter.getName()));
        }
      } else {
        String value = (String) parameters.get(reportParameter.getName());

        if (value != null) {
          try {
            Object object = parseParameter(reportParameter, value);

            if (rpMap.isRequired() || value.length() > 0) {
              map.put(reportParameter.getName(), object);
            }
          } catch (Exception e) {
            log.warn(
                "Error setting parameter: " + reportParameter.getName() + " : " + e.getMessage());
          }
        }
      }
    }

    // always pass drilldown chart parameter to reports if it exists

    String value = (String) parameters.get(ReportChart.DRILLDOWN_PARAMETER);

    if (value != null)
      map.put(ReportChart.DRILLDOWN_PARAMETER, parameters.get(ReportChart.DRILLDOWN_PARAMETER));

    //

    return map;
  }