Search in sources :

Example 1 with AlarmCriteria

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;
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) AlarmQueryParms(org.opennms.web.alarm.AlarmQueryParms) ModelAndView(org.springframework.web.servlet.ModelAndView) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) NormalizedQueryParameters(org.opennms.web.filter.NormalizedQueryParameters)

Example 2 with AlarmCriteria

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());
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) AlarmIdFilter(org.opennms.web.alarm.filter.AlarmIdFilter) Date(java.util.Date) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 3 with AlarmCriteria

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);
}
Also used : SeverityFilter(org.opennms.web.alarm.filter.SeverityFilter) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with AlarmCriteria

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);
}
Also used : AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) AcknowledgedByFilter(org.opennms.web.alarm.filter.AcknowledgedByFilter) AlarmIdFilter(org.opennms.web.alarm.filter.AlarmIdFilter) Date(java.util.Date) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 5 with AlarmCriteria

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);
}
Also used : NodeNameLikeFilter(org.opennms.web.alarm.filter.NodeNameLikeFilter) SeverityFilter(org.opennms.web.alarm.filter.SeverityFilter) Filter(org.opennms.web.filter.Filter) AlarmIdFilter(org.opennms.web.alarm.filter.AlarmIdFilter) NodeNameLikeFilter(org.opennms.web.alarm.filter.NodeNameLikeFilter) AcknowledgedByFilter(org.opennms.web.alarm.filter.AcknowledgedByFilter) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)14 Test (org.junit.Test)10 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)10 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)8 AlarmIdFilter (org.opennms.web.alarm.filter.AlarmIdFilter)6 Date (java.util.Date)5 SeverityFilter (org.opennms.web.alarm.filter.SeverityFilter)5 Filter (org.opennms.web.filter.Filter)5 Transactional (org.springframework.transaction.annotation.Transactional)5 AcknowledgedByFilter (org.opennms.web.alarm.filter.AcknowledgedByFilter)4 ArrayList (java.util.ArrayList)3 OnmsCriteria (org.opennms.netmgt.model.OnmsCriteria)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 AlarmQueryParms (org.opennms.web.alarm.AlarmQueryParms)2 NodeNameLikeFilter (org.opennms.web.alarm.filter.NodeNameLikeFilter)2 SyndContent (com.rometools.rome.feed.synd.SyndContent)1 SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)1 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)1 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)1 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)1