public List getNextPrevEntries( WeblogEntryData current, String catName, String locale, int maxEntries, boolean next) throws RollerException { Junction conjunction = Expression.conjunction(); conjunction.add(Expression.eq("website", current.getWebsite())); conjunction.add(Expression.eq("status", WeblogEntryData.PUBLISHED)); if (next) { conjunction.add(Expression.gt("pubTime", current.getPubTime())); } else { conjunction.add(Expression.lt("pubTime", current.getPubTime())); } if (catName != null && !catName.trim().equals("/")) { WeblogCategoryData category = getWeblogCategoryByPath(current.getWebsite(), null, catName); if (category != null) { conjunction.add(Expression.eq("category", category)); } else { throw new RollerException("Cannot find category: " + catName); } } if (locale != null) { conjunction.add(Expression.ilike("locale", locale, MatchMode.START)); } try { Session session = ((HibernatePersistenceStrategy) this.strategy).getSession(); Criteria criteria = session.createCriteria(WeblogEntryData.class); criteria.addOrder(next ? Order.asc("pubTime") : Order.desc("pubTime")); criteria.add(conjunction); criteria.setMaxResults(maxEntries); List results = criteria.list(); return results; } catch (HibernateException e) { throw new RollerException(e); } }
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; }