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

Since:
1.8.1
Version:
$Id: $
Author:
Lawrence Karnowski , OpenNMS , 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, javax.servlet.ServletContext servletContext)
          Return a specific notice.
static int getNoticeCount(AcknowledgeType ackType, Filter[] filters)
          Count the number of notices for a given acknowledgement type.
static Notification[] getNotices(AcknowledgeType ackType, javax.servlet.ServletContext servletContext)
          Return all unacknowledged or acknowledged notices sorted by id.
static Notification[] getNotices(javax.servlet.ServletContext servletContext)
          Return all unacknowledged notices sorted by id.
static Notification[] getNotices(SortStyle sortStyle, AcknowledgeType ackType, Filter[] filters, int limit, int offset, javax.servlet.ServletContext servletContext)
          Return all notices (optionally only unacknowledged notices) sorted by the given sort style.
static Notification[] getNotices(SortStyle sortStyle, AcknowledgeType ackType, Filter[] filters, javax.servlet.ServletContext servletContext)
          Return all notices (optionally only unacknowledged notices) sorted by the given sort style.
static Notification[] getNotices(SortStyle sortStyle, AcknowledgeType ackType, javax.servlet.ServletContext servletContext)
          Return all notices (optionally only unacknowledged notices) sorted by the given sort style.
static Notification[] getNotices(SortStyle sortStyle, boolean includeAcknowledged, javax.servlet.ServletContext servletContext)
          Deprecated. Replaced by " #getNotices(SortStyle,AcknowledgeType) getNotices( SortStyle, AcknowledgeType )"
static Notification[] getNotices(SortStyle sortStyle, javax.servlet.ServletContext servletContext)
          Return all unacknowledged notices sorted by the given sort style.
static Notification[] getNoticesForInterface(int nodeId, String ipAddress, boolean includeAcknowledged, javax.servlet.ServletContext servletContext)
          Return all notices (optionally only unacknowledged notices) sorted by id for the given interface.
static Notification[] getNoticesForInterface(int nodeId, String ipAddress, javax.servlet.ServletContext servletContext)
          Return all unacknowledged notices for the given interface.
static Notification[] getNoticesForInterface(String ipAddress, boolean includeAcknowledged, javax.servlet.ServletContext servletContext)
          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[] getNoticesForInterface(String ipAddress, javax.servlet.ServletContext servletContext)
          Return all unacknowledged notices sorted by time for that have the given IP address, regardless of what node they belong to.
static Notification[] getNoticesForNode(int nodeId, boolean includeAcknowledged, javax.servlet.ServletContext servletContext)
          Deprecated. Replaced by " #getNoticesForNode(int,SortStyle,AcknowledgeType) getNoticesForNode( int, SortStyle, AcknowledgeType )"
static Notification[] getNoticesForNode(int nodeId, javax.servlet.ServletContext servletContext)
          Return all unacknowledged notices sorted by time for the given node.
static Notification[] getNoticesForNode(int nodeId, SortStyle sortStyle, AcknowledgeType ackType, javax.servlet.ServletContext servletContext)
          Return all notices (optionally only unacknowledged notices) sorted by given sort style for the given node.
static Notification[] getNoticesForService(int serviceId, boolean includeAcknowledged, javax.servlet.ServletContext servletContext)
          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 serviceId, javax.servlet.ServletContext servletContext)
          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 nodeId, String ipAddress, int serviceId, boolean includeAcknowledged, javax.servlet.ServletContext servletContext)
          Return all notices (optionally only unacknowledged notices) sorted by time for the given service.
static Notification[] getNoticesForService(int nodeId, String ipAddress, int serviceId, javax.servlet.ServletContext servletContext)
          Return all unacknowledged notices sorted by time for the given service.
protected static Notification[] rs2Notices(ResultSet rs, javax.servlet.ServletContext servletContext)
          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.

Parameters:
ackType - a AcknowledgeType object.
filters - an array of org$opennms$web$filter$Filter objects.
Returns:
a int.
Throws:
SQLException - if any.

getNotice

public static Notification getNotice(int noticeId,
                                     javax.servlet.ServletContext servletContext)
                              throws SQLException
Return a specific notice.

Parameters:
noticeId - a int.
Returns:
a Notification object.
Throws:
SQLException - if any.

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(javax.servlet.ServletContext servletContext)
                                 throws SQLException
Return all unacknowledged notices sorted by id.

Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNotices

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

Parameters:
ackType - a AcknowledgeType object.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNotices

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

Parameters:
sortStyle - a SortStyle object.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNotices

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

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

Parameters:
sortStyle - a SortStyle object.
includeAcknowledged - a boolean.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNotices

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

Parameters:
sortStyle - a SortStyle object.
ackType - a AcknowledgeType object.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNotices

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

Parameters:
sortStyle - a SortStyle object.
ackType - a AcknowledgeType object.
filters - an array of org$opennms$web$filter$Filter objects.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNotices

public static Notification[] getNotices(SortStyle sortStyle,
                                        AcknowledgeType ackType,
                                        Filter[] filters,
                                        int limit,
                                        int offset,
                                        javax.servlet.ServletContext servletContext)
                                 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
sortStyle - a SortStyle object.
ackType - a AcknowledgeType object.
filters - an array of org$opennms$web$filter$Filter objects.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForNode

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

Parameters:
nodeId - a int.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForNode

public static Notification[] getNoticesForNode(int nodeId,
                                               boolean includeAcknowledged,
                                               javax.servlet.ServletContext servletContext)
                                        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.

Parameters:
nodeId - a int.
includeAcknowledged - a boolean.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForNode

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

Parameters:
nodeId - a int.
sortStyle - a SortStyle object.
ackType - a AcknowledgeType object.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForInterface

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

Parameters:
nodeId - a int.
ipAddress - a String object.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForInterface

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

Parameters:
nodeId - a int.
ipAddress - a String object.
includeAcknowledged - a boolean.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForInterface

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

Parameters:
ipAddress - a String object.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForInterface

public static Notification[] getNoticesForInterface(String ipAddress,
                                                    boolean includeAcknowledged,
                                                    javax.servlet.ServletContext servletContext)
                                             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.

Parameters:
ipAddress - a String object.
includeAcknowledged - a boolean.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForService

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

Parameters:
nodeId - a int.
ipAddress - a String object.
serviceId - a int.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForService

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

Parameters:
nodeId - a int.
ipAddress - a String object.
serviceId - a int.
includeAcknowledged - a boolean.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForService

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

Parameters:
serviceId - a int.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

getNoticesForService

public static Notification[] getNoticesForService(int serviceId,
                                                  boolean includeAcknowledged,
                                                  javax.servlet.ServletContext servletContext)
                                           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.

Parameters:
serviceId - a int.
includeAcknowledged - a boolean.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.

acknowledge

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

Parameters:
notices - an array of Notification objects.
user - a String object.
Throws:
SQLException - if any.

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.

Parameters:
notices - an array of Notification objects.
user - a String object.
time - a java$util$Date object.
Throws:
SQLException - if any.

acknowledge

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

Parameters:
noticeIds - an array of int.
user - a String object.
Throws:
SQLException - if any.

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.

Parameters:
noticeIds - an array of int.
user - a String object.
time - a java$util$Date object.
Throws:
SQLException - if any.

rs2Notices

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

Parameters:
rs - a ResultSet object.
Returns:
an array of Notification objects.
Throws:
SQLException - if any.


Copyright © 2011. All Rights Reserved.