/*
* The AlertDampeningEvents keep a running log of when all conditions have become true, as well as when they
* become untrue (if they were most recently known to be true)
*/
AlertDampeningEvent latestEvent = alertDampeningManager.getLatestEventByAlertDefinitionId(alertDefinitionId);
AlertDampeningEvent.Type type = getNextEventType(latestEvent, conditionSetResult);
if (log.isDebugEnabled()) {
log.debug("Latest event was " + latestEvent + ", " + "next AlertDampeningEvent.Type is " + type);
}
/*
* Finally, operate on the new type event
*/
if (type != AlertDampeningEvent.Type.UNCHANGED) {
/*
* But only if it represents a type of event we need to act on
*/
AlertDefinition flyWeightDefinition = new AlertDefinition();
flyWeightDefinition.setId(alertDefinitionId);
AlertDampeningEvent alertDampeningEvent = new AlertDampeningEvent(flyWeightDefinition, type);
entityManager.persist(alertDampeningEvent);
if (log.isDebugEnabled()) {
log.debug("Need to process AlertDampeningEvent.Type of " + type + " " + "for AlertDefinition[ id="
+ alertDefinitionId + " ]");