@Override
public void saveAlertDefinition() {
updated = false;
AlertDampening.Category cat = AlertDampening.Category.valueOf(dampeningRuleSelection.getValue().toString());
AlertDampening alertDampening = new AlertDampening(cat);
switch (cat) {
case NONE: {
// each time condition set is true
alertDampening.setValue(0);
alertDampening.setValueUnits(null);
alertDampening.setPeriod(0);
alertDampening.setPeriodUnits(null);
break;
}
case CONSECUTIVE_COUNT: {
// once every N times condition set is true consecutively
alertDampening.setValue(Integer.valueOf(consecutiveOccurrencesSpinner.getValue().toString()));
alertDampening.setValueUnits(null);
alertDampening.setPeriod(0);
alertDampening.setPeriodUnits(null);
break;
}
case PARTIAL_COUNT: {
// once every N times condition set is true during the last M evaluations
alertDampening.setValue(Integer.valueOf(partialOccurrencesSpinner.getValue().toString()));
alertDampening.setValueUnits(null);
alertDampening.setPeriod(Integer.valueOf(partialEvaluationsSpinner.getValue().toString()));
alertDampening.setPeriodUnits(null);
break;
}
case DURATION_COUNT: {
// once every N times condition set is true within a time period of M {mins, hours, days, weeks}
alertDampening.setValue(Integer.valueOf(durationOccurrencesSpinner.getValue().toString()));
alertDampening.setValueUnits(null);
alertDampening.setPeriod(Integer.valueOf(durationTimePeriodSpinner.getValue().toString()));
alertDampening.setPeriodUnits(TimeUnits.valueOf(durationTimeUnitsSelection.getValue().toString()));
break;
}
default: {
throw new IllegalStateException(MSG.view_alert_common_tab_invalid_dampening_category(cat.name())); // should never happen
}