org.opennms.web.notification
Class NoticeFactory

java.lang.Object
  extended by org.opennms.web.notification.NoticeFactory

public class NoticeFactory
extends Object

Encapsulates all querying functionality for notices

Author:
Lawrence Karnowski , OpenNMS

Method Summary
static void acknowledge(int[] noticeIds, String user)
          Acknowledge a list of notices with the given username and the current time.
static void acknowledge(int[] noticeIds, String user, Date time)
          Acknowledge a list of notices with the given username and the given time.
static void acknowledge(Notification[] notices, String user)
          Acknowledge a list of notices with the given username
static void acknowledge(Notification[] notices, String user, Date time)
          Acknowledge a list of notices with the given username and the given time.
static boolean canDisplayEvent(int eventId)
          This method determines the log status of an event associated with a notification
static Notification getNotice(int noticeId)
          Return a specific notice.
static int getNoticeCount(AcknowledgeType ackType, Filter[] filters)
          Count the number of notices for a given acknowledgement type.
static Notification[] getNotices()
          Return all unacknowledged notices sorted by id.
static Notification[] getNotices(AcknowledgeType ackType)
          Return all unacknowledged or acknowledged notices sorted by id.
static Notification[] getNotices(SortStyle sortStyle)
          Return all unacknowledged notices sorted by the given sort style.
static Notification[] getNotices(SortStyle sortStyle, AcknowledgeType ackType)
          Return all notices (optionally only unacknowledged notices) sorted by the given sort style.
static Notification[] getNotices(SortStyle sortStyle, AcknowledgeType ackType, Filter[] filters)
          Return all notices (optionally only unacknowledged notices) sorted by the given sort style.
static Notification[] getNotices(SortStyle sortStyle, AcknowledgeType ackType, Filter[] filters, int limit, int offset)
          Return all notices (optionally only unacknowledged notices) sorted by the given sort style.
static Notification[] getNotices(SortStyle sortStyle, boolean includeAcknowledged)
          Deprecated. Replaced by " #getNotices(SortStyle,AcknowledgeType) getNotices( SortStyle, AcknowledgeType )"
static Notification[] getNoticesForInterface(int nodeId, String ipAddress)
          Return all unacknowledged notices for the given interface.
static Notification[] getNoticesForInterface(int nodeId, String ipAddress, boolean includeAcknowledged)
          Return all notices (optionally only unacknowledged notices) sorted by id for the given interface.
static Notification[] getNoticesForInterface(String ipAddress)
          Return all unacknowledged notices sorted by time for that have the given IP address, regardless of what node they belong to.
static Notification[] getNoticesForInterface(String ipAddress, boolean includeAcknowledged)
          Return all notices (optionally only unacknowledged notices) sorted by id that have the given IP address, regardless of what node they belong to.
static Notification[] getNoticesForNode(int nodeId)
          Return all unacknowledged notices sorted by time for the given node.
static Notification[] getNoticesForNode(int nodeId, boolean includeAcknowledged)
          Deprecated. Replaced by " #getNoticesForNode(int,SortStyle,AcknowledgeType) getNoticesForNode( int, SortStyle, AcknowledgeType )"
static Notification[] getNoticesForNode(int nodeId, SortStyle sortStyle, AcknowledgeType ackType)
          Return all notices (optionally only unacknowledged notices) sorted by given sort style for the given node.
static Notification[] getNoticesForService(int serviceId)
          Return all unacknowledged notices sorted by time for the given service type, regardless of what node or interface they belong to.
static Notification[] getNoticesForService(int serviceId, boolean includeAcknowledged)
          Return all notices (optionally only unacknowledged notices) sorted by id for the given service type, regardless of what node or interface they belong to.
static Notification[] getNoticesForService(int nodeId, String ipAddress, int serviceId)
          Return all unacknowledged notices sorted by time for the given service.
static Notification[] getNoticesForService(int nodeId, String ipAddress, int serviceId, boolean includeAcknowledged)
          Return all notices (optionally only unacknowledged notices) sorted by time for the given service.
protected static Notification[] rs2Notices(ResultSet rs)
          Convenience method for translating a java.sql.ResultSet containing notice information into an array of Notification objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNoticeCount

public static int getNoticeCount(AcknowledgeType ackType,
                                 Filter[] filters)
                          throws SQLException
Count the number of notices for a given acknowledgement type.

Throws:
SQLException

getNotice

public static Notification getNotice(int noticeId)
                              throws SQLException
Return a specific notice.

Throws:
SQLException

canDisplayEvent

public static boolean canDisplayEvent(int eventId)
This method determines the log status of an event associated with a notification

Parameters:
eventId - the unique id of the event from the notice
Returns:
true if the event is display, false if log only

getNotices

public static Notification[] getNotices()
                                 throws SQLException
Return all unacknowledged notices sorted by id.

Throws:
SQLException

getNotices

public static Notification[] getNotices(AcknowledgeType ackType)
                                 throws SQLException
Return all unacknowledged or acknowledged notices sorted by id.

Throws:
SQLException

getNotices

public static Notification[] getNotices(SortStyle sortStyle)
                                 throws SQLException
Return all unacknowledged notices sorted by the given sort style.

Throws:
SQLException

getNotices

public static Notification[] getNotices(SortStyle sortStyle,
                                        boolean includeAcknowledged)
                                 throws SQLException
Deprecated. Replaced by " #getNotices(SortStyle,AcknowledgeType) getNotices( SortStyle, AcknowledgeType )"

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

Throws:
SQLException

getNotices

public static Notification[] getNotices(SortStyle sortStyle,
                                        AcknowledgeType ackType)
                                 throws SQLException
Return all notices (optionally only unacknowledged notices) sorted by the given sort style.

Throws:
SQLException

getNotices

public static Notification[] getNotices(SortStyle sortStyle,
                                        AcknowledgeType ackType,
                                        Filter[] filters)
                                 throws SQLException
Return all notices (optionally only unacknowledged notices) sorted by the given sort style.

Throws:
SQLException

getNotices

public static Notification[] getNotices(SortStyle sortStyle,
                                        AcknowledgeType ackType,
                                        Filter[] filters,
                                        int limit,
                                        int offset)
                                 throws SQLException
Return all notices (optionally only unacknowledged notices) 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:
SQLException

getNoticesForNode

public static Notification[] getNoticesForNode(int nodeId)
                                        throws SQLException
Return all unacknowledged notices sorted by time for the given node.

Throws:
SQLException

getNoticesForNode

public static Notification[] getNoticesForNode(int nodeId,
                                               boolean includeAcknowledged)
                                        throws SQLException
Deprecated. Replaced by " #getNoticesForNode(int,SortStyle,AcknowledgeType) getNoticesForNode( int, SortStyle, AcknowledgeType )"

Return all notices (optionally only unacknowledged notices) sorted by id for the given node.

Throws:
SQLException

getNoticesForNode

public static Notification[] getNoticesForNode(int nodeId,
                                               SortStyle sortStyle,
                                               AcknowledgeType ackType)
                                        throws SQLException
Return all notices (optionally only unacknowledged notices) sorted by given sort style for the given node.

Throws:
SQLException

getNoticesForInterface

public static Notification[] getNoticesForInterface(int nodeId,
                                                    String ipAddress)
                                             throws SQLException
Return all unacknowledged notices for the given interface.

Throws:
SQLException

getNoticesForInterface

public static Notification[] getNoticesForInterface(int nodeId,
                                                    String ipAddress,
                                                    boolean includeAcknowledged)
                                             throws SQLException
Return all notices (optionally only unacknowledged notices) sorted by id for the given interface.

Throws:
SQLException

getNoticesForInterface

public static Notification[] getNoticesForInterface(String ipAddress)
                                             throws SQLException
Return all unacknowledged notices sorted by time for that have the given IP address, regardless of what node they belong to.

Throws:
SQLException

getNoticesForInterface

public static Notification[] getNoticesForInterface(String ipAddress,
                                                    boolean includeAcknowledged)
                                             throws SQLException
Return all notices (optionally only unacknowledged notices) sorted by id that have the given IP address, regardless of what node they belong to.

Throws:
SQLException

getNoticesForService

public static Notification[] getNoticesForService(int nodeId,
                                                  String ipAddress,
                                                  int serviceId)
                                           throws SQLException
Return all unacknowledged notices sorted by time for the given service.

Throws:
SQLException

getNoticesForService

public static Notification[] getNoticesForService(int nodeId,
                                                  String ipAddress,
                                                  int serviceId,
                                                  boolean includeAcknowledged)
                                           throws SQLException
Return all notices (optionally only unacknowledged notices) sorted by time for the given service.

Throws:
SQLException

getNoticesForService

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

Throws:
SQLException

getNoticesForService

public static Notification[] getNoticesForService(int serviceId,
                                                  boolean includeAcknowledged)
                                           throws SQLException
Return all notices (optionally only unacknowledged notices) sorted by id for the given service type, regardless of what node or interface they belong to.

Throws:
SQLException

acknowledge

public static void acknowledge(Notification[] notices,
                               String user)
                        throws SQLException
Acknowledge a list of notices with the given username

Throws:
SQLException

acknowledge

public static void acknowledge(Notification[] notices,
                               String user,
                               Date time)
                        throws SQLException
Acknowledge a list of notices with the given username and the given time.

Throws:
SQLException

acknowledge

public static void acknowledge(int[] noticeIds,
                               String user)
                        throws SQLException
Acknowledge a list of notices with the given username and the current time.

Throws:
SQLException

acknowledge

public static void acknowledge(int[] noticeIds,
                               String user,
                               Date time)
                        throws SQLException
Acknowledge a list of notices with the given username and the given time.

Throws:
SQLException

rs2Notices

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

Throws:
SQLException


Copyright © 2009. All Rights Reserved.