_typedNewsEntries = new HashMap<String, List<NewsEntry>>();
_categorizedTopNewsEntries = new HashMap<String, List<NewsEntry>>();
Database db = ExtLibUtil.getCurrentDatabase();
View view = null;
ViewNavigator navigator = null;
FacesContext context = FacesContext.getCurrentInstance();
ConfigCache config = (ConfigCache) context.getApplication()
.getVariableResolver().resolveVariable(context, "configCache");
try {
view = db.getView("NewsModeratedCached");
view.setAutoUpdate(false);
navigator = view.createViewNav();
ViewEntry tmpEntry;
ViewEntry entry = navigator.getFirst();
while (entry != null) {
try {
entry.setPreferJavaDates(true);
List<Object> columnValues = entry.getColumnValues();
Date d1 = MiscUtils.getColumnValueAsDate(columnValues.get(4));
Date d2 = MiscUtils.getColumnValueAsDate(columnValues.get(0));
Date d3 = MiscUtils.getColumnValueAsDate(columnValues.get(15));
Date d4 = MiscUtils.getColumnValueAsDate(columnValues.get(22));
Double clicksTotalDouble = MiscUtils.getColumnValueAsDouble(columnValues.get(13));
Double clicksLastWeekDouble = MiscUtils.getColumnValueAsDouble(columnValues.get(14));
String spotlightImageURL = (String)columnValues.get(18);
if (spotlightImageURL != null) {
if (!spotlightImageURL.equals("")) {
spotlightImageURL = entry.getUniversalID()
+ "/$file/" + spotlightImageURL;
} else {
spotlightImageURL = null;
}
}
NewsEntry newsEntry = new NewsEntry(
(String)columnValues.get(8),
(String)columnValues.get(1),
(String)columnValues.get(2),
(String)columnValues.get(3),
(String)columnValues.get(5),
(String)columnValues.get(6),
(String)columnValues.get(7),
d1,
d2,
(String)columnValues.get(9),
(String)columnValues.get(10),
(String)columnValues.get(11),
(String)columnValues.get(12),
clicksTotalDouble,
clicksLastWeekDouble,
d3,
(String)columnValues.get(16),
(String)columnValues.get(17),
spotlightImageURL,
(String)columnValues.get(19),
(String)columnValues.get(20),
(String)columnValues.get(21),
d4
);
_newsEntries.add(newsEntry);
if (newsEntry.isSpotlight())
_spotlightNewsEntries.add(newsEntry);
getTypedEntriesList(newsEntry.getTID()).add(newsEntry);
if (newsEntry.isTopStory()) {
if(newsEntry.getTopStoryCategory().equalsIgnoreCase("top")) {
_topTopStories.add(newsEntry);
} else {
getCategorizedTopEntriesList(
newsEntry.getTopStoryCategory()).add(
newsEntry);
}
}
} catch (Exception e) {
}
tmpEntry = navigator.getNext();
entry.recycle();
entry = tmpEntry;
}
_spotlightNewsEntries = sortSpotlightStories(_spotlightNewsEntries);
_topTopStories = sortTopStories(_topTopStories);
if (_categorizedTopNewsEntries != null) {
List<Category> categories = config.getCategories();
if (categories != null) {
Iterator it = categories.iterator();
for (; it.hasNext();) {
Category category = (Category) it.next();
List<NewsEntry> catTopNews = _categorizedTopNewsEntries.get(category.getID());
catTopNews = sortTopStories(catTopNews);
_categorizedTopNewsEntries.put(category.getID(),
catTopNews);
}
}
}
} catch (Exception e) {
e.printStackTrace();
return;
} catch (Throwable t) {
t.printStackTrace();
return;
} finally {
try {
if (navigator != null) {
navigator.recycle();
}
if (view != null) {
view.recycle();
}
} catch (NotesException e) {