private ActionForward forwardToAlertMessageArchive(ActionMapping mapping, HttpServletRequest request, YearMonth yearMonthBean) {
Integer year = yearMonthBean.getYear();
if (year == null) {
year = Integer.valueOf(ExecutionYear.readCurrentExecutionYear().getYear());
}
Month month = yearMonthBean.getMonth();
TreeSet<PhdAlertMessage> orderedMessages =
new TreeSet<PhdAlertMessage>(Collections.reverseOrder(PhdAlertMessage.COMPARATOR_BY_WHEN_CREATED_AND_ID));
if (month == null) {
for (PhdAlertMessage message : getLoggedPerson(request).getPhdAlertMessagesSet()) {
if (year == message.getWhenCreated().getYear()) {
orderedMessages.add(message);
}
}
} else {
for (PhdAlertMessage message : getLoggedPerson(request).getPhdAlertMessagesSet()) {
if ((year == message.getWhenCreated().getYear())
&& (month.getNumberOfMonth() == message.getWhenCreated().getMonthOfYear())) {
orderedMessages.add(message);
}
}
}