use of org.opennms.web.notification.filter.NotificationCriteria in project opennms by OpenNMS.
the class WebNotificationRepositoryFilterIT method testResponderFilter.
@Test
@Transactional
public void testResponderFilter() {
m_daoNotificationRepo.acknowledgeMatchingNotification("TestUser", new Date(), new NotificationCriteria());
ResponderFilter filter = new ResponderFilter("TestUser");
assert1Result(filter);
}
use of org.opennms.web.notification.filter.NotificationCriteria in project opennms by OpenNMS.
the class WebNotificationRepositoryFilterIT method assert1Result.
private void assert1Result(Filter filter) {
System.out.println(filter.getSql());
NotificationCriteria criteria = new NotificationCriteria(filter);
Notification[] notifs = m_daoNotificationRepo.getMatchingNotifications(criteria);
assertEquals(1, notifs.length);
}
use of org.opennms.web.notification.filter.NotificationCriteria in project opennms by OpenNMS.
the class WebNotificationRepositoryFilterIT method testAcknowledgeByFilter.
@Test
@Transactional
public void testAcknowledgeByFilter() {
m_daoNotificationRepo.acknowledgeMatchingNotification("TestUser", new Date(), new NotificationCriteria());
AcknowledgedByFilter filter = new AcknowledgedByFilter("TestUser");
assert1Result(filter);
}
use of org.opennms.web.notification.filter.NotificationCriteria in project opennms by OpenNMS.
the class AcknowledgeNotificationController method handleRequestInternal.
/**
* {@inheritDoc}
*
* Acknowledge the notifications specified in the POST and then redirect the client
* to an appropriate URL for display.
*/
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
String[] required = { "notices" };
String[] noticeIdStrings = request.getParameterValues("notices");
if (noticeIdStrings == null) {
throw new MissingParameterException("notices", required);
}
String currentUser = request.getParameter("curUser");
if (currentUser == null) {
currentUser = request.getRemoteUser();
}
List<Integer> noticeIds = new ArrayList<>();
for (String noticeIdString : noticeIdStrings) {
noticeIds.add(WebSecurityUtils.safeParseInt(noticeIdString));
}
List<Filter> filters = new ArrayList<>();
filters.add(new NotificationIdListFilter(noticeIds.toArray(new Integer[0])));
NotificationCriteria criteria = new NotificationCriteria(filters.toArray(new Filter[0]));
m_webNotificationRepository.acknowledgeMatchingNotification(currentUser, new Date(), criteria);
Notification[] notices = m_webNotificationRepository.getMatchingNotifications(criteria);
request.setAttribute("notices", notices);
String redirectParms = request.getParameter("redirectParms");
String redirect = request.getParameter("redirect");
String viewName;
if (redirect != null) {
viewName = redirect;
} else {
viewName = (redirectParms == null || redirectParms == "" || redirectParms == "null" ? m_redirectView : m_redirectView + "?" + redirectParms);
}
RedirectView view = new RedirectView(viewName, true);
return new ModelAndView(view);
}
Aggregations