Commits

Anonymous committed 2ffe729

Refactoring UI alarm code to eliminate the JDBC code and unnecessary
facades on the OnmsAlarm object.

Comments (0)

Files changed (8)

opennms-webapp/src/main/java/org/opennms/web/alarm/Alarm.java

 import java.util.Date;
 
 import org.apache.commons.lang.builder.ToStringBuilder;
+import org.opennms.core.utils.InetAddressUtils;
+import org.opennms.netmgt.model.OnmsAlarm;
+import org.opennms.netmgt.model.OnmsMemo;
 import org.opennms.netmgt.model.OnmsSeverity;
 import org.opennms.netmgt.model.TroubleTicketState;
 
  * @since 1.8.1
  */
 public class Alarm {
-    /** Constant <code>PROBLEM_TYPE=1</code> */
-    public static final int PROBLEM_TYPE = 1;
-    
-    /** Constant <code>RESOLUTION_TYPE=2</code> */
-    public static final int RESOLUTION_TYPE = 2;
-
-    /** Unique identifier for the alarm, cannot be null */
-    protected int id;
-
-    /** Universal Event Identifer (UEI) for this alarm, cannot be null */
-    protected String uei;
-
-    /** The dpName of the Dist Poller which received the alarm, cannot be null. */
-    protected String dpName;
-
-    /** Unique integer identifier for node, can be null */
-    protected Integer nodeID;
-
-    /** IP Address of node's interface */
-    protected String ipAddr;
-
-    /** Unique integer identifier of service/poller package, can be null */
-    protected Integer serviceID;
-
-    /** Reduction key for this alarm, cannot be null */
-    protected String reductionKey;
-
-    /** Reduction count for the alarm, cannot be null */
-    protected int count;
-
-    /**
-     * Severity the of alarm.
-     * 
-     * <pre>
-     * 
-     *   1  = Indeterminate
-     *   2 = Cleared (unimplemented at this time)
-     *   3 = Warning
-     *   4 = Minor
-     *   5 = Major
-     *   6 = Critical
-     *  
-     * </pre>
-     */
-    protected OnmsSeverity severity;
-
-    /** The last event to be reduced by this alarm */
-    protected int lastEventID;
-
-    /**
-     * The first time an event was reduced by this alarm
-     */
-    protected Date firsteventtime;
-
-    /**
-     * The last time an event was reduced by this alarm
-     */
-    protected Date lasteventtime;
-
-    /** Free-form textual description of the alarm */
-    protected String description;
+    private final OnmsAlarm m_delegate;
 
     /**
-     * Formatted display text to control how the alarm will appear in the
-     * browser. This field may contain variables that are populated by field
-     * values of the message.
-     */
-    protected String logMessage;
-
-    /** Operator instruction for event. */
-    protected String operatorInstruction;
-
-    /**
-     * Trouble ticket id.  This represents the id as returned from a trouble ticketing system
-     * or null if not trouble ticket exists.
-     */
-    protected String troubleTicket;
-
-    /**
-     * State of the trouble ticket. Trouble ticket on/off boolean 1=on, 0=off.
-     * Can be null.
-     */
-    protected TroubleTicketState troubleTicketState;
-
-    /**
-     * Mouse over text. Text to be displayed on MouseOver event, if the event is
-     * displayed in the browser and the operator needs additional info.
-     */
-    protected String mouseOverText;
-
-    /** The time that suppression will end for this alarm. */
-    protected Date suppressedUntil;
-
-    /** The name of the user who suppressed this alarm. */
-    protected String suppressedUser;
-
-    /** The time this alarm was suppressed. */
-    protected Date suppressedTime;
-
-    /** The name of the user who acknowledged this alarm. */
-    protected String acknowledgeUser;
-
-    /** The time this alarm was acknowledged. */
-    protected Date acknowledgeTime;
-
-    /** The &lt;parms&gt; element for this alarm.*/
-    protected String parms;
-
-    /** Human-readable name of the service */
-    protected String serviceName;
-
-    /** The human-readable name of the node of this alarm. Can be null. */
-    protected String nodeLabel;
-    
-    /** sticky memo to this alarm, can't be null */
-    protected Memo stickyMemo = new Memo();
-    
-    /** journal memo to the reductionkey of this alarm, can be null */
-    protected Memo reductionKeyMemo = new ReductionKeyMemo();
-    
-    /**
      * Empty constructor to create an empty <code>Alarm</code> instance. All
      * fields will hold the default values.
      */
     public Alarm() {
+        m_delegate = new OnmsAlarm();
     }
 
     /**
      * @param count a int.
      * @param severityId a int.
      */
-    public Alarm(int id, String uei, String dpName, Date lasteventtime, Date firsteventtime, int count, int severityId) {
+    private Alarm(int id, String uei, String dpName, Date lasteventtime, Date firsteventtime, int count, int severityId) {
+        this();
         if (uei == null || dpName == null || lasteventtime == null || firsteventtime == null ) {
             throw new IllegalArgumentException("Cannot take null parameters.");
         }
 
-        this.id = id;
-        this.uei = uei;
-        this.dpName = dpName;
-        this.lasteventtime = lasteventtime;
-        this.firsteventtime = firsteventtime;
-        this.count = count;
-        this.severity = OnmsSeverity.get(severityId);
+        m_delegate.setId(id);
+        m_delegate.setUei(uei);
+        m_delegate.setDistPoller(dpName);
+        m_delegate.setLastEventTime(lasteventtime);
+        m_delegate.setFirstEventTime(firsteventtime);
+        m_delegate.setCounter(count);
+        m_delegate.setSeverity(OnmsSeverity.get(severityId));
     }
 
     /**
      * @param acknowledgeTime a {@link java.util.Date} object.
      * @param parms a {@link java.lang.String} object.
      */
-    public Alarm(int id, String uei, String dpName, Integer nodeID, String ipAddr, Integer serviceID, String reductionKey, int count, int severity, int lastEventID, Date firsteventtime, Date lasteventtime, String description, String logMessage, String operatorInstruction, String troubleTicket, TroubleTicketState troubleTicketState, String mouseOverText, Date suppressedUntil, String suppressedUser, Date suppressedTime, String acknowledgeUser, Date acknowledgeTime, String parms) {
-    	this(id, uei, dpName, nodeID, ipAddr, serviceID, reductionKey, count, severity, lastEventID, firsteventtime, lasteventtime, description, logMessage, operatorInstruction, troubleTicket, troubleTicketState, mouseOverText, suppressedUntil, suppressedUser, suppressedTime, acknowledgeUser, acknowledgeTime, parms, null, null);
-    }
-
-    /**
-     * Create an alarm that represents a real network alarm with all the
-     * parameters.
-     *
-     * @param id a int.
-     * @param uei a {@link java.lang.String} object.
-     * @param dpName a {@link java.lang.String} object.
-     * @param nodeID a {@link java.lang.Integer} object.
-     * @param ipAddr a {@link java.lang.String} object.
-     * @param serviceID a {@link java.lang.Integer} object.
-     * @param reductionKey a {@link java.lang.String} object.
-     * @param count a int.
-     * @param severityId a int.
-     * @param lastEventID a int.
-     * @param firsteventtime a {@link java.util.Date} object.
-     * @param lasteventtime a {@link java.util.Date} object.
-     * @param description a {@link java.lang.String} object.
-     * @param logMessage a {@link java.lang.String} object.
-     * @param operatorInstruction a {@link java.lang.String} object.
-     * @param troubleTicket a {@link java.lang.String} object.
-     * @param troubleTicketState a {@link org.opennms.netmgt.model.TroubleTicketState} object.
-     * @param mouseOverText a {@link java.lang.String} object.
-     * @param suppressedUntil a {@link java.util.Date} object.
-     * @param suppressedUser a {@link java.lang.String} object.
-     * @param suppressedTime a {@link java.util.Date} object.
-     * @param acknowledgeUser a {@link java.lang.String} object.
-     * @param acknowledgeTime a {@link java.util.Date} object.
-     * @param parms a {@link java.lang.String} object.
-     * @param nodeLabel a {@link java.lang.String} object.
-     * @param serviceName a {@link java.lang.String} object.
-     */
-    public Alarm(int id, String uei, String dpName, Integer nodeID, String ipAddr, Integer serviceID, String reductionKey, int count, int severityId, int lastEventID, Date firsteventtime, Date lasteventtime, String description, String logMessage, String operatorInstruction, String troubleTicket, TroubleTicketState troubleTicketState, String mouseOverText, Date suppressedUntil, String suppressedUser, Date suppressedTime, String acknowledgeUser, Date acknowledgeTime, String parms, String nodeLabel, String serviceName) {
-
-        if (uei == null || dpName == null || lasteventtime == null || firsteventtime == null ) {
-            throw new IllegalArgumentException("Cannot take null values for the following parameters: uei, dpName, firsteventtime, lasteventtime.");
-        }
-
-        // required fields
-        this.id = id;
-        this.uei = uei;
-        this.dpName = dpName;
-        this.lasteventtime = lasteventtime;
-        this.firsteventtime = firsteventtime;
-	this.count = count;
-        this.severity = OnmsSeverity.get(severityId);
+    public Alarm(int id, String uei, String dpName, Integer nodeID, String ipAddr, Integer serviceID, String reductionKey, int count, int severity, int lastEventID, Date firsteventtime, Date lasteventtime, String description, String logMessage, String operatorInstruction, String troubleTicket, TroubleTicketState troubleTicketState, String mouseOverText, Date suppressedUntil, String suppressedUser, Date suppressedTime, String acknowledgeUser, Date acknowledgeTime) {
+        this(id, uei, dpName, lasteventtime, firsteventtime, count, severity);
 
         // optional fields
-    	this.nodeID = nodeID;
-	this.ipAddr = ipAddr;
-	this.serviceID = serviceID;
-	this.reductionKey = reductionKey;
-	this.lastEventID = lastEventID;
-	this.description = description;
-	this.logMessage = logMessage;
-	this.operatorInstruction = operatorInstruction;
-	this.troubleTicket = troubleTicket;
-	this.troubleTicketState = troubleTicketState;
-	this.mouseOverText = mouseOverText;
-	this.suppressedUntil = suppressedUntil;
-	this.suppressedUser = suppressedUser;
-	this.suppressedTime = suppressedTime;
-	this.acknowledgeUser = acknowledgeUser;
-	this.acknowledgeTime = acknowledgeTime;
-        this.parms = parms;
-        this.nodeLabel = nodeLabel;
-        this.serviceName = serviceName;
+        m_delegate.setNode(nodeID);
+        m_delegate.setIpAddr(ipAddr);
+        m_delegate.setServiceType(serviceID);
+        m_delegate.setReductionKey(reductionKey);
+        m_delegate.setLastEvent(lastEventID);
+        m_delegate.setDescription(description);
+        m_delegate.setLogMsg(logMessage);
+        m_delegate.setOperInstruct(operatorInstruction);
+        m_delegate.setTTicketId(troubleTicket);
+        m_delegate.setTTicketState(troubleTicketState);
+        m_delegate.setMouseOverText(mouseOverText);
+        m_delegate.setSuppressedUntil(suppressedUntil);
+        m_delegate.setSuppressedUser(suppressedUser);
+        m_delegate.setSuppressedTime(suppressedTime);
+        m_delegate.setAlarmAckUser(acknowledgeUser);
+        m_delegate.setAlarmAckTime(acknowledgeTime);
+    }
 
+    public Alarm(OnmsAlarm onmsAlarm) {
+        m_delegate = onmsAlarm;
     }
 
     /**
      * @return a int.
      */
     public int getId() {
-        return (this.id);
+        return m_delegate.getId();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getUei() {
-        return (this.uei);
+        return m_delegate.getUei();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getDpName() {
-        return (this.dpName);
+        return m_delegate.getDistPoller() == null ? null : m_delegate.getDistPoller().getName();
     }
 
     /**
      * @return a {@link java.util.Date} object.
      */
     public Date getLastEventTime() {
-        return (lasteventtime);
+        return m_delegate.getLastEventTime();
     }
 
     /**
      * @return a {@link java.util.Date} object.
      */
     public Date getFirstEventTime() {
-        return (firsteventtime);
+        return m_delegate.getFirstEventTime();
     }
 
     /**
      * @return a int.
      */
     public int getCount() {
-        return (this.count);
+        return m_delegate.getCounter();
     }
 
     /**
      * @return a {@link org.opennms.netmgt.model.OnmsSeverity} object.
      */
     public OnmsSeverity getSeverity() {
-        return severity;
+        return m_delegate.getSeverity();
     }
     
     /**
      * @return a int.
      */
     public int getNodeId() {
-        return (this.nodeID.intValue());
+        return m_delegate.getNodeId();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getIpAddress() {
-        return (this.ipAddr);
+        return InetAddressUtils.str(m_delegate.getIpAddr());
     }
 
     /**
      * @return a int.
      */
     public int getServiceId() {
-        return (this.serviceID.intValue());
+        return m_delegate.getServiceType() == null ? null : m_delegate.getServiceType().getId();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getReductionKey() {
-        return (this.reductionKey);
+        return m_delegate.getReductionKey();
     }
 
     /**
      * @return a int.
      */
     public int getLastEventID() {
-        return (this.lastEventID);
+        return m_delegate.getLastEvent() == null ? null : m_delegate.getLastEvent().getId();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getDescription() {
-        return (this.description);
+        return m_delegate.getDescription();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getLogMessage() {
-        return (this.logMessage);
+        return m_delegate.getLogMsg();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getOperatorInstruction() {
-        return (this.operatorInstruction);
+        return m_delegate.getOperInstruct();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getTroubleTicket() {
-        return (this.troubleTicket);
+        return m_delegate.getTTicketId();
     }
 
     /**
      * @return a {@link org.opennms.netmgt.model.TroubleTicketState} object.
      */
     public TroubleTicketState getTroubleTicketState() {
-        return (this.troubleTicketState);
+        return m_delegate.getTTicketState();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getMouseOverText() {
-        return (this.mouseOverText);
+        return m_delegate.getMouseOverText();
     }
 
     /**
      * @return a {@link java.util.Date} object.
      */
     public Date getSuppressedUntil() {
-        return (this.suppressedUntil);
+        return m_delegate.getSuppressedUntil();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getSuppressedUser() {
-        return (this.suppressedUser);
+        return m_delegate.getSuppressedUser();
     }
 
     /**
      * @return a {@link java.util.Date} object.
      */
     public Date getSuppressedTime() {
-        return (this.suppressedTime);
+        return m_delegate.getSuppressedTime();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getAcknowledgeUser() {
-        return (this.acknowledgeUser);
+        return m_delegate.getAckUser();
     }
 
     /**
      * @return a {@link java.util.Date} object.
      */
     public Date getAcknowledgeTime() {
-        return (this.acknowledgeTime);
+        return m_delegate.getAckTime();
     }
 
     /**
      * @return a boolean.
      */
     public boolean isAcknowledged() {
-        return (this.acknowledgeUser != null);
+        return m_delegate.getAckUser() != null;
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getParms() {
-        return (this.parms);
+        return m_delegate.getEventParms();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getNodeLabel() {
-        return (this.nodeLabel);
+        return m_delegate.getNode() == null ? null : m_delegate.getNode().getLabel();
     }
 
     /**
      * @return a {@link java.lang.String} object.
      */
     public String getServiceName() {
-        return (this.serviceName);
+        return m_delegate.getServiceType() == null ? null : m_delegate.getServiceType().getName();
     }
 
-    public Memo getReductionKeyMemo() {
-        return reductionKeyMemo;
+    public OnmsMemo getReductionKeyMemo() {
+        return m_delegate.getReductionKeyMemo();
     }
 
-    public Memo getStickyMemo() {
-        return stickyMemo;
+    public OnmsMemo getStickyMemo() {
+        return m_delegate.getStickyMemo();
     }
     
     @Override
     public String toString() {
         return new ToStringBuilder(this)
-            .append("id", id)
-            .append("UEI", uei)
-            .append("distPoller", dpName)
-            .append("nodeID", nodeID)
-            .append("nodeLabel", nodeLabel)
-            .append("ipAddress", ipAddr)
-            .append("serviceID", serviceID)
-            .append("reductionKey", reductionKey)
-            .append("count", count)
-            .append("severity", severity)
-            .append("serviceName", serviceName)
-            .append("lastEventID", lastEventID)
-            .append("lastEventTime", lasteventtime)
-            .append("description", description)
-            .append("logMessage", logMessage)
-            .append("operatorInstruction", operatorInstruction)
-            .append("troubleTicket", troubleTicket)
-            .append("troubleTicketState", troubleTicketState)
-            .append("mouseOverText", mouseOverText)
-            .append("suppressedUntil", suppressedUntil)
-            .append("suppressedUser", suppressedUser)
-            .append("suppressedTime", suppressedTime)
-            .append("acknowledgedUser", acknowledgeUser)
-            .append("acknowledgedTime", acknowledgeTime)
-            .append("parms", parms)
-            .append("stickyMemo", stickyMemo)
-            .append("reductionKeyMemo", reductionKeyMemo)    
+            .append("id", getId())
+            .append("UEI", getUei())
+            .append("distPoller", getDpName())
+            .append("nodeID", getNodeId())
+            .append("nodeLabel", getNodeLabel())
+            .append("ipAddress", getIpAddress())
+            .append("serviceID", getServiceId())
+            .append("reductionKey", getReductionKey())
+            .append("count", getCount())
+            .append("severity", getSeverity())
+            .append("serviceName", getServiceName())
+            .append("lastEventID", getLastEventID())
+            .append("lastEventTime", getLastEventTime())
+            .append("description", getDescription())
+            .append("logMessage", getLogMessage())
+            .append("operatorInstruction", getOperatorInstruction())
+            .append("troubleTicket", getTroubleTicket())
+            .append("troubleTicketState", getTroubleTicketState())
+            .append("mouseOverText", getMouseOverText())
+            .append("suppressedUntil", getSuppressedUntil())
+            .append("suppressedUser", getSuppressedUser())
+            .append("suppressedTime", getSuppressedTime())
+            .append("acknowledgedUser", getAcknowledgeUser())
+            .append("acknowledgedTime", getAcknowledgeTime())
+            .append("stickyMemo", getStickyMemo())
+            .append("reductionKeyMemo", getReductionKeyMemo())
             .toString();
     }
 }

opennms-webapp/src/main/java/org/opennms/web/alarm/AlarmFactory.java

-/*******************************************************************************
- * This file is part of OpenNMS(R).
- *
- * Copyright (C) 2006-2012 The OpenNMS Group, Inc.
- * OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
- *
- * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
- *
- * OpenNMS(R) is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, either version 3 of the License,
- * or (at your option) any later version.
- *
- * OpenNMS(R) is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with OpenNMS(R).  If not, see:
- *      http://www.gnu.org/licenses/
- *
- * For more information contact:
- *     OpenNMS(R) Licensing <license@opennms.org>
- *     http://www.opennms.org/
- *     http://www.opennms.com/
- *******************************************************************************/
-
-package org.opennms.web.alarm;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.Vector;
-
-import javax.servlet.ServletContext;
-
-import org.opennms.core.resource.Vault;
-import org.opennms.core.utils.DBUtils;
-import org.opennms.core.utils.ThreadCategory;
-import org.opennms.netmgt.model.OnmsSeverity;
-import org.opennms.netmgt.model.TroubleTicketState;
-import org.opennms.web.alarm.filter.InterfaceFilter;
-import org.opennms.web.alarm.filter.NodeFilter;
-import org.opennms.web.alarm.filter.ServiceFilter;
-import org.opennms.web.alarm.filter.SeverityFilter;
-import org.opennms.web.filter.Filter;
-
-/**
- * Encapsulates all querying functionality for alarms.
- *
- * @author <A HREF="mailto:tarus@opennms.org">Tarus Balog </A>
- * @author <A HREF="mailto:larry@opennms.org">Lawrence Karnowski </A>
- */
-public class AlarmFactory extends Object {
-    
-    /** Private constructor so this class cannot be instantiated. */
-    private AlarmFactory() {
-    }
-    
-    private static ThreadCategory log() {
-    	return ThreadCategory.getInstance();
-    }
-
-    /**
-     * Count all outstanding (unacknowledged) alarms.
-     *
-     * @return a int.
-     * @throws java.sql.SQLException if any.
-     */
-    public static int getAlarmCount() throws SQLException {
-        return getAlarmCount(AcknowledgeType.UNACKNOWLEDGED, new Filter[0]);
-    }
-    
-    /**
-     * Count the number of alarms for a given acknowledgement type.
-     *
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @param filters an array of org$opennms$web$filter$Filter objects.
-     * @return a int.
-     * @throws java.sql.SQLException if any.
-     */
-    public static int getAlarmCount(AcknowledgeType ackType, Filter[] filters) throws SQLException {
-        if (ackType == null || filters == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        int alarmCount = 0;
-
-        final DBUtils d = new DBUtils(AlarmFactory.class);
-        try {
-            Connection conn = Vault.getDbConnection();
-            d.watch(conn);
-            StringBuffer select = new StringBuffer("SELECT COUNT(ALARMID) AS ALARMCOUNT FROM ALARMS LEFT OUTER JOIN NODE USING (NODEID) LEFT OUTER JOIN SERVICE USING (SERVICEID) WHERE ");
-            select.append(ackType.getAcknowledgeTypeClause());
-
-            for (int i = 0; i < filters.length; i++) {
-                select.append(" AND ");
-                select.append(filters[i].getParamSql());
-            }
-
-//            select.append(" AND ALARMDISPLAY='Y' ");
-
-            PreparedStatement stmt = conn.prepareStatement(select.toString());
-            d.watch(stmt);
-            
-            int parameterIndex = 1;
-            for (int i = 0; i < filters.length; i++) {
-            	parameterIndex += filters[i].bindParam(stmt, parameterIndex);
-            }
-            
-            ResultSet rs = stmt.executeQuery();
-            d.watch(rs);
-
-            if (rs.next()) {
-                alarmCount = rs.getInt("ALARMCOUNT");
-            }
-        } finally {
-            d.cleanUp();
-        }
-
-        return alarmCount;
-    }
-
-    /**
-     * Count the number of alarms for a given acknowledgement type.
-     *
-     * @return 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).
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @param filters an array of org$opennms$web$filter$Filter objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static int[] getAlarmCountBySeverity(AcknowledgeType ackType, Filter[] filters) throws SQLException {
-        if (ackType == null || filters == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        int[] alarmCounts = new int[8];
-
-        final DBUtils d = new DBUtils(AlarmFactory.class);
-        try {
-            Connection conn = Vault.getDbConnection();
-            d.watch(conn);
-            StringBuffer select = new StringBuffer("SELECT SEVERITY, COUNT(ALARMID) AS ALARMCOUNT FROM ALARMS LEFT OUTER JOIN NODE USING (NODEID) LEFT OUTER JOIN SERVICE USING (SERVICEID) WHERE ");
-            select.append(ackType.getAcknowledgeTypeClause());
-
-            for (int i = 0; i < filters.length; i++) {
-                select.append(" AND ");
-                select.append(filters[i].getParamSql());
-            }
-
-//            select.append(" AND EVENTDISPLAY='Y'");
-            select.append(" GROUP BY SEVERITY");
-
-            PreparedStatement stmt = conn.prepareStatement(select.toString());
-            d.watch(stmt);
-            
-            int parameterIndex = 1;
-            for (int i = 1; i < filters.length; i++) {
-            	parameterIndex += filters[i].bindParam(stmt, parameterIndex);
-            }
-            
-            ResultSet rs = stmt.executeQuery();
-            d.watch(rs);
-
-            while (rs.next()) {
-                int severity = rs.getInt("SEVERITY");
-                int alarmCount = rs.getInt("ALARMCOUNT");
-
-                alarmCounts[severity] = alarmCount;
-            }
-        } finally {
-            d.cleanUp();
-        }
-
-        return alarmCounts;
-    }
-
-    /**
-     * Return a specific alarm.
-     *
-     * @param alarmId a int.
-     * @return a {@link org.opennms.web.alarm.Alarm} object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm getAlarms(int alarmId) throws SQLException {
-        Alarm alarm = null;
-
-        final DBUtils d = new DBUtils(AlarmFactory.class);
-        try {
-            Connection conn = Vault.getDbConnection();
-            d.watch(conn);
-            PreparedStatement stmt = conn.prepareStatement("SELECT ALARMS.*, NODE.NODELABEL, SERVICE.SERVICENAME FROM ALARMS LEFT OUTER JOIN NODE USING (NODEID) LEFT OUTER JOIN SERVICE USING (SERVICEID) WHERE ALARMID=? ");
-            d.watch(stmt);
-            stmt.setInt(1, alarmId);
-            ResultSet rs = stmt.executeQuery();
-            d.watch(rs);
-
-            Alarm[] alarms = rs2Alarms(rs);
-
-            // what do I do if this actually returns more than one service?
-            if (alarms.length > 0) {
-                alarm = alarms[0];
-            }
-        } finally {
-            d.cleanUp();
-        }
-
-        return alarm;
-    }
-
-    /**
-     * Return all unacknowledged alarms sorted by time.
-     *
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarms() throws SQLException {
-        return (AlarmFactory.getAlarms(SortStyle.LASTEVENTTIME, AcknowledgeType.UNACKNOWLEDGED));
-    }
-
-    /**
-     * Return all unacknowledged or acknowledged alarms sorted by time.
-     *
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarms(AcknowledgeType ackType) throws SQLException {
-        return (AlarmFactory.getAlarms(SortStyle.LASTEVENTTIME, ackType));
-    }
-
-    /**
-     * Return all unacknowledged alarms sorted by the given sort style.
-     *
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarms(SortStyle sortStyle) throws SQLException {
-        return (AlarmFactory.getAlarms(sortStyle, AcknowledgeType.UNACKNOWLEDGED));
-    }
-
-    /**
-     * Return all alarms (optionally only unacknowledged alarms) sorted by the
-     * given sort style.
-     *
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param includeAcknowledged a boolean.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarms(SortStyle sortStyle, boolean includeAcknowledged) throws SQLException {
-        AcknowledgeType ackType = (includeAcknowledged) ? AcknowledgeType.BOTH : AcknowledgeType.UNACKNOWLEDGED;
-        return (AlarmFactory.getAlarms(sortStyle, ackType));
-    }
-
-    /**
-     * Return all alarms (optionally only unacknowledged alarms) sorted by the
-     * given sort style.
-     *
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarms(SortStyle sortStyle, AcknowledgeType ackType) throws SQLException {
-        return (AlarmFactory.getAlarms(sortStyle, ackType, new Filter[0]));
-    }
-
-    /**
-     * Return all alarms (optionally only unacknowledged alarms) sorted by the
-     * given sort style.
-     *
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @param filters an array of org$opennms$web$filter$Filter objects.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarms(SortStyle sortStyle, AcknowledgeType ackType, Filter[] filters) throws SQLException {
-        return (AlarmFactory.getAlarms(sortStyle, ackType, filters, -1, -1));
-    }
-
-    /**
-     * Return all alarms (optionally only unacknowledged alarms) sorted by the
-     * given sort style.
-     *
-     * <p>
-     * <strong>Note: </strong> This limit/offset code is <em>Postgres
-     * specific!</em>
-     * Per <a href="mailto:shaneo@opennms.org">Shane </a>, this is okay for now
-     * until we can come up with an Oracle alternative too.
-     * </p>
-     *
-     * @param limit
-     *            if -1 or zero, no limit or offset is used
-     * @param offset
-     *            if -1, no limit or offset if used
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @param filters an array of org$opennms$web$filter$Filter objects.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarms(SortStyle sortStyle, AcknowledgeType ackType, Filter[] filters, int limit, int offset) throws SQLException {
-        if (sortStyle == null || ackType == null || filters == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        boolean useLimits = false;
-        if (limit > 0 && offset > -1) {
-            useLimits = true;
-        }
-
-        Alarm[] alarms = null;
-
-        final DBUtils d = new DBUtils(AlarmFactory.class);
-        try {
-            Connection conn = Vault.getDbConnection();
-            d.watch(conn);
-            StringBuffer select = new StringBuffer("SELECT ALARMS.*, NODE.NODELABEL, SERVICE.SERVICENAME FROM ALARMS LEFT OUTER JOIN NODE USING(NODEID) LEFT OUTER JOIN SERVICE USING(SERVICEID) WHERE");
-            select.append(ackType.getAcknowledgeTypeClause());
-
-            for (int i = 0; i < filters.length; i++) {
-                select.append(" AND ");
-                select.append(filters[i].getParamSql());
-            }
-
-//            select.append(" AND ALARMDISPLAY='Y' ");
-            select.append(sortStyle.getOrderByClause());
-
-            if (useLimits) {
-                select.append(" LIMIT ");
-                select.append(limit);
-                select.append(" OFFSET ");
-                select.append(offset);
-            }
-
-            PreparedStatement stmt = conn.prepareStatement(select.toString());
-            d.watch(stmt);
-            
-            int parameterIndex = 1;
-            for (int i = 0; i < filters.length; i++) {
-            	parameterIndex += filters[i].bindParam(stmt, parameterIndex);
-            }
-            
-            ResultSet rs = stmt.executeQuery();
-            d.watch(rs);
-
-            alarms = rs2Alarms(rs);
-        } finally {
-            d.cleanUp();
-        }
-
-        return alarms;
-    }
-
-    /*
-     * ****************************************************************************
-     * N O D E M E T H O D S
-     * ****************************************************************************
-     */
-
-    /**
-     * Return all unacknowledged alarms sorted by alarm ID for the given node.
-     *
-     * @param nodeId a int.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForNode(int nodeId, ServletContext servletContext) throws SQLException {
-        return (getAlarmsForNode(nodeId, SortStyle.ID, AcknowledgeType.UNACKNOWLEDGED, -1, -1, servletContext));
-    }
-
-    /**
-     * Return all alarms (optionally only unacknowledged alarms) sorted by the
-     * given sort style for the given node.
-     *
-     * @param nodeId a int.
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForNode(int nodeId, SortStyle sortStyle, AcknowledgeType ackType, ServletContext servletContext) throws SQLException {
-        return (getAlarmsForNode(nodeId, sortStyle, ackType, -1, -1, servletContext));
-    }
-
-    /**
-     * Return some maximum number of alarms or less (optionally only
-     * unacknowledged alarms) sorted by the given sort style for the given node.
-     *
-     * @param throttle
-     *            a value less than one means no throttling
-     * @param nodeId a int.
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @param offset a int.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForNode(int nodeId, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset, ServletContext servletContext) throws SQLException {
-        if (sortStyle == null || ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new NodeFilter(nodeId, servletContext) };
-        return (AlarmFactory.getAlarms(sortStyle, ackType, filters, throttle, offset));
-    }
-
-    /**
-     * Return the number of alarms for this node and the given acknowledgement
-     * type.
-     *
-     * @param nodeId a int.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return a int.
-     * @throws java.sql.SQLException if any.
-     */
-    public static int getAlarmCountForNode(int nodeId, AcknowledgeType ackType, ServletContext servletContext) throws SQLException {
-        if (ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new NodeFilter(nodeId, servletContext) };
-        return (getAlarmCount(ackType, filters));
-    }
-
-    /*
-     * ****************************************************************************
-     * I N T E R F A C E M E T H O D S
-     * ****************************************************************************
-     */
-
-    /**
-     * Return all unacknowledged alarms sorted by event ID for the given
-     * interface.
-     *
-     * @param nodeId a int.
-     * @param ipAddress a {@link java.lang.String} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForInterface(int nodeId, String ipAddress, ServletContext servletContext) throws SQLException {
-        return (getAlarmsForInterface(nodeId, ipAddress, SortStyle.ID, AcknowledgeType.UNACKNOWLEDGED, -1, -1, servletContext));
-    }
-
-    /**
-     * Return some maximum number of alarms or less (optionally only
-     * unacknowledged alarms) sorted by the given sort style for the given node
-     * and IP address.
-     *
-     * @param throttle
-     *            a value less than one means no throttling
-     * @param offset
-     *            which row to start on in the result list
-     * @param nodeId a int.
-     * @param ipAddress a {@link java.lang.String} object.
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForInterface(int nodeId, String ipAddress, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset, ServletContext servletContext) throws SQLException {
-        if (ipAddress == null || sortStyle == null || ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new NodeFilter(nodeId, servletContext), new InterfaceFilter(ipAddress) };
-        return (AlarmFactory.getAlarms(sortStyle, ackType, filters, throttle, offset));
-    }
-
-    /**
-     * Return all unacknowledged alarms sorted by time for that have the given
-     * IP address, regardless of what node they belong to.
-     *
-     * @param ipAddress a {@link java.lang.String} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForInterface(String ipAddress) throws SQLException {
-        return (getAlarmsForInterface(ipAddress, SortStyle.ID, AcknowledgeType.UNACKNOWLEDGED, -1, -1));
-    }
-
-    /**
-     * Return all alarms (optionally only unacknowledged alarms) sorted by time
-     * that have the given IP address, regardless of what node they belong to.
-     *
-     * @deprecated Replaced by
-     *             {@link " #getEventsForInterface(String,SortStyle,AcknowledgeType) getEventsForInterface( String, SortStyle, AcknowledgeType )"}
-     * @param ipAddress a {@link java.lang.String} object.
-     * @param includeAcknowledged a boolean.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForInterface(String ipAddress, boolean includeAcknowledged) throws SQLException {
-        AcknowledgeType ackType = (includeAcknowledged) ? AcknowledgeType.BOTH : AcknowledgeType.UNACKNOWLEDGED;
-        return (getAlarmsForInterface(ipAddress, SortStyle.ID, ackType, -1, -1));
-    }
-
-    /**
-     * Return some maximum number of alarms or less (optionally only
-     * unacknowledged alarms) sorted by the given sort style for the given IP
-     * address.
-     *
-     * @param throttle
-     *            a value less than one means no throttling
-     * @param offset
-     *            which row to start on in the result list
-     * @param ipAddress a {@link java.lang.String} object.
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForInterface(String ipAddress, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset) throws SQLException {
-        if (ipAddress == null || sortStyle == null || ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new InterfaceFilter(ipAddress) };
-        return (AlarmFactory.getAlarms(sortStyle, ackType, filters, throttle, offset));
-    }
-
-    /**
-     * Return the number of alarms for this node ID, IP address, and the given
-     * acknowledgement type.
-     *
-     * @param nodeId a int.
-     * @param ipAddress a {@link java.lang.String} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return a int.
-     * @throws java.sql.SQLException if any.
-     */
-    public static int getAlarmCountForInterface(int nodeId, String ipAddress, AcknowledgeType ackType, ServletContext servletContext) throws SQLException {
-        if (ipAddress == null || ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new NodeFilter(nodeId, servletContext), new InterfaceFilter(ipAddress) };
-        return (getAlarmCount(ackType, filters));
-    }
-
-    /**
-     * Return the number of alarms for this IP address and the given
-     * acknowledgement type.
-     *
-     * @param ipAddress a {@link java.lang.String} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return a int.
-     * @throws java.sql.SQLException if any.
-     */
-    public static int getAlarmCountForInterface(String ipAddress, AcknowledgeType ackType) throws SQLException {
-        if (ipAddress == null || ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new InterfaceFilter(ipAddress) };
-        return (getAlarmCount(ackType, filters));
-    }
-
-    /*
-     * ****************************************************************************
-     * S E R V I C E M E T H O D S
-     * ****************************************************************************
-     */
-
-    /**
-     * Return all unacknowledged alarms sorted by time for the given service.
-     *
-     * @param nodeId a int.
-     * @param ipAddress a {@link java.lang.String} object.
-     * @param serviceId a int.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForService(int nodeId, String ipAddress, int serviceId, ServletContext servletContext) throws SQLException {
-        return (getAlarmsForService(nodeId, ipAddress, serviceId, SortStyle.ID, AcknowledgeType.UNACKNOWLEDGED, -1, -1, servletContext));
-    }
-
-    /**
-     * Return some maximum number of alarms or less (optionally only
-     * unacknowledged alarms) sorted by the given sort style for the given node,
-     * IP address, and service ID.
-     *
-     * @param throttle
-     *            a value less than one means no throttling
-     * @param offset
-     *            which row to start on in the result list
-     * @param nodeId a int.
-     * @param ipAddress a {@link java.lang.String} object.
-     * @param serviceId a int.
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForService(int nodeId, String ipAddress, int serviceId, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset, ServletContext servletContext) throws SQLException {
-        if (ipAddress == null || sortStyle == null || ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new NodeFilter(nodeId, servletContext), new InterfaceFilter(ipAddress), new ServiceFilter(serviceId) };
-        return (AlarmFactory.getAlarms(sortStyle, ackType, filters, throttle, offset));
-    }
-
-    /**
-     * Return all unacknowledged alarms sorted by time for the given service
-     * type, regardless of what node or interface they belong to.
-     *
-     * @param serviceId a int.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForService(int serviceId) throws SQLException {
-        return (getAlarmsForService(serviceId, SortStyle.ID, AcknowledgeType.UNACKNOWLEDGED, -1, -1));
-    }
-
-    /**
-     * Return all alarms (optionally only unacknowledged alarms) sorted by time
-     * for the given service type, regardless of what node or interface they
-     * belong to.
-     *
-     * @param serviceId a int.
-     * @param includeAcknowledged a boolean.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForService(int serviceId, boolean includeAcknowledged) throws SQLException {
-        AcknowledgeType ackType = (includeAcknowledged) ? AcknowledgeType.BOTH : AcknowledgeType.UNACKNOWLEDGED;
-        return (getAlarmsForService(serviceId, SortStyle.ID, ackType, -1, -1));
-    }
-
-    /**
-     * Return some maximum number of alarms or less (optionally only
-     * unacknowledged alarms) sorted by the given sort style for the given
-     * service ID.
-     *
-     * @param throttle
-     *            a value less than one means no throttling
-     * @param offset
-     *            which row to start on in the result list
-     * @param serviceId a int.
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForService(int serviceId, SortStyle sortStyle, AcknowledgeType ackType, int throttle, int offset) throws SQLException {
-        if (sortStyle == null || ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new ServiceFilter(serviceId) };
-        return (AlarmFactory.getAlarms(sortStyle, ackType, filters, throttle, offset));
-    }
-
-    /**
-     * Return the number of alarms for this node ID, IP address, service ID, and
-     * the given acknowledgement type.
-     *
-     * @param nodeId a int.
-     * @param ipAddress a {@link java.lang.String} object.
-     * @param serviceId a int.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return a int.
-     * @throws java.sql.SQLException if any.
-     */
-    public static int getAlarmCountForService(int nodeId, String ipAddress, int serviceId, AcknowledgeType ackType, ServletContext servletContext) throws SQLException {
-        if (ipAddress == null || ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new NodeFilter(nodeId, servletContext), new InterfaceFilter(ipAddress), new ServiceFilter(serviceId) };
-        return (getAlarmCount(ackType, filters));
-    }
-
-    /**
-     * Return the number of alarms for this node ID, IP address, service ID, and
-     * the given acknowledgement type.
-     *
-     * @param serviceId a int.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return a int.
-     * @throws java.sql.SQLException if any.
-     */
-    public static int getAlarmCountForService(int serviceId, AcknowledgeType ackType) throws SQLException {
-        if (ackType == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Filter[] filters = new Filter[] { new ServiceFilter(serviceId) };
-        return (getAlarmCount(ackType, filters));
-    }
-
-    /**
-     * Return all unacknowledged alarms sorted by time for the given severity.
-     *
-     * @param severity a int.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForSeverity(int severity) throws SQLException {
-        return (AlarmFactory.getAlarmsForSeverity(severity, SortStyle.ID, AcknowledgeType.UNACKNOWLEDGED));
-    }
-
-    /**
-     * <p>getAlarmsForSeverity</p>
-     *
-     * @param severity a int.
-     * @param sortStyle a {@link org.opennms.web.alarm.SortStyle} object.
-     * @param ackType a {@link org.opennms.web.alarm.AcknowledgeType} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForSeverity(int severity, SortStyle sortStyle, AcknowledgeType ackType) throws SQLException {
-        return (AlarmFactory.getAlarms(sortStyle, ackType, new Filter[] { new SeverityFilter(OnmsSeverity.get(severity)) }));
-    }
-
-    /**
-     * Return all unacknowledged alarms sorted by time for that have the given
-     * distributed poller.
-     *
-     * @param poller a {@link java.lang.String} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForPoller(String poller) throws SQLException {
-        return (getAlarmsForPoller(poller, false));
-    }
-
-    /**
-     * Return all alarms (optionally only unacknowledged alarms) sorted by time
-     * that have the given distributed poller.
-     *
-     * @param poller a {@link java.lang.String} object.
-     * @param includeAcknowledged a boolean.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static Alarm[] getAlarmsForPoller(String poller, boolean includeAcknowledged) throws SQLException {
-        if (poller == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        Alarm[] alarms = null;
-
-        final DBUtils d = new DBUtils(AlarmFactory.class);
-        try {
-            Connection conn = Vault.getDbConnection();
-            d.watch(conn);
-            StringBuffer select = new StringBuffer("SELECT * FROM ALARMS WHERE DPNAME=?");
-
-            if (!includeAcknowledged) {
-                select.append(" AND ALARMACKUSER IS NULL");
-            }
-
-            select.append(" AND ALARMDISPLAY='Y' ");
-            select.append(" ORDER BY ALARMID DESC");
-
-            PreparedStatement stmt = conn.prepareStatement(select.toString());
-            d.watch(stmt);
-            stmt.setString(1, poller);
-            ResultSet rs = stmt.executeQuery();
-            d.watch(rs);
-
-            alarms = rs2Alarms(rs);
-        } finally {
-            d.cleanUp();
-        }
-
-        return alarms;
-    }
-
-    /**
-     * Acknowledge a list of alarms with the given username and the current
-     * time.
-     *
-     * @param alarms an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @param user a {@link java.lang.String} object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void acknowledge(Alarm[] alarms, String user) throws SQLException {
-        acknowledge(alarms, user, new Date());
-    }
-
-    /**
-     * Acknowledge a list of alarms with the given username and the given time.
-     *
-     * @param alarms an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @param user a {@link java.lang.String} object.
-     * @param time a java$util$Date object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void acknowledge(Alarm[] alarms, String user, Date time) throws SQLException {
-        if (alarms == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        int[] ids = new int[alarms.length];
-
-        for (int i = 0; i < ids.length; i++) {
-            ids[i] = alarms[i].getId();
-        }
-
-        acknowledge(ids, user, time);
-    }
-
-    /**
-     * Acknowledge a list of alarms with the given username and the current
-     * time.
-     *
-     * @param alarmIds an array of int.
-     * @param user a {@link java.lang.String} object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void acknowledge(int[] alarmIds, String user) throws SQLException {
-        acknowledge(alarmIds, user, new Date());
-    }
-
-    /**
-     * Acknowledge a list of alarms with the given username and the given time.
-     *
-     * @param alarmIds an array of int.
-     * @param user a {@link java.lang.String} object.
-     * @param time a java$util$Date object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void acknowledge(int[] alarmIds, String user, Date time) throws SQLException {
-        if (alarmIds == null || user == null || time == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        if (alarmIds.length > 0) {
-            StringBuffer update = new StringBuffer("UPDATE ALARMS SET ALARMACKUSER=?, ALARMACKTIME=?");
-            update.append(" WHERE ALARMID IN (");
-            update.append(alarmIds[0]);
-
-            for (int i = 1; i < alarmIds.length; i++) {
-                update.append(",");
-                update.append(alarmIds[i]);
-            }
-
-            update.append(")");
-            update.append(" AND ALARMACKUSER IS NULL");
-
-            final DBUtils d = new DBUtils(AlarmFactory.class);
-            try {
-                Connection conn = Vault.getDbConnection();
-                d.watch(conn);
-
-                PreparedStatement stmt = conn.prepareStatement(update.toString());
-                d.watch(stmt);
-                stmt.setString(1, user);
-                stmt.setTimestamp(2, new Timestamp(time.getTime()));
-
-                stmt.executeUpdate();
-            } finally {
-                d.cleanUp();
-            }
-        }
-    }
-
-    /**
-     * Acknowledge with the given username and the current time all alarms that
-     * match the given filter criteria.
-     *
-     * @param filters an array of org$opennms$web$filter$Filter objects.
-     * @param user a {@link java.lang.String} object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void acknowledge(Filter[] filters, String user) throws SQLException {
-        acknowledge(filters, user, new Date());
-    }
-
-    /**
-     * Acknowledge with the given username and the given time all alarms that
-     * match the given filter criteria.
-     *
-     * @param filters an array of org$opennms$web$filter$Filter objects.
-     * @param user a {@link java.lang.String} object.
-     * @param time a java$util$Date object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void acknowledge(Filter[] filters, String user, Date time) throws SQLException {
-        if (filters == null || user == null || time == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        StringBuffer update = new StringBuffer("UPDATE ALARMS SET ALARMACKUSER=?, ALARMACKTIME=? WHERE");
-        update.append(AcknowledgeType.UNACKNOWLEDGED.getAcknowledgeTypeClause());
-
-        for (int i = 0; i < filters.length; i++) {
-            update.append(" AND ");
-            update.append(filters[i].getParamSql());
-        }
-
-        final DBUtils d = new DBUtils(AlarmFactory.class);
-        try {
-            Connection conn = Vault.getDbConnection();
-            d.watch(conn);
-
-            PreparedStatement stmt = conn.prepareStatement(update.toString());
-            d.watch(stmt);
-            stmt.setString(1, user);
-            stmt.setTimestamp(2, new Timestamp(time.getTime()));
-            
-            int parameterIndex = 3;
-            for (int i = 0; i < filters.length; i++) {
-            	parameterIndex += filters[i].bindParam(stmt, parameterIndex);
-            }
-
-            stmt.executeUpdate();
-        } finally {
-            d.cleanUp();
-        }
-    }
-
-    /**
-     * Acknowledge all unacknowledged alarms with the given username and the
-     * given time.
-     *
-     * @param user a {@link java.lang.String} object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void acknowledgeAll(String user) throws SQLException {
-        acknowledgeAll(user, new Date());
-    }
-
-    /**
-     * Acknowledge all unacknowledged alarms with the given username and the
-     * given time.
-     *
-     * @param user a {@link java.lang.String} object.
-     * @param time a java$util$Date object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void acknowledgeAll(String user, Date time) throws SQLException {
-        if (user == null || time == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        final DBUtils d = new DBUtils(AlarmFactory.class);
-        try {
-            Connection conn = Vault.getDbConnection();
-            d.watch(conn);
-
-            PreparedStatement stmt = conn.prepareStatement("UPDATE ALARMS SET ALARMACKUSER=?, ALARMACKTIME=? WHERE ALARMACKUSER IS NULL");
-            d.watch(stmt);
-            stmt.setString(1, user);
-            stmt.setTimestamp(2, new Timestamp(time.getTime()));
-
-            stmt.executeUpdate();
-        } finally {
-            d.cleanUp();
-        }
-
-    }
-
-    /**
-     * Unacknowledge a list of alarms.
-     *
-     * @param alarms an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void unacknowledge(Alarm[] alarms) throws SQLException {
-        if (alarms == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        int[] ids = new int[alarms.length];
-
-        for (int i = 0; i < ids.length; i++) {
-            ids[i] = alarms[i].getId();
-        }
-
-        unacknowledge(ids);
-    }
-
-    /**
-     * Unacknowledge a list of alarms.
-     *
-     * @param alarmIds an array of int.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void unacknowledge(int[] alarmIds) throws SQLException {
-        if (alarmIds == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        if (alarmIds.length > 0) {
-            StringBuffer update = new StringBuffer("UPDATE ALARMS SET ALARMACKUSER=NULL, ALARMACKTIME=NULL");
-            update.append(" WHERE ALARMID IN (");
-            update.append(alarmIds[0]);
-
-            for (int i = 1; i < alarmIds.length; i++) {
-                update.append(",");
-                update.append(alarmIds[i]);
-            }
-
-            update.append(")");
-
-            final DBUtils d = new DBUtils(AlarmFactory.class);
-            try {
-                Connection conn = Vault.getDbConnection();
-                d.watch(conn);
-
-                PreparedStatement stmt = conn.prepareStatement(update.toString());
-                d.watch(stmt);
-                stmt.executeUpdate();
-            } finally {
-                d.cleanUp();
-            }
-        }
-    }
-
-    /**
-     * Unacknowledge alarms that match the given filter criteria.
-     *
-     * @param filters an array of org$opennms$web$filter$Filter objects.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void unacknowledge(Filter[] filters) throws SQLException {
-        if (filters == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        StringBuffer update = new StringBuffer("UPDATE ALARMS SET ALARMACKUSER=NULL, ALARMACKTIME=NULL WHERE");
-        update.append(AcknowledgeType.ACKNOWLEDGED.getAcknowledgeTypeClause());
-
-        for (int i = 0; i < filters.length; i++) {
-            update.append(" AND ");
-            update.append(filters[i].getParamSql());
-        }
-
-        final DBUtils d = new DBUtils(AlarmFactory.class);
-        try {
-            Connection conn = Vault.getDbConnection();
-            d.watch(conn);
-
-            PreparedStatement stmt = conn.prepareStatement(update.toString());
-            d.watch(stmt);
-            
-            int parameterIndex = 1;
-            for (int i = 0; i < filters.length; i++) {
-            	parameterIndex += filters[i].bindParam(stmt, parameterIndex);
-            }
-
-            stmt.executeUpdate();
-        } finally {
-            d.cleanUp();
-        }
-    }
-
-    /**
-     * Unacknowledge all acknowledged alarms.
-     *
-     * @throws java.sql.SQLException if any.
-     */
-    public static void unacknowledgeAll() throws SQLException {
-        final DBUtils d = new DBUtils(AlarmFactory.class);
-        try {
-            Connection conn = Vault.getDbConnection();
-            d.watch(conn);
-
-            PreparedStatement stmt = conn.prepareStatement("UPDATE ALARMS SET ALARMACKUSER=NULL, ALARMACKTIME=NULL WHERE ALARMACKUSER IS NOT NULL");
-            d.watch(stmt);
-            
-            stmt.executeUpdate();
-        } finally {
-            d.cleanUp();
-        }
-
-    }
-
-    /**
-     * Convenience method for translating a <code>java.sql.ResultSet</code>
-     * containing event information into an array of <code>Alarm</code>
-     * objects.
-     *
-     * @param rs a {@link java.sql.ResultSet} object.
-     * @return an array of {@link org.opennms.web.alarm.Alarm} objects.
-     * @throws java.sql.SQLException if any.
-     */
-    protected static Alarm[] rs2Alarms(ResultSet rs) throws SQLException {
-        Vector<Alarm> vector = new Vector<Alarm>();
-
-        while (rs.next()) {
-            Alarm alarm = new Alarm();
-
-            alarm.id = rs.getInt("alarmID");
-
-            alarm.uei = rs.getString("eventUei");
-
-            alarm.dpName = rs.getString("dpName");
-
-            // node id can be null, in which case nodeID will be 0
-            alarm.nodeID = Integer.valueOf(rs.getInt("nodeID"));
-
-            alarm.ipAddr = rs.getString("ipAddr");
-
-            // This causes serviceID to be null if the column in the database is null
-            alarm.serviceID = ((Integer) rs.getObject("serviceID"));
-
-            alarm.reductionKey = rs.getString("reductionKey");
-
-            alarm.count = rs.getInt("counter");
-
-            alarm.severity = OnmsSeverity.get(rs.getInt("severity"));
-
-            alarm.lastEventID = rs.getInt("lastEventID");
-
-            Timestamp firsteventtime = rs.getTimestamp("firsteventtime");
-            if (firsteventtime != null) {
-                alarm.firsteventtime = new Date(firsteventtime.getTime());
-            }
-
-            Timestamp lasteventtime = rs.getTimestamp("lasteventtime");
-            if (lasteventtime != null) {
-                alarm.lasteventtime = new Date(lasteventtime.getTime());
-            }
-
-            alarm.description = rs.getString("description");
-
-            alarm.logMessage = rs.getString("logmsg");
-
-            alarm.operatorInstruction = rs.getString("OperInstruct");
-
-            alarm.troubleTicket = rs.getString("TTicketID");
-            
-            Integer stateCode = (Integer) rs.getObject("TTicketState");
-            for (TroubleTicketState state : TroubleTicketState.values()) {
-                if (stateCode != null && state.ordinal() == stateCode.intValue()) {
-                    alarm.troubleTicketState = state;
-                }
-            }
-
-            alarm.mouseOverText = rs.getString("MouseOverText");
-
-            Timestamp suppressedUntil = rs.getTimestamp("suppressedUntil");
-            if (suppressedUntil != null) {
-                alarm.suppressedUntil = new Date(suppressedUntil.getTime());
-            }
-
-            alarm.suppressedUser = rs.getString("suppressedUser");
-
-            Timestamp suppressedTime = rs.getTimestamp("suppressedTime");
-            if (suppressedTime != null) {
-                alarm.suppressedTime = new Date(suppressedTime.getTime());
-            }
-
-            alarm.acknowledgeUser = rs.getString("alarmAckUser");
-
-            Timestamp alarmAckTime = rs.getTimestamp("alarmAckTime");
-            if (alarmAckTime != null) {
-                alarm.acknowledgeTime = new Date(alarmAckTime.getTime());
-            }
-
-            alarm.nodeLabel = rs.getString("nodeLabel");
-
-            alarm.serviceName = rs.getString("serviceName");
-
-            vector.addElement(alarm);
-        }
-
-        return vector.toArray(new Alarm[vector.size()]);
-    }
-
-    /**
-     * Escalate a list of alarms using the given username and the current time
-     *
-     * @throws java.sql.SQLException if any.
-     * @param alarmIds an array of int.
-     * @param user a {@link java.lang.String} object.
-     */
-    public static void escalateAlarms(int[] alarmIds, String user) throws SQLException {
-    	escalateAlarms(alarmIds, user, new Date());
-    }
-    
-    /**
-     * Escalate a list of alarms.  The username and time are currently discarded, but
-     * are required for future use.
-     *
-     * @param alarmIds an array of int.
-     * @param user a {@link java.lang.String} object.
-     * @param time a java$util$Date object.
-     * @throws java.sql.SQLException if any.
-     */
-    public static void escalateAlarms(int[] alarmIds, String user, Date time) throws SQLException {
-        if (alarmIds == null || user == null || time == null) {
-            throw new IllegalArgumentException("Cannot take null parameters.");
-        }
-
-        if (alarmIds.length > 0) {
-            StringBuffer update = new StringBuffer("UPDATE ALARMS SET SEVERITY = (");
-            update.append("CASE WHEN SEVERITY =? THEN ?");
-            update.append(" ELSE (");
-            update.append("  CASE WHEN SEVERITY <? THEN SEVERITY + 1");
-            update.append("  ELSE ? END)");
-            update.append(" END),");
-            update.append(" ALARMTYPE =?");
-            update.append(" WHERE ALARMID IN (");
-            update.append(alarmIds[0]);
-
-            for (int i = 1; i < alarmIds.length; i++) {
-                update.append(",");
-                update.append(alarmIds[i]);
-            }
-
-            update.append(")");
-            update.append(" AND ( (");
-            update.append("  ALARMTYPE =? AND");
-            update.append("  SEVERITY =?");
-            update.append(" ) OR (");
-            update.append("  ALARMTYPE =? AND");
-            update.append("  SEVERITY >? AND");
-            update.append("  SEVERITY <=?");