private Map getWeblogEntryMap(
      WebsiteData website,
      Date startDate,
      Date endDate,
      String catName,
      String status,
      boolean stringsOnly,
      String locale,
      int offset,
      int length)
      throws RollerException {

    TreeMap map = new TreeMap(reverseComparator);

    List entries =
        getWeblogEntries(
            website, null, startDate, endDate, catName, status, null, locale, offset, length);

    Calendar cal = Calendar.getInstance();
    if (website != null) {
      cal.setTimeZone(website.getTimeZoneInstance());
    }

    SimpleDateFormat formatter = DateUtil.get8charDateFormat();
    for (Iterator wbItr = entries.iterator(); wbItr.hasNext(); ) {
      WeblogEntryData entry = (WeblogEntryData) wbItr.next();
      Date sDate = DateUtil.getNoonOfDay(entry.getPubTime(), cal);
      if (stringsOnly) {
        if (map.get(sDate) == null) map.put(sDate, formatter.format(sDate));
      } else {
        List dayEntries = (List) map.get(sDate);
        if (dayEntries == null) {
          dayEntries = new ArrayList();
          map.put(sDate, dayEntries);
        }
        dayEntries.add(entry);
      }
    }
    return map;
  }
예제 #2
0
 public Date getEndDate(Locale locale) {
   Date endDate = null;
   final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
   if (null != getEndDateString() && getEndDateString().trim().length() > 0) {
     try {
       endDate = DateUtil.getEndOfDay(df.parse(getEndDateString()));
     } catch (ParseException e) {
       // what!?! calendar widget handed us a bad date?
       logger.debug("Parsing endDate", e);
     }
   }
   return endDate;
 }
  /** @inheritDoc */
  public Map<Date, String> getWeblogEntryStringMap(WeblogEntrySearchCriteria wesc)
      throws WebloggerException {
    TreeMap<Date, String> map = new TreeMap<Date, String>(Collections.reverseOrder());

    List<WeblogEntry> entries = getWeblogEntries(wesc);

    Calendar cal = Calendar.getInstance();
    SimpleDateFormat formatter = DateUtil.get8charDateFormat();
    if (wesc.getWeblog() != null) {
      TimeZone tz = wesc.getWeblog().getTimeZoneInstance();
      cal.setTimeZone(tz);
      formatter.setTimeZone(tz);
    }

    for (WeblogEntry entry : entries) {
      Date sDate = DateUtil.getNoonOfDay(entry.getPubTime(), cal);
      if (map.get(sDate) == null) {
        map.put(sDate, formatter.format(sDate));
      }
    }
    return map;
  }
  /** @inheritDoc */
  public Map<Date, List<WeblogEntry>> getWeblogEntryObjectMap(WeblogEntrySearchCriteria wesc)
      throws WebloggerException {
    TreeMap<Date, List<WeblogEntry>> map =
        new TreeMap<Date, List<WeblogEntry>>(Collections.reverseOrder());

    List<WeblogEntry> entries = getWeblogEntries(wesc);

    Calendar cal = Calendar.getInstance();
    if (wesc.getWeblog() != null) {
      cal.setTimeZone(wesc.getWeblog().getTimeZoneInstance());
    }

    for (WeblogEntry entry : entries) {
      Date sDate = DateUtil.getNoonOfDay(entry.getPubTime(), cal);
      List<WeblogEntry> dayEntries = map.get(sDate);
      if (dayEntries == null) {
        dayEntries = new ArrayList<WeblogEntry>();
        map.put(sDate, dayEntries);
      }
      dayEntries.add(entry);
    }
    return map;
  }