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();
}
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();
}
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;
}
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);
}
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();
}
Aggregations