use of org.opennms.web.alarm.filter.AlarmCriteria in project opennms by OpenNMS.
the class AlarmFilterController method createListModelAndView.
private ModelAndView createListModelAndView(HttpServletRequest request, List<Filter> filterList, AcknowledgeType ackType) {
final AlarmQueryParms parms = createAlarmQueryParms(request, filterList, ackType);
AlarmCriteria queryCriteria = new AlarmCriteria(parms);
AlarmCriteria countCriteria = new AlarmCriteria(filterList, ackType);
final OnmsAlarm[] alarms = m_webAlarmRepository.getMatchingAlarms(AlarmUtil.getOnmsCriteria(queryCriteria));
final long alarmCount = m_webAlarmRepository.countMatchingAlarms(AlarmUtil.getOnmsCriteria(countCriteria));
final ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("alarms", alarms);
modelAndView.addObject("alarmCount", alarmCount);
modelAndView.addObject("parms", new NormalizedQueryParameters(parms));
modelAndView.addObject("callback", getFilterCallback());
modelAndView.addObject("favorites", favoriteService.getFavorites(request.getRemoteUser(), OnmsFilterFavorite.Page.ALARM).toArray());
return modelAndView;
}
use of org.opennms.web.alarm.filter.AlarmCriteria in project opennms by OpenNMS.
the class AlarmRepositoryIT method testEscalateAlarms.
@Test
@JUnitTemporaryDatabase
public void testEscalateAlarms() {
int[] alarmIds = { 1 };
m_alarmRepo.escalateAlarms(alarmIds, "TestUser", new Date());
OnmsAlarm[] alarms = m_alarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1))));
assertNotNull(alarms);
assertEquals(OnmsSeverity.WARNING.getId(), alarms[0].getSeverity().getId());
}
use of org.opennms.web.alarm.filter.AlarmCriteria in project opennms by OpenNMS.
the class AlarmRepositoryIT method testCountMatchingBySeverity.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testCountMatchingBySeverity() {
int[] matchingAlarmCount = m_alarmRepo.countMatchingAlarmsBySeverity(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new SeverityFilter(OnmsSeverity.NORMAL))));
assertEquals(8, matchingAlarmCount.length);
}
use of org.opennms.web.alarm.filter.AlarmCriteria in project opennms by OpenNMS.
the class AlarmRepositoryIT method testAcknowledgeUnacknowledge.
@Test
@JUnitTemporaryDatabase
public void testAcknowledgeUnacknowledge() {
String user = "TestUser";
m_alarmRepo.acknowledgeMatchingAlarms(user, new Date(), AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1))));
int matchingAlarmCount = m_alarmRepo.countMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AcknowledgedByFilter(user))));
assertEquals(1, matchingAlarmCount);
m_alarmRepo.unacknowledgeMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1))), user);
matchingAlarmCount = m_alarmRepo.countMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AcknowledgedByFilter(user))));
assertEquals(0, matchingAlarmCount);
}
use of org.opennms.web.alarm.filter.AlarmCriteria in project opennms by OpenNMS.
the class AlarmRepositoryIT method testSortAndSearchBySameProperty.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testSortAndSearchBySameProperty() {
Filter[] filters = new Filter[] { new NodeNameLikeFilter("node") };
AlarmCriteria sorted = new AlarmCriteria(filters, SortStyle.NODE, AcknowledgeType.UNACKNOWLEDGED, 100, 0);
OnmsAlarm[] alarms = m_alarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(sorted));
assertTrue("Failed to sort with style " + SortStyle.NODE, alarms.length > 0);
}
Aggregations