use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmSearchProvider method findAlarms.
private List<OnmsAlarm> findAlarms(final List<SearchResult> results, final String queryString) {
CriteriaBuilder bldr = new CriteriaBuilder(OnmsAlarm.class);
OnmsSeverity severity = OnmsSeverity.get(queryString);
List<OnmsAlarm> alarms;
if (!OnmsSeverity.INDETERMINATE.equals(severity)) {
bldr = new CriteriaBuilder(OnmsAlarm.class);
bldr.eq("severity", severity);
alarms = alarmProvider.findMatchingAlarms(bldr.toCriteria());
if (alarms.size() > 0) {
AlarmSearchResult result = new AlarmSearchResult(queryString);
result.setSeverityQuery(true);
results.add(result);
}
} else {
bldr.isNotNull("node").ilike("uei", "%" + queryString + "%").orderBy("node");
alarms = alarmProvider.findMatchingAlarms(bldr.toCriteria());
}
return alarms;
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmSearchProvider method buildResults.
private Set<AlarmSearchResult> buildResults(final String queryString, List<OnmsAlarm> alarms) {
Set<AlarmSearchResult> queryResults = new HashSet<>();
LOG.debug("SearchProvider.query: creating alarm results set.");
for (OnmsAlarm alarm : alarms) {
String nodeLabel = alarm.getNodeLabel();
LOG.debug("SearchProvider.query: adding '{}' to set of results.", nodeLabel);
AlarmSearchResult result = new AlarmSearchResult(alarm.getId(), alarm.getNodeLabel(), queryString, !SearchResult.COLLAPSED);
queryResults.add(result);
}
return queryResults;
}
use of org.opennms.netmgt.model.OnmsAlarm 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.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class DroolsTicketerServiceLayerTest method setUp.
@Before
public void setUp() throws Exception {
m_eventIpcManager = new MockEventIpcManager();
EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
MockLogAppender.setupLogging();
ResourceLoader loader = new DefaultResourceLoader();
Resource resource = loader.getResource("classpath:/drools-ticketer-rules.drl");
m_easyMockUtils = new EasyMockUtils();
m_configDao = m_easyMockUtils.createMock(DroolsTicketerConfigDao.class);
EasyMock.expect(m_configDao.getRulesFile()).andReturn(resource.getFile()).times(1);
EasyMock.replay(m_configDao);
m_alarmDao = m_easyMockUtils.createMock(AlarmDao.class);
m_ticketerPlugin = m_easyMockUtils.createMock(Plugin.class);
m_droolsTicketerServiceLayer = new DroolsTicketerServiceLayer(m_configDao);
m_droolsTicketerServiceLayer.setAlarmDao(m_alarmDao);
m_droolsTicketerServiceLayer.setTicketerPlugin(m_ticketerPlugin);
EasyMock.reset(m_configDao);
m_alarm = new OnmsAlarm();
m_alarm.setId(1);
m_alarm.setLogMsg("Test Logmsg");
m_alarm.setDescription("Test Description");
m_alarm.setUei("uei.opennms.org/nodes/nodeDown");
m_ticket = new Ticket();
m_ticket.setId("4");
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class DefaultTicketerServiceLayerIT method testWire.
@Test
public void testWire() {
assertNotNull(m_ticketerServiceLayer);
assertNotNull(m_ticketerPlugin);
OnmsAlarm alarm = m_alarmDao.findAll().get(0);
assertNull(alarm.getTTicketState());
assertNull(alarm.getTTicketId());
final int alarmId = alarm.getId();
m_ticketerServiceLayer.createTicketForAlarm(alarmId, new HashMap<String, String>());
m_alarmDao.flush();
alarm = m_alarmDao.get(alarmId);
assertEquals(TroubleTicketState.OPEN, alarm.getTTicketState());
assertNotNull(alarm.getTTicketId());
assertEquals("testId", alarm.getTTicketId());
m_ticketerServiceLayer.updateTicketForAlarm(alarm.getId(), alarm.getTTicketId());
m_alarmDao.flush();
alarm = m_alarmDao.get(alarmId);
assertEquals(TroubleTicketState.OPEN, alarm.getTTicketState());
alarm.setSeverity(OnmsSeverity.CLEARED);
m_alarmDao.update(alarm);
m_ticketerServiceLayer.closeTicketForAlarm(alarmId, alarm.getTTicketId());
m_alarmDao.flush();
alarm = m_alarmDao.get(alarmId);
assertEquals(TroubleTicketState.CLOSED, alarm.getTTicketState());
}
Aggregations