use of org.opennms.netmgt.model.OnmsEvent in project opennms by OpenNMS.
the class DaoWebOutageRepository method mapOnmsOutageToOutage.
private Outage mapOnmsOutageToOutage(OnmsOutage onmsOutage) {
if (onmsOutage != null) {
Outage outage = new Outage();
final String outageAddress = str(onmsOutage.getIpAddress());
outage.outageId = onmsOutage.getId();
outage.ipAddress = outageAddress;
outage.hostname = outageAddress;
outage.lostServiceTime = onmsOutage.getIfLostService();
outage.regainedServiceTime = onmsOutage.getIfRegainedService();
outage.serviceId = onmsOutage.getServiceId();
outage.serviceName = onmsOutage.getMonitoredService() != null ? onmsOutage.getMonitoredService().getServiceName() : "";
outage.suppressedBy = onmsOutage.getSuppressedBy();
outage.suppressTime = onmsOutage.getSuppressTime();
// Node-related fields
outage.nodeId = onmsOutage.getNodeId();
outage.location = "";
final OnmsNode node = onmsOutage.getNode();
if (node != null) {
outage.nodeLabel = node.getLabel();
if (node.getLocation() != null) {
outage.location = node.getLocation().getLocationName();
}
}
// Event-related fields
final OnmsEvent event = onmsOutage.getServiceLostEvent();
outage.lostServiceEventId = 0;
outage.regainedServiceEventId = 0;
if (event != null) {
outage.lostServiceEventId = onmsOutage.getServiceLostEvent().getId();
if (event.getDistPoller() != null) {
outage.eventLocation = event.getDistPoller().getLocation();
}
}
if (onmsOutage.getServiceRegainedEvent() != null) {
outage.regainedServiceEventId = onmsOutage.getServiceRegainedEvent().getId();
}
return outage;
} else {
return null;
}
}
use of org.opennms.netmgt.model.OnmsEvent in project opennms by OpenNMS.
the class TestUtils method createEvent.
public static OnmsEvent createEvent(OnmsNode node, OnmsSeverity severity, OnmsDistPoller distPoller) {
OnmsEvent event = new OnmsEvent();
event.setEventUei(EventConstants.NODE_DOWN_EVENT_UEI);
event.setEventTime(new Date());
event.setEventCreateTime(new Date());
event.setEventSource(OutageStatusCalculatorIT.class.getName());
event.setDistPoller(distPoller);
event.setEventSeverity(severity.getId());
event.setEventLog("Y");
event.setEventDisplay("Y");
event.setEventLogMsg("Dummy Log Message");
event.setNode(node);
return event;
}
use of org.opennms.netmgt.model.OnmsEvent in project opennms by OpenNMS.
the class DaoWebOutageRepositoryIT method setUp.
@Before
public void setUp() {
m_dbPopulator.populateDatabase();
OnmsMonitoredService svc2 = m_dbPopulator.getMonitoredServiceDao().get(2, InetAddressUtils.addr("192.168.2.1"), "ICMP");
OnmsEvent event = m_dbPopulator.getEventDao().get(1);
OnmsOutage unresolved2 = new OnmsOutage(new Date(), event, svc2);
m_dbPopulator.getOutageDao().save(unresolved2);
m_dbPopulator.getOutageDao().flush();
}
use of org.opennms.netmgt.model.OnmsEvent in project opennms by OpenNMS.
the class WebOutageRepositoryFilterIT method testRegainedServiceDateAfterFilter.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
public void testRegainedServiceDateAfterFilter() {
OnmsMonitoredService svc2 = m_dbPopulator.getMonitoredServiceDao().get(m_dbPopulator.getNode2().getId(), InetAddressUtils.addr("192.168.2.1"), "ICMP");
// This requires every test method to have a new database instance :/
OnmsEvent event = m_dbPopulator.getEventDao().get(1);
// Put a resolved outage into the database so that one will match the
// filter below
OnmsOutage resolvedToday = new OnmsOutage(new Date(), new Date(), event, event, svc2, null, null);
m_dbPopulator.getOutageDao().save(resolvedToday);
m_dbPopulator.getOutageDao().flush();
RegainedServiceDateAfterFilter filter = new RegainedServiceDateAfterFilter(yesterday());
OutageCriteria criteria = new OutageCriteria(filter);
Outage[] outages = m_daoOutageRepo.getMatchingOutages(criteria);
assertEquals(1, outages.length);
}
use of org.opennms.netmgt.model.OnmsEvent in project opennms by OpenNMS.
the class WebOutageRepositoryFilterIT method setUp.
@Before
public void setUp() {
m_dbPopulator.populateDatabase();
OnmsMonitoredService svc2 = m_dbPopulator.getMonitoredServiceDao().get(m_dbPopulator.getNode2().getId(), InetAddressUtils.addr("192.168.2.1"), "ICMP");
// This requires every test method to have a new database instance :/
OnmsEvent event = m_dbPopulator.getEventDao().get(1);
OnmsOutage unresolved2 = new OnmsOutage(new Date(), event, svc2);
m_dbPopulator.getOutageDao().save(unresolved2);
m_dbPopulator.getOutageDao().flush();
}
Aggregations