Description of problem: Allow filtering of recent alerts with the following choices: - Acknowledged alerts - Recovery alerts - Alerts that have recovered Also show new column "Recovered" which indicates if the alerts has recovered or not. The last one requires a change to domain model also, and to alert firing.
Created attachment 815572 [details] Adds filters and recovered status to RecentAlertsView and REST-interface. The following patch should work with the exception of Reports/RecentAlerts (the filters are available there, but for some reason they don't work). What I'd need is input on did I approach this issue correctly and if the UI changes should be modified?
+ @NamedQuery(name = Alert.QUERY_MARK_RECOVERED_BY_DEFINITION_ID, query = "" // + + "UPDATE Alert AS alert " // + + " SET alert.recoveryTime = :recoveryTime " // + + "WHERE alert.id IN ( SELECT innerA.id " // + + " FROM AlertDefinition AS ad " // + + " JOIN ad.alerts AS innerA " // + + " WHERE ad.id = :alertDefinitionId )" + + " AND alert.ctime < :recoveryTime " // + + " AND alert.willRecover = true " // + + " AND alert.recoveryTime < 0" // don't process again The way I ack'ed in Bug 1030667 was to do: AlertDefinition rdef = getRecovered(def); log.debug("find existing alerts for " + rdef); for (Alert old : rdef.getAlerts()) { ack(old); } private void ack(Alert alert) { if (alert.getAcknowledgingSubject() == null) { alert.setAcknowledgeTime(System.currentTimeMillis()); String name = getSubject(); alert.setAcknowledgingSubject(name); log.debug("ack " + alert); } } Basically I just use Hibernate to find all the alerts for the definition, iterate, and if the ack subject is null, then update. This seems simpler than using an update query, though maybe not quite as scalable. (In practice, I don't think you'll have thousands of alerts for one definition, I hope.) I don't see why you do recoveryTime < 0 when you could do 'recoveryTime is null', since it's not obvious that 'null < 0' .
The recoverytime is actually a bigint/long in the database, like the ack_time (which structure I copied), so it's never null.
Assigning this to myself for potential inclusion... No target yet.
On master: commit 65994bb1ae5d6475ceea937206f75a3a39143a66 Author: burmanm <miburman> Date: Mon Jul 14 14:58:42 2014 +0300 [BZ 1003211] Adds automatic recovery information to the alerts if there's a recovery alert fired. [BZ 1003211] Add hovering support, and also add naming filter to the reports & REST interface
*** Bug 1030667 has been marked as a duplicate of this bug. ***