use of org.opennms.netmgt.mock.Outage in project opennms by OpenNMS.
the class MockDatabase method getOutages.
public Collection<Outage> getOutages(String criteria, Object... values) {
String critSql = (criteria == null ? "" : " and " + criteria);
final List<Outage> outages = new LinkedList<Outage>();
Querier loadExisting = new Querier(this, "select * from outages, ifServices, ipInterface, node, service where outages.ifServiceId = ifServices.id and ifServices.ipInterfaceId = ipInterface.id and ipInterface.nodeId = node.nodeId and ifServices.serviceId = service.serviceId" + critSql) {
@Override
public void processRow(ResultSet rs) throws SQLException {
Outage outage = new Outage(rs.getInt("nodeId"), rs.getString("ipAddr"), rs.getInt("serviceId"));
outage.setServiceName(rs.getString("serviceName"));
outage.setLostEvent(rs.getInt("svcLostEventID"), rs.getTimestamp("ifLostService"));
boolean open = (rs.getObject("ifRegainedService") == null);
if (!open) {
outage.setRegainedEvent(rs.getInt("svcRegainedEventID"), rs.getTimestamp("ifRegainedService"));
}
outages.add(outage);
}
};
loadExisting.execute(values);
return outages;
}
Aggregations