OpenNMS API 1.2.3

org.opennms.web.event
Class EventFactory

java.lang.Object
  extended byorg.opennms.web.event.EventFactory

public class EventFactory
extends java.lang.Object

Encapsulates all querying functionality for events.

Author:
Lawrence Karnowski , OpenNMS

Nested Class Summary
static class EventFactory.AcknowledgeType
          Convenience class to determine what sort of events to include in a query.
static class EventFactory.SortStyle
          Convenience class to determine sort style of a query.
 
Constructor Summary
private EventFactory()
          Private constructor so this class cannot be instantiated.
 
Method Summary
static void acknowledge(Event[] events, java.lang.String user)
          Acknowledge a list of events with the given username and the current time.
static void acknowledge(Event[] events, java.lang.String user, java.util.Date time)
          Acknowledge a list of events with the given username and the given time.
static void acknowledge(Filter[] filters, java.lang.String user)
          Acknowledge with the given username and the current time all events that match the given filter criteria.
static void acknowledge(Filter[] filters, java.lang.String user, java.util.Date time)
          Acknowledge with the given username and the given time all events that match the given filter criteria.
static void acknowledge(int[] eventIds, java.lang.String user)
          Acknowledge a list of events with the given username and the current time.
static void acknowledge(int[] eventIds, java.lang.String user, java.util.Date time)
          Acknowledge a list of events with the given username and the given time.
static void acknowledgeAll(java.lang.String user)
          Acknowledge all unacknowledged events with the given username and the given time.
static void acknowledgeAll(java.lang.String user, java.util.Date time)
          Acknowledge all unacknowledged events with the given username and the given time.
protected static java.lang.String getAcknowledgeTypeClause(EventFactory.AcknowledgeType ackType)
          Convenience method for getting the SQL ORDER BY clause related to a given sort style.
static Event getEvent(int eventId)
          Return a specific event.
static int getEventCount()
          Count all outstanding (unacknowledged) events.
static int getEventCount(EventFactory.AcknowledgeType ackType, Filter[] filters)
          Count the number of events for a given acknowledgement type.
static int[] getEventCountBySeverity(EventFactory.AcknowledgeType ackType, Filter[] filters)
          Count the number of events for a given acknowledgement type.
static int getEventCountForInterface(int nodeId, java.lang.String ipAddress, EventFactory.AcknowledgeType ackType)
          Return the number of events for this node ID, IP address, and the given acknowledgement type.
static int getEventCountForInterface(java.lang.String ipAddress, EventFactory.AcknowledgeType ackType)
          Return the number of events for this IP address and the given acknowledgement type.
static int getEventCountForNode(int nodeId, EventFactory.AcknowledgeType ackType)
          Return the number of events for this node and the given acknowledgement type.
static int getEventCountForService(int serviceId, EventFactory.AcknowledgeType ackType)
          Return the number of events for this node ID, IP address, service ID, and the given acknowledgement type.
static int getEventCountForService(int nodeId, java.lang.String ipAddress, int serviceId, EventFactory.AcknowledgeType ackType)
          Return the number of events for this node ID, IP address, service ID, and the given acknowledgement type.
static Event[] getEvents()
          Return all unacknowledged events sorted by time.
static Event[] getEvents(EventFactory.AcknowledgeType ackType)
          Return all unacknowledged or acknowledged events sorted by time.
static Event[] getEvents(EventFactory.SortStyle sortStyle)
          Return all unacknowledged events sorted by the given sort style.
static Event[] getEvents(EventFactory.SortStyle sortStyle, boolean includeAcknowledged)
          Deprecated. Replaced by " #getEvents(SortStyle,AcknowledgeType) getEvents(SortStyle, AcknowledgeType)"
static Event[] getEvents(EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType)
          Return all events (optionally only unacknowledged events) sorted by the given sort style.
static Event[] getEvents(EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType, Filter[] filters)
          Return all events (optionally only unacknowledged events) sorted by the given sort style.
static Event[] getEvents(EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType, Filter[] filters, int limit, int offset)
          Return all events (optionally only unacknowledged events) sorted by the given sort style.
static Event[] getEventsForInterface(int nodeId, java.lang.String ipAddress)
          Return all unacknowledged events sorted by event ID for the given interface.
static Event[] getEventsForInterface(int nodeId, java.lang.String ipAddress, boolean includeAcknowledged)
          Deprecated. Replaced by " #getEventsForInterface(int,String,SortStyle,AcknowledgeType) getEventsForInterface( int, String, SortStyle, AcknowledgeType )"
static Event[] getEventsForInterface(int nodeId, java.lang.String ipAddress, EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given node and IP address.
static Event[] getEventsForInterface(java.lang.String ipAddress)
          Return all unacknowledged events sorted by time for that have the given IP address, regardless of what node they belong to.
static Event[] getEventsForInterface(java.lang.String ipAddress, boolean includeAcknowledged)
          Deprecated. Replaced by " #getEventsForInterface(String,SortStyle,AcknowledgeType) getEventsForInterface( String, SortStyle, AcknowledgeType )"
static Event[] getEventsForInterface(java.lang.String ipAddress, EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given IP address.
static Event[] getEventsForNode(int nodeId)
          Return all unacknowledged events sorted by event ID for the given node.
static Event[] getEventsForNode(int nodeId, boolean includeAcknowledged)
          Deprecated. Replaced by " #getEventsForNode(int,SortStyle,AcknowledgeType) getEventsForNode( int, SortStyle, AcknowledgeType )"
static Event[] getEventsForNode(int nodeId, EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType)
          Return all events (optionally only unacknowledged events) sorted by the given sort style for the given node.
static Event[] getEventsForNode(int nodeId, EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given node.
static Event[] getEventsForPoller(java.lang.String poller)
          Return all unacknowledged events sorted by time for that have the given distributed poller.
static Event[] getEventsForPoller(java.lang.String poller, boolean includeAcknowledged)
          Return all events (optionally only unacknowledged events) sorted by time that have the given distributed poller.
static Event[] getEventsForService(int serviceId)
          Return all unacknowledged events sorted by time for the given service type, regardless of what node or interface they belong to.
static Event[] getEventsForService(int serviceId, boolean includeAcknowledged)
          Return all events (optionally only unacknowledged events) sorted by time for the given service type, regardless of what node or interface they belong to.
static Event[] getEventsForService(int serviceId, EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given service ID.
static Event[] getEventsForService(int nodeId, java.lang.String ipAddress, int serviceId)
          Return all unacknowledged events sorted by time for the given service.
static Event[] getEventsForService(int nodeId, java.lang.String ipAddress, int serviceId, boolean includeAcknowledged)
          Deprecated. Replaced by " #getEventsForService(int,String,int,SortStyle,AcknowledgeType,int,int) getEventsForService( int, String, int, SortStyle, AcknowledgeType, int, int )"
static Event[] getEventsForService(int nodeId, java.lang.String ipAddress, int serviceId, EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType, int throttle, int offset)
          Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given node, IP address, and service ID.
static Event[] getEventsForSeverity(int severity)
          Return all unacknowledged events sorted by time for the given severity.
static Event[] getEventsForSeverity(int severity, boolean includeAcknowledged)
          Deprecated. Replaced by " #getEventsForSeverity(int,SortStyle,AcknowledgeType) getEventsForSeverity( int, SortStyle, AcknowledgeType )"
static Event[] getEventsForSeverity(int severity, EventFactory.SortStyle sortStyle, EventFactory.AcknowledgeType ackType)
           
protected static java.lang.String getOrderByClause(EventFactory.SortStyle sortStyle)
          Convenience method for getting the SQL ORDER BY clause related to a given sort style.
protected static Event[] rs2Events(java.sql.ResultSet rs)
          Convenience method for translating a java.sql.ResultSet containing event information into an array of Event objects.
static void unacknowledge(Event[] events)
          Unacknowledge a list of events.
static void unacknowledge(Filter[] filters)
          Unacknowledge events that match the given filter criteria.
static void unacknowledge(int[] eventIds)
          Unacknowledge a list of events.
static void unacknowledgeAll()
          Unacknowledge all acknowledged events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventFactory

private EventFactory()
Private constructor so this class cannot be instantiated.

Method Detail

getEventCount

public static int getEventCount()
                         throws java.sql.SQLException
Count all outstanding (unacknowledged) events.

Throws:
java.sql.SQLException

getEventCount

public static int getEventCount(EventFactory.AcknowledgeType ackType,
                                Filter[] filters)
                         throws java.sql.SQLException
Count the number of events for a given acknowledgement type.

Throws:
java.sql.SQLException

getEventCountBySeverity

public static int[] getEventCountBySeverity(EventFactory.AcknowledgeType ackType,
                                            Filter[] filters)
                                     throws java.sql.SQLException
Count the number of events for a given acknowledgement type.

Returns:
An array of event counts. Each index of the array corresponds to the event severity for the counts (indeterminate is 1, critical is 7, etc).
Throws:
java.sql.SQLException

getEvent

public static Event getEvent(int eventId)
                      throws java.sql.SQLException
Return a specific event.

Throws:
java.sql.SQLException

getEvents

public static Event[] getEvents()
                         throws java.sql.SQLException
Return all unacknowledged events sorted by time.

Throws:
java.sql.SQLException

getEvents

public static Event[] getEvents(EventFactory.AcknowledgeType ackType)
                         throws java.sql.SQLException
Return all unacknowledged or acknowledged events sorted by time.

Throws:
java.sql.SQLException

getEvents

public static Event[] getEvents(EventFactory.SortStyle sortStyle)
                         throws java.sql.SQLException
Return all unacknowledged events sorted by the given sort style.

Throws:
java.sql.SQLException

getEvents

public static Event[] getEvents(EventFactory.SortStyle sortStyle,
                                boolean includeAcknowledged)
                         throws java.sql.SQLException
Deprecated. Replaced by " #getEvents(SortStyle,AcknowledgeType) getEvents(SortStyle, AcknowledgeType)"

Return all events (optionally only unacknowledged events) sorted by the given sort style.

Throws:
java.sql.SQLException

getEvents

public static Event[] getEvents(EventFactory.SortStyle sortStyle,
                                EventFactory.AcknowledgeType ackType)
                         throws java.sql.SQLException
Return all events (optionally only unacknowledged events) sorted by the given sort style.

Throws:
java.sql.SQLException

getEvents

public static Event[] getEvents(EventFactory.SortStyle sortStyle,
                                EventFactory.AcknowledgeType ackType,
                                Filter[] filters)
                         throws java.sql.SQLException
Return all events (optionally only unacknowledged events) sorted by the given sort style.

Throws:
java.sql.SQLException

getEvents

public static Event[] getEvents(EventFactory.SortStyle sortStyle,
                                EventFactory.AcknowledgeType ackType,
                                Filter[] filters,
                                int limit,
                                int offset)
                         throws java.sql.SQLException
Return all events (optionally only unacknowledged events) sorted by the given sort style.

Note: This limit/offset code is Postgres specific! Per Shane , this is okay for now until we can come up with an Oracle alternative too.

Parameters:
limit - if -1 or zero, no limit or offset is used
offset - if -1, no limit or offset if used
Throws:
java.sql.SQLException

getEventsForNode

public static Event[] getEventsForNode(int nodeId)
                                throws java.sql.SQLException
Return all unacknowledged events sorted by event ID for the given node.

Throws:
java.sql.SQLException

getEventsForNode

public static Event[] getEventsForNode(int nodeId,
                                       boolean includeAcknowledged)
                                throws java.sql.SQLException
Deprecated. Replaced by " #getEventsForNode(int,SortStyle,AcknowledgeType) getEventsForNode( int, SortStyle, AcknowledgeType )"

Return all events (optionally only unacknowledged events) sorted by event ID for the given node.

Throws:
java.sql.SQLException

getEventsForNode

public static Event[] getEventsForNode(int nodeId,
                                       EventFactory.SortStyle sortStyle,
                                       EventFactory.AcknowledgeType ackType)
                                throws java.sql.SQLException
Return all events (optionally only unacknowledged events) sorted by the given sort style for the given node.

Throws:
java.sql.SQLException

getEventsForNode

public static Event[] getEventsForNode(int nodeId,
                                       EventFactory.SortStyle sortStyle,
                                       EventFactory.AcknowledgeType ackType,
                                       int throttle,
                                       int offset)
                                throws java.sql.SQLException
Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given node.

Parameters:
throttle - a value less than one means no throttling
Throws:
java.sql.SQLException

getEventCountForNode

public static int getEventCountForNode(int nodeId,
                                       EventFactory.AcknowledgeType ackType)
                                throws java.sql.SQLException
Return the number of events for this node and the given acknowledgement type.

Throws:
java.sql.SQLException

getEventsForInterface

public static Event[] getEventsForInterface(int nodeId,
                                            java.lang.String ipAddress)
                                     throws java.sql.SQLException
Return all unacknowledged events sorted by event ID for the given interface.

Throws:
java.sql.SQLException

getEventsForInterface

public static Event[] getEventsForInterface(int nodeId,
                                            java.lang.String ipAddress,
                                            boolean includeAcknowledged)
                                     throws java.sql.SQLException
Deprecated. Replaced by " #getEventsForInterface(int,String,SortStyle,AcknowledgeType) getEventsForInterface( int, String, SortStyle, AcknowledgeType )"

Return all events (optionally only unacknowledged events) sorted by time for the given interface.

Throws:
java.sql.SQLException

getEventsForInterface

public static Event[] getEventsForInterface(int nodeId,
                                            java.lang.String ipAddress,
                                            EventFactory.SortStyle sortStyle,
                                            EventFactory.AcknowledgeType ackType,
                                            int throttle,
                                            int offset)
                                     throws java.sql.SQLException
Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given node and IP address.

Parameters:
throttle - a value less than one means no throttling
offset - which row to start on in the result list
Throws:
java.sql.SQLException

getEventsForInterface

public static Event[] getEventsForInterface(java.lang.String ipAddress)
                                     throws java.sql.SQLException
Return all unacknowledged events sorted by time for that have the given IP address, regardless of what node they belong to.

Throws:
java.sql.SQLException

getEventsForInterface

public static Event[] getEventsForInterface(java.lang.String ipAddress,
                                            boolean includeAcknowledged)
                                     throws java.sql.SQLException
Deprecated. Replaced by " #getEventsForInterface(String,SortStyle,AcknowledgeType) getEventsForInterface( String, SortStyle, AcknowledgeType )"

Return all events (optionally only unacknowledged events) sorted by time that have the given IP address, regardless of what node they belong to.

Throws:
java.sql.SQLException

getEventsForInterface

public static Event[] getEventsForInterface(java.lang.String ipAddress,
                                            EventFactory.SortStyle sortStyle,
                                            EventFactory.AcknowledgeType ackType,
                                            int throttle,
                                            int offset)
                                     throws java.sql.SQLException
Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given IP address.

Parameters:
throttle - a value less than one means no throttling
offset - which row to start on in the result list
Throws:
java.sql.SQLException

getEventCountForInterface

public static int getEventCountForInterface(int nodeId,
                                            java.lang.String ipAddress,
                                            EventFactory.AcknowledgeType ackType)
                                     throws java.sql.SQLException
Return the number of events for this node ID, IP address, and the given acknowledgement type.

Throws:
java.sql.SQLException

getEventCountForInterface

public static int getEventCountForInterface(java.lang.String ipAddress,
                                            EventFactory.AcknowledgeType ackType)
                                     throws java.sql.SQLException
Return the number of events for this IP address and the given acknowledgement type.

Throws:
java.sql.SQLException

getEventsForService

public static Event[] getEventsForService(int nodeId,
                                          java.lang.String ipAddress,
                                          int serviceId)
                                   throws java.sql.SQLException
Return all unacknowledged events sorted by time for the given service.

Throws:
java.sql.SQLException

getEventsForService

public static Event[] getEventsForService(int nodeId,
                                          java.lang.String ipAddress,
                                          int serviceId,
                                          boolean includeAcknowledged)
                                   throws java.sql.SQLException
Deprecated. Replaced by " #getEventsForService(int,String,int,SortStyle,AcknowledgeType,int,int) getEventsForService( int, String, int, SortStyle, AcknowledgeType, int, int )"

Return all events (optionally only unacknowledged events) sorted by time for the given service.

Throws:
java.sql.SQLException

getEventsForService

public static Event[] getEventsForService(int nodeId,
                                          java.lang.String ipAddress,
                                          int serviceId,
                                          EventFactory.SortStyle sortStyle,
                                          EventFactory.AcknowledgeType ackType,
                                          int throttle,
                                          int offset)
                                   throws java.sql.SQLException
Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given node, IP address, and service ID.

Parameters:
throttle - a value less than one means no throttling
offset - which row to start on in the result list
Throws:
java.sql.SQLException

getEventsForService

public static Event[] getEventsForService(int serviceId)
                                   throws java.sql.SQLException
Return all unacknowledged events sorted by time for the given service type, regardless of what node or interface they belong to.

Throws:
java.sql.SQLException

getEventsForService

public static Event[] getEventsForService(int serviceId,
                                          boolean includeAcknowledged)
                                   throws java.sql.SQLException
Return all events (optionally only unacknowledged events) sorted by time for the given service type, regardless of what node or interface they belong to.

Throws:
java.sql.SQLException

getEventsForService

public static Event[] getEventsForService(int serviceId,
                                          EventFactory.SortStyle sortStyle,
                                          EventFactory.AcknowledgeType ackType,
                                          int throttle,
                                          int offset)
                                   throws java.sql.SQLException
Return some maximum number of events or less (optionally only unacknowledged events) sorted by the given sort style for the given service ID.

Parameters:
throttle - a value less than one means no throttling
offset - which row to start on in the result list
Throws:
java.sql.SQLException

getEventCountForService

public static int getEventCountForService(int nodeId,
                                          java.lang.String ipAddress,
                                          int serviceId,
                                          EventFactory.AcknowledgeType ackType)
                                   throws java.sql.SQLException
Return the number of events for this node ID, IP address, service ID, and the given acknowledgement type.

Throws:
java.sql.SQLException

getEventCountForService

public static int getEventCountForService(int serviceId,
                                          EventFactory.AcknowledgeType ackType)
                                   throws java.sql.SQLException
Return the number of events for this node ID, IP address, service ID, and the given acknowledgement type.

Throws:
java.sql.SQLException

getEventsForSeverity

public static Event[] getEventsForSeverity(int severity)
                                    throws java.sql.SQLException
Return all unacknowledged events sorted by time for the given severity.

Throws:
java.sql.SQLException

getEventsForSeverity

public static Event[] getEventsForSeverity(int severity,
                                           boolean includeAcknowledged)
                                    throws java.sql.SQLException
Deprecated. Replaced by " #getEventsForSeverity(int,SortStyle,AcknowledgeType) getEventsForSeverity( int, SortStyle, AcknowledgeType )"

Return all events (optionally only unacknowledged events) sorted by time for the given severity.

Throws:
java.sql.SQLException

getEventsForSeverity

public static Event[] getEventsForSeverity(int severity,
                                           EventFactory.SortStyle sortStyle,
                                           EventFactory.AcknowledgeType ackType)
                                    throws java.sql.SQLException
Throws:
java.sql.SQLException

getEventsForPoller

public static Event[] getEventsForPoller(java.lang.String poller)
                                  throws java.sql.SQLException
Return all unacknowledged events sorted by time for that have the given distributed poller.

Throws:
java.sql.SQLException

getEventsForPoller

public static Event[] getEventsForPoller(java.lang.String poller,
                                         boolean includeAcknowledged)
                                  throws java.sql.SQLException
Return all events (optionally only unacknowledged events) sorted by time that have the given distributed poller.

Throws:
java.sql.SQLException

acknowledge

public static void acknowledge(Event[] events,
                               java.lang.String user)
                        throws java.sql.SQLException
Acknowledge a list of events with the given username and the current time.

Throws:
java.sql.SQLException

acknowledge

public static void acknowledge(Event[] events,
                               java.lang.String user,
                               java.util.Date time)
                        throws java.sql.SQLException
Acknowledge a list of events with the given username and the given time.

Throws:
java.sql.SQLException

acknowledge

public static void acknowledge(int[] eventIds,
                               java.lang.String user)
                        throws java.sql.SQLException
Acknowledge a list of events with the given username and the current time.

Throws:
java.sql.SQLException

acknowledge

public static void acknowledge(int[] eventIds,
                               java.lang.String user,
                               java.util.Date time)
                        throws java.sql.SQLException
Acknowledge a list of events with the given username and the given time.

Throws:
java.sql.SQLException

acknowledge

public static void acknowledge(Filter[] filters,
                               java.lang.String user)
                        throws java.sql.SQLException
Acknowledge with the given username and the current time all events that match the given filter criteria.

Throws:
java.sql.SQLException

acknowledge

public static void acknowledge(Filter[] filters,
                               java.lang.String user,
                               java.util.Date time)
                        throws java.sql.SQLException
Acknowledge with the given username and the given time all events that match the given filter criteria.

Throws:
java.sql.SQLException

acknowledgeAll

public static void acknowledgeAll(java.lang.String user)
                           throws java.sql.SQLException
Acknowledge all unacknowledged events with the given username and the given time.

Throws:
java.sql.SQLException

acknowledgeAll

public static void acknowledgeAll(java.lang.String user,
                                  java.util.Date time)
                           throws java.sql.SQLException
Acknowledge all unacknowledged events with the given username and the given time.

Throws:
java.sql.SQLException

unacknowledge

public static void unacknowledge(Event[] events)
                          throws java.sql.SQLException
Unacknowledge a list of events.

Throws:
java.sql.SQLException

unacknowledge

public static void unacknowledge(int[] eventIds)
                          throws java.sql.SQLException
Unacknowledge a list of events.

Throws:
java.sql.SQLException

unacknowledge

public static void unacknowledge(Filter[] filters)
                          throws java.sql.SQLException
Unacknowledge events that match the given filter criteria.

Throws:
java.sql.SQLException

unacknowledgeAll

public static void unacknowledgeAll()
                             throws java.sql.SQLException
Unacknowledge all acknowledged events.

Throws:
java.sql.SQLException

rs2Events

protected static Event[] rs2Events(java.sql.ResultSet rs)
                            throws java.sql.SQLException
Convenience method for translating a java.sql.ResultSet containing event information into an array of Event objects.

Throws:
java.sql.SQLException

getOrderByClause

protected static java.lang.String getOrderByClause(EventFactory.SortStyle sortStyle)
Convenience method for getting the SQL ORDER BY clause related to a given sort style.


getAcknowledgeTypeClause

protected static java.lang.String getAcknowledgeTypeClause(EventFactory.AcknowledgeType ackType)
Convenience method for getting the SQL ORDER BY clause related to a given sort style.

Parameters:
ackType - the acknowledge type to map to a clause

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.