use of org.opennms.web.notification.NotificationModel in project opennms by OpenNMS.
the class NotificationFeed method getFeed.
/**
* <p>getFeed</p>
*
* @return a {@link com.sun.syndication.feed.synd.SyndFeed} object.
*/
@Override
public SyndFeed getFeed() {
SyndFeed feed = new SyndFeedImpl();
feed.setTitle("Notifications");
feed.setDescription("Notifications");
feed.setLink(getUrlBase() + "notification/browse");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
try {
NotificationModel model = new NotificationModel();
Notification[] notifications = model.allNotifications("desc");
SyndEntry entry;
int count = 0;
for (Notification notification : notifications) {
if (count++ == this.getMaxEntries()) {
break;
}
entry = new SyndEntryImpl();
entry.setPublishedDate(notification.getTimeSent());
if (notification.getTimeReplied() == null) {
entry.setTitle(sanitizeTitle(notification.getTextMessage()));
entry.setUpdatedDate(notification.getTimeSent());
} else {
entry.setTitle(sanitizeTitle(notification.getTextMessage()) + " (acknowledged)");
entry.setUpdatedDate(notification.getTimeReplied());
}
entry.setLink(getUrlBase() + "notification/detail.jsp?notice=" + notification.getId());
entry.setAuthor("OpenNMS");
entries.add(entry);
}
} catch (SQLException e) {
LOG.warn("unable to get outstanding notifications", e);
}
feed.setEntries(entries);
return feed;
}
Aggregations