AlertConditionOperator alertConditionOperator = AlertConditionCacheUtils
.getAlertConditionOperator(alertCondition);
if (DataType.CALLTIME == composite.getDataType()) { // call-time cases start here
if (alertConditionCategory == AlertConditionCategory.CHANGE) {
AlertConditionChangesCategoryComposite changesComposite = (AlertConditionChangesCategoryComposite) composite;
int scheduleId = changesComposite.getScheduleId();
try {
CallTimeDataCacheElement cacheElement = new CallTimeDataCacheElement(alertConditionOperator,
CallTimeElementValue.valueOf(alertCondition.getOption()), alertCondition.getComparator(),
alertCondition.getThreshold(), alertConditionId, alertCondition.getName());
addTo("callTimeDataCache", callTimeCache, scheduleId, cacheElement, alertConditionId, stats);
} catch (InvalidCacheElementException icee) {
log.info("Failed to create CallTimeDataCacheElement with parameters: "
+ AlertConditionCacheUtils.getCacheElementErrorString(alertConditionId, alertConditionOperator,
null, alertCondition.getThreshold(), icee));
}
} else if (alertConditionCategory == AlertConditionCategory.THRESHOLD) {
AlertConditionScheduleCategoryComposite thresholdComposite = (AlertConditionScheduleCategoryComposite) composite;
try {
CallTimeDataCacheElement cacheElement = new CallTimeDataCacheElement(alertConditionOperator,
CallTimeElementValue.valueOf(alertCondition.getOption()), null, alertCondition.getThreshold(),
alertConditionId, alertCondition.getName());
addTo("measurementDataCache", callTimeCache, thresholdComposite.getScheduleId(), cacheElement,
alertConditionId, stats);
} catch (InvalidCacheElementException icee) {
log.info("Failed to create CallTimeDataCacheElement with parameters: "
+ AlertConditionCacheUtils.getCacheElementErrorString(alertConditionId, alertConditionOperator,
null, alertCondition.getThreshold(), icee));
}
}// last call-time case
} else if (alertConditionCategory == AlertConditionCategory.BASELINE) { // normal cases start here
AlertConditionBaselineCategoryComposite baselineComposite = (AlertConditionBaselineCategoryComposite) composite;
// option status for baseline gets set to "mean", but it's rather useless since the UI
// current doesn't allow alerting off of other baseline properties such as "min" and "max"
Double threshold = alertCondition.getThreshold();
String optionStatus = alertCondition.getOption();
/*
* yes, calculatedValue may be null, but that's OK because the match
* method for MeasurementBaselineCacheElement handles nulls just fine
*/
Double calculatedValue = getCalculatedBaselineValue(alertConditionId, baselineComposite, optionStatus,
threshold);
try {
MeasurementBaselineCacheElement cacheElement = new MeasurementBaselineCacheElement(
alertConditionOperator, calculatedValue, alertConditionId, optionStatus);
// auto-boxing (of alertConditionId) is always safe
addTo("measurementDataCache", measurementDataCache, baselineComposite.getScheduleId(), cacheElement,
alertConditionId, stats);
} catch (InvalidCacheElementException icee) {
log.info("Failed to create MeasurementBaselineCacheElement with parameters: "
+ AlertConditionCacheUtils.getCacheElementErrorString(alertConditionId, alertConditionOperator,
null, calculatedValue, icee));
}
} else if (alertConditionCategory == AlertConditionCategory.CHANGE) {
AlertConditionChangesCategoryComposite changesComposite = (AlertConditionChangesCategoryComposite) composite;
int scheduleId = changesComposite.getScheduleId();
MeasurementDataNumeric numeric = measurementDataManager.getCurrentNumericForSchedule(scheduleId);
try {
MeasurementNumericCacheElement cacheElement = new MeasurementNumericCacheElement(