return chapters;
}
public List<List<Chapter>> getChaptersGroupedByCountry() {
MemcacheService ms = MemcacheServiceFactory.getMemcacheService();
if (!ms.contains(CHAPTERS_GROUPED_BY_COUNTRY_MEMCACHE_KEY)) {
List<Chapter> chapters = chapterDao.getChaptersOrderedByCountry();
if (chapters == null) {
return null;
}
List<List<Chapter>> groups = new ArrayList<List<Chapter>>();
List<Chapter> group = new ArrayList<Chapter>();
String country = chapters.get(0).getCountry();
for (Chapter chapter : chapters) {
if (!chapter.getCountry().equals(country)) {
groups.add(group);
group = new ArrayList<Chapter>();
country = chapter.getCountry();
}
group.add(chapter);
}
groups.add(group);
ms.put(CHAPTERS_GROUPED_BY_COUNTRY_MEMCACHE_KEY, groups);
}
return (List<List<Chapter>>) ms.get(
CHAPTERS_GROUPED_BY_COUNTRY_MEMCACHE_KEY);
}