Search in sources :

Example 1 with SingleResultQuerier

use of org.opennms.core.utils.SingleResultQuerier in project opennms by OpenNMS.

the class MockDatabase method getServiceID.

public Integer getServiceID(String serviceName) {
    if (serviceName == null)
        return null;
    SingleResultQuerier querier = new SingleResultQuerier(this, "select serviceId from service where serviceName = ?");
    querier.execute(serviceName);
    return (Integer) querier.getResult();
}
Also used : SingleResultQuerier(org.opennms.core.utils.SingleResultQuerier)

Example 2 with SingleResultQuerier

use of org.opennms.core.utils.SingleResultQuerier in project opennms by OpenNMS.

the class MockDatabase method getAlarmCount.

public Integer getAlarmCount(String reductionKey) {
    SingleResultQuerier querier = new SingleResultQuerier(this, "select counter from alarms where reductionKey = ?");
    querier.execute(reductionKey);
    return (Integer) querier.getResult();
}
Also used : SingleResultQuerier(org.opennms.core.utils.SingleResultQuerier)

Example 3 with SingleResultQuerier

use of org.opennms.core.utils.SingleResultQuerier in project opennms by OpenNMS.

the class NotificationManager method getEvent.

/**
 * In the absence of DAOs and ORMs this creates an Event object from the persisted
 * record.
 *
 * @param eventid a int.
 * @return a populated Event object
 */
public Event getEvent(final int eventid) {
    // don't switch using event builder since this event is read from the database
    final Event event = new Event();
    Querier querier = new Querier(m_dataSource, "select * from events where eventid = ?", new RowProcessor() {

        @Override
        public void processRow(ResultSet rs) throws SQLException {
            event.setDbid(rs.getInt("eventid"));
            event.setUei(rs.getString("eventuei"));
            event.setNodeid(rs.getLong("nodeid"));
            event.setTime(rs.getDate("eventtime"));
            event.setHost(rs.getString("eventhost"));
            event.setInterface(rs.getString("ipaddr"));
            event.setSnmphost(rs.getString("eventsnmphost"));
            event.setService(getServiceName(rs.getInt("serviceid")));
            event.setCreationTime(rs.getDate("eventcreatetime"));
            event.setSeverity(rs.getString("eventseverity"));
            event.setPathoutage(rs.getString("eventpathoutage"));
            Tticket tticket = new Tticket();
            tticket.setContent(rs.getString("eventtticket"));
            tticket.setState(rs.getString("eventtticketstate"));
            event.setTticket(tticket);
            event.setSource(rs.getString("eventsource"));
        }

        private String getServiceName(int serviceid) {
            SingleResultQuerier querier = new SingleResultQuerier(m_dataSource, "select servicename from service where serviceid = ?");
            return (String) querier.getResult();
        }
    });
    querier.execute(eventid);
    return event;
}
Also used : Querier(org.opennms.core.utils.Querier) SingleResultQuerier(org.opennms.core.utils.SingleResultQuerier) Tticket(org.opennms.netmgt.xml.event.Tticket) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) Event(org.opennms.netmgt.xml.event.Event) SingleResultQuerier(org.opennms.core.utils.SingleResultQuerier) RowProcessor(org.opennms.core.utils.RowProcessor)

Example 4 with SingleResultQuerier

use of org.opennms.core.utils.SingleResultQuerier in project opennms by OpenNMS.

the class MockDatabase method getServiceStatus.

public char getServiceStatus(MockService svc) {
    SingleResultQuerier querier = new SingleResultQuerier(this, "select ifServices.status as status from ifServices, ipInterface, node where ifServices.ipInterfaceId = ipInterface.id and ipInterface.ipAddr = ? and ipInterface.nodeId = node.nodeId and node.nodeId = ? and serviceID = ?");
    querier.execute(svc.getIpAddr(), Integer.valueOf(svc.getNodeId()), Integer.valueOf(svc.getSvcId()));
    String result = (String) querier.getResult();
    if (result == null || "".equals(result)) {
        return 'X';
    }
    return result.charAt(0);
}
Also used : SingleResultQuerier(org.opennms.core.utils.SingleResultQuerier)

Example 5 with SingleResultQuerier

use of org.opennms.core.utils.SingleResultQuerier in project opennms by OpenNMS.

the class MockDatabase method getAlarmId.

public Integer getAlarmId(String reductionKey) {
    SingleResultQuerier querier = new SingleResultQuerier(this, "select alarmid from alarms where reductionKey = ?");
    querier.execute(reductionKey);
    return (Integer) querier.getResult();
}
Also used : SingleResultQuerier(org.opennms.core.utils.SingleResultQuerier)

Aggregations

SingleResultQuerier (org.opennms.core.utils.SingleResultQuerier)8 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Querier (org.opennms.core.utils.Querier)1 RowProcessor (org.opennms.core.utils.RowProcessor)1 Event (org.opennms.netmgt.xml.event.Event)1 Tticket (org.opennms.netmgt.xml.event.Tticket)1