Exemplo n.º 1
0
  protected List<FilterDescription> generateFilterDescriptions(
      Filter filter, Set<DimensionType> excludeDims, User user) {

    List<FilterDescription> list = new ArrayList<FilterDescription>();

    Set<DimensionType> filterDims = filter.getRestrictedDimensions();
    filterDims.removeAll(excludeDims);

    for (DimensionType type : filterDims) {

      list.add(
          new FilterDescription(
              type, pivotDAO.getFilterLabels(type, filter.getRestrictions(type))));
    }

    if (filter.getMinDate() != null || filter.getMaxDate() != null) {
      DateRangeFormat format = new DateRangeFormat(user.getLocaleInstance());

      list.add(
          new FilterDescription(
              DimensionType.Date, format.format(filter.getMinDate(), filter.getMaxDate())));
    }

    return list;
  }
Exemplo n.º 2
0
  /**
   * Resolves a templated string using the supplied parameters. Parameters can be referenced within
   * the template as ${DATE_RANGE}. Case sensitive.
   *
   * @param template The file name template
   * @param range The date range of the report
   * @param user The user for whom the report will be generated (required for the locale)
   * @return The resolved file name
   * @see org.sigmah.shared.report.model.Report#getFileName()
   */
  protected String resolveTemplate(String template, DateRange range, User user) {

    if (template.contains("${DATE_RANGE}")) {
      DateRangeFormat format = new DateRangeFormat(user.getLocaleInstance());
      String rangeText = format.format(range);

      return template.replace("${DATE_RANGE}", rangeText);
    } else {
      return template;
    }
  }