Search in sources :

Example 1 with Outage

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;
}
Also used : Querier(org.opennms.core.utils.Querier) SingleResultQuerier(org.opennms.core.utils.SingleResultQuerier) MockPathOutage(org.opennms.netmgt.mock.MockPathOutage) Outage(org.opennms.netmgt.mock.Outage) ResultSet(java.sql.ResultSet) LinkedList(java.util.LinkedList)

Aggregations

ResultSet (java.sql.ResultSet)1 LinkedList (java.util.LinkedList)1 Querier (org.opennms.core.utils.Querier)1 SingleResultQuerier (org.opennms.core.utils.SingleResultQuerier)1 MockPathOutage (org.opennms.netmgt.mock.MockPathOutage)1 Outage (org.opennms.netmgt.mock.Outage)1