modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
| 49 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
| 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
| 224 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
| 2
4 files changed, 220 insertions(+), 63 deletions(-)
New commits:
commit f1599977fb315f35391f8b8c54babc40c5b062ea
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 17:08:19 2010 -0400
builds the conditions object and sets the new condition in the alert def
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 78261a3..7b85eae 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -111,7 +111,13 @@ public class ConditionsEditor extends LocatableVLayout {
});
NewConditionEditor newConditionEditor = new
NewConditionEditor(extendLocatorId("newConditionEditor"),
- conditions, ConditionsEditor.this.resourceType, winModal);
+ conditions, ConditionsEditor.this.resourceType, new Runnable() {
+ @Override
+ public void run() {
+ winModal.markForDestroy();
+ table.refresh();
+ }
+ });
winModal.addItem(newConditionEditor);
winModal.show();
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 7922824..bd20b0a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,13 +24,11 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.FormItemIfFunction;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
@@ -46,10 +44,12 @@ import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -57,42 +57,49 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class NewConditionEditor extends LocatableDynamicForm {
+ private static final String AVAILABILITY_ITEMNAME = "availability";
+ private static final String THRESHOLD_METRIC_ITEMNAME = "thresholdMetric";
+ private static final String THRESHOLD_COMPARATOR_ITEMNAME =
"thresholdComparator";
+ private static final String THRESHOLD_ABSVALUE_ITEMNAME =
"metricAbsoluteValue";
+ private static final String BASELINE_METRIC_ITEMNAME = "baselineMetric";
+ private static final String BASELINE_COMPARATOR_ITEMNAME =
"baselineComparator";
+ private static final String BASELINE_PERCENTAGE_ITEMNAME =
"baselinePercentage";
+ private static final String BASELINE_SELECTION_ITEMNAME =
"baselineSelection";
+ private static final String CHANGE_METRIC_ITEMNAME = "changeMetric";
+ private static final String TRAIT_METRIC_ITEMNAME = "trait";
+ private static final String OPERATION_NAME_ITEMNAME = "operation";
+ private static final String OPERATION_RESULTS_ITEMNAME =
"operationResults";
+ private static final String EVENT_SEVERITY_ITEMNAME = "eventSeverity";
+ private static final String EVENT_REGEX_ITEMNAME = "eventRegex";
+
private SelectItem conditionTypeSelectItem;
private HashSet<AlertCondition> conditions; // the new condition we create goes
into this set
- private Collection<String> metrics;
- private Collection<String> traits;
- private Collection<String> operations;
- private boolean supportsEvents;
- private Window parentWindow; // where this form is located; after form is OK'ed,
this window will be destroyed
+ private boolean supportsMetrics = false;
+ private boolean supportsTraits = false;
+ private boolean supportsOperations = false;
+ private boolean supportsEvents = false;
+ private Runnable okFunction; // this is called after the OK button is pressed and a
new condition is saved
+ private ResourceType resourceType;
- public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions,
ResourceType rtype, Window parent) {
+ public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions,
ResourceType rtype, Runnable okFunc) {
super(locatorId);
this.conditions = conditions;
- this.parentWindow = parent;
+ this.okFunction = okFunc;
+ this.resourceType = rtype;
this.supportsEvents = (rtype.getEventDefinitions() != null &
rtype.getEventDefinitions().size() > 0);
Set<MeasurementDefinition> metricDefinitions =
rtype.getMetricDefinitions();
- Set<OperationDefinition> operationDefinitions =
rtype.getOperationDefinitions();
- if (metricDefinitions == null || metricDefinitions.size() == 0) {
- this.metrics = null;
- this.traits = null;
- } else {
+ if (metricDefinitions != null && metricDefinitions.size() > 0) {
for (MeasurementDefinition measurementDefinition : metricDefinitions) {
switch (measurementDefinition.getDataType()) {
case MEASUREMENT: {
- if (this.metrics == null) {
- this.metrics = new ArrayList<String>();
- }
- this.metrics.add(measurementDefinition.getDisplayName());
+ this.supportsMetrics = true;
break;
}
case TRAIT: {
- if (this.traits == null) {
- this.traits = new ArrayList<String>();
- }
- this.traits.add(measurementDefinition.getDisplayName());
+ this.supportsTraits = true;
break;
}
default: {
@@ -102,13 +109,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
}
- if (operationDefinitions == null || operationDefinitions.size() == 0) {
- this.operations = null;
- } else {
- this.operations = new ArrayList<String>(operationDefinitions.size());
- for (OperationDefinition operationDefinition : operationDefinitions) {
- this.operations.add(operationDefinition.getDisplayName());
- }
+ Set<OperationDefinition> operationDefinitions =
rtype.getOperationDefinitions();
+ if (operationDefinitions != null && operationDefinitions.size() > 0)
{
+ this.supportsOperations = true;
}
}
@@ -121,15 +124,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
conditionTypeSelectItem = new SelectItem("conditionType",
"Condition Type");
LinkedHashMap<String, String> condTypes = new LinkedHashMap<String,
String>(7);
condTypes.put(AlertConditionCategory.AVAILABILITY.name(), "Availability
Change");
- if (metrics != null) {
+ if (supportsMetrics) {
condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement
Absolute Value Threshold");
condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement
Baseline Threshold");
condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value
Change");
}
- if (traits != null) {
+ if (supportsTraits) {
condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value
Change");
}
- if (operations != null) {
+ if (supportsOperations) {
condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation
Execution");
}
if (supportsEvents) {
@@ -152,8 +155,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
@Override
public void onClick(ClickEvent event) {
if (validate(false)) {
- // TODO
- NewConditionEditor.this.parentWindow.markForDestroy();
+ saveNewCondition();
+ okFunction.run();
}
}
});
@@ -162,15 +165,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(conditionTypeSelectItem);
formItems.add(spacer);
formItems.addAll(buildAvailabilityChangeFormItems());
- if (metrics != null) {
+ if (supportsMetrics) {
formItems.addAll(buildMetricThresholdFormItems());
formItems.addAll(buildMetricBaselineFormItems());
formItems.addAll(buildMetricChangeFormItems());
}
- if (traits != null) {
+ if (supportsTraits) {
formItems.addAll(buildTraitChangeFormItems());
}
- if (operations != null) {
+ if (supportsOperations) {
formItems.addAll(buildOperationFormItems());
}
if (supportsEvents) {
@@ -181,6 +184,90 @@ public class NewConditionEditor extends LocatableDynamicForm {
setFields(formItems.toArray(new FormItem[formItems.size()]));
};
+ private void saveNewCondition() {
+ AlertConditionCategory category;
+ category =
AlertConditionCategory.valueOf(conditionTypeSelectItem.getValue().toString());
+
+ AlertCondition newCondition = new AlertCondition();
+ newCondition.setCategory(category);
+
+ switch (category) {
+ case AVAILABILITY: {
+ newCondition.setName(null);
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(getValueAsString(AVAILABILITY_ITEMNAME));
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
+ case THRESHOLD: {
+ MeasurementDefinition measDef =
getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use
display name
+
newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
+ newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case BASELINE: {
+ MeasurementDefinition measDef =
getMeasurementDefinition(getValueAsString(BASELINE_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use
display name
+
newCondition.setThreshold(Double.valueOf(getValueAsString(BASELINE_PERCENTAGE_ITEMNAME)) /
100.0);
+ newCondition.setComparator(getValueAsString(BASELINE_COMPARATOR_ITEMNAME));
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case CHANGE: {
+ MeasurementDefinition measDef =
getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use
display name
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case TRAIT: {
+ MeasurementDefinition measDef =
getMeasurementDefinition(getValueAsString(TRAIT_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use
display name
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case CONTROL: {
+ newCondition.setName(getValueAsString(OPERATION_NAME_ITEMNAME));
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(getValueAsString(OPERATION_RESULTS_ITEMNAME));
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
+ case EVENT: {
+ newCondition.setName(getValueAsString(EVENT_SEVERITY_ITEMNAME));
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(getValueAsString(EVENT_REGEX_ITEMNAME));
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
+ default: {
+ CoreGUI.getErrorHandler().handleError("Invalid alert category selected:
" + category); // should never happen
+ break;
+ }
+ }
+
+ this.conditions.add(newCondition);
+ }
+
private ArrayList<FormItem> buildMetricThresholdFormItems() {
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
@@ -190,10 +277,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("thresholdHelp", helpStr,
ifFunc);
formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("thresholdMetric", ifFunc));
- formItems.add(buildComparatorDropDownMenu("thresholdComparator",
ifFunc));
-
- TextItem absoluteValue = new TextItem("metricAbsoluteValue",
"Metric Value");
+ formItems.add(buildMetricDropDownMenu(THRESHOLD_METRIC_ITEMNAME, ifFunc));
+ formItems.add(buildComparatorDropDownMenu(THRESHOLD_COMPARATOR_ITEMNAME,
ifFunc));
+ TextItem absoluteValue = new TextItem(THRESHOLD_ABSVALUE_ITEMNAME, "Metric
Value");
absoluteValue.setWrapTitle(false);
absoluteValue.setRequired(true);
absoluteValue
@@ -214,10 +300,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("baselineHelp", helpStr,
ifFunc);
formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("baselineMetric", ifFunc));
- formItems.add(buildComparatorDropDownMenu("baselineComparator",
ifFunc));
+ formItems.add(buildMetricDropDownMenu(BASELINE_METRIC_ITEMNAME, ifFunc));
+ formItems.add(buildComparatorDropDownMenu(BASELINE_COMPARATOR_ITEMNAME,
ifFunc));
- TextItem baselinePercentage = new TextItem("baselinePercentage",
"Baseline Percentage");
+ TextItem baselinePercentage = new TextItem(BASELINE_PERCENTAGE_ITEMNAME,
"Baseline Percentage");
baselinePercentage.setWrapTitle(false);
baselinePercentage.setRequired(true);
baselinePercentage
@@ -225,13 +311,13 @@ public class NewConditionEditor extends LocatableDynamicForm {
baselinePercentage.setShowIfCondition(ifFunc);
formItems.add(baselinePercentage);
- SelectItem baselineSelection = new SelectItem("baselineSelection",
"Baseline");
+ SelectItem baselineSelection = new SelectItem(BASELINE_SELECTION_ITEMNAME,
"Baseline");
LinkedHashMap<String, String> baselines = new LinkedHashMap<String,
String>(3);
- baselines.put("min", "Minimum"); // title should have the
current value of the min baseline
- baselines.put("avg", "Baseline"); // title should have the
current value of the avg baseline
- baselines.put("max", "Maximum"); // title should have the
current value of the max baseline
+ baselines.put("min", "Minimum"); // TODO can we have the
current value of the min baseline
+ baselines.put("mean", "Average"); // TODO can we have the
current value of the avg baseline
+ baselines.put("max", "Maximum"); // TODO can we have the
current value of the max baseline
baselineSelection.setValueMap(baselines);
- baselineSelection.setDefaultValue("avg");
+ baselineSelection.setDefaultValue("mean");
baselineSelection.setWrapTitle(false);
baselineSelection.setWidth("*");
baselineSelection.setRedrawOnChange(true);
@@ -250,7 +336,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("changeMetricHelp",
helpStr, ifFunc);
formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("changeMetric", ifFunc));
+ formItems.add(buildMetricDropDownMenu(CHANGE_METRIC_ITEMNAME, ifFunc));
return formItems;
}
@@ -265,11 +351,13 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(helpItem);
LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String,
String>();
- for (String traitName : this.traits) {
- traitsMap.put(traitName, traitName);
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (def.getDataType() == DataType.TRAIT) {
+ traitsMap.put(def.getName(), def.getDisplayName());
+ }
}
- SelectItem traitSelection = new SelectItem("trait",
"Trait");
+ SelectItem traitSelection = new SelectItem(TRAIT_METRIC_ITEMNAME,
"Trait");
traitSelection.setValueMap(traitsMap);
traitSelection.setDefaultValue(traitsMap.keySet().iterator().next()); // just use
the first one
traitSelection.setWidth("*");
@@ -289,7 +377,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("availabilityHelp",
helpStr, ifFunc);
formItems.add(helpItem);
- SelectItem selection = new SelectItem("availability",
"Availability");
+ SelectItem selection = new SelectItem(AVAILABILITY_ITEMNAME,
"Availability");
LinkedHashMap<String, String> avails = new LinkedHashMap<String,
String>(2);
avails.put(AvailabilityType.UP.name(), "Goes UP");
avails.put(AvailabilityType.DOWN.name(), "Goes DOWN");
@@ -311,11 +399,11 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(helpItem);
LinkedHashMap<String, String> ops = new LinkedHashMap<String,
String>();
- for (String opName : this.operations) {
- ops.put(opName, opName);
+ for (OperationDefinition opDef : this.resourceType.getOperationDefinitions()) {
+ ops.put(opDef.getName(), opDef.getDisplayName());
}
- SelectItem opSelection = new SelectItem("operation",
"Operation");
+ SelectItem opSelection = new SelectItem(OPERATION_NAME_ITEMNAME,
"Operation");
opSelection.setValueMap(ops);
opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the
first one
opSelection.setWidth("*");
@@ -323,7 +411,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
opSelection.setShowIfCondition(ifFunc);
formItems.add(opSelection);
- SelectItem opResultsSelection = new SelectItem("operationResults",
"Operation Status");
+ SelectItem opResultsSelection = new SelectItem(OPERATION_RESULTS_ITEMNAME,
"Operation Status");
LinkedHashMap<String, String> operationStatuses = new
LinkedHashMap<String, String>(4);
operationStatuses.put(OperationRequestStatus.INPROGRESS.name(),
OperationRequestStatus.INPROGRESS.name());
operationStatuses.put(OperationRequestStatus.SUCCESS.name(),
OperationRequestStatus.SUCCESS.name());
@@ -347,7 +435,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("eventHelp", helpStr,
ifFunc);
formItems.add(helpItem);
- SelectItem eventSeveritySelection = new SelectItem("eventSeverity",
"Event Severity");
+ SelectItem eventSeveritySelection = new SelectItem(EVENT_SEVERITY_ITEMNAME,
"Event Severity");
LinkedHashMap<String, String> severities = new LinkedHashMap<String,
String>(5);
severities.put(EventSeverity.DEBUG.name(), EventSeverity.DEBUG.name());
severities.put(EventSeverity.INFO.name(), EventSeverity.INFO.name());
@@ -360,7 +448,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
eventSeveritySelection.setShowIfCondition(ifFunc);
formItems.add(eventSeveritySelection);
- TextItem eventRegex = new TextItem("eventRegex", "Regular
Expression");
+ TextItem eventRegex = new TextItem(EVENT_REGEX_ITEMNAME, "Regular
Expression");
eventRegex.setRequired(false);
eventRegex
.setTooltip("If specified, this is a regular expression that must match
a collected event message in order to trigger the condition.");
@@ -374,8 +462,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction
ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String,
String>();
- for (String metricName : this.metrics) {
- metricsMap.put(metricName, metricName);
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (def.getDataType() == DataType.MEASUREMENT) {
+ metricsMap.put(def.getName(), def.getDisplayName());
+ }
}
SelectItem metricSelection = new SelectItem(itemName, "Metric");
@@ -413,6 +503,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
return help;
}
+ private MeasurementDefinition getMeasurementDefinition(String metricName) {
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (metricName.equals(def.getName())) {
+ return def;
+ }
+ }
+ CoreGUI.getErrorHandler().handleError("Should have found metric definition -
something is wrong");
+ return null;
+ }
+
private class ShowIfCategoryFunction implements FormItemIfFunction {
private final AlertConditionCategory category;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index 8269a8d..7cf6356 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -31,6 +31,7 @@ import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
@@ -117,6 +118,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
makeViewOnly();
// TODO getAlertDefinition() should now have the new user data - commit
it to DB
+ CoreGUI.refresh();
}
});
commit d0a76a4f3628d280bd861237869933dc126e235b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 15:23:41 2010 -0400
add javadoc omments to AlertCondition so its clear what the different fields should be
based on the different category semantics
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
index b54d58e..3218d9d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
@@ -47,7 +47,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationRequestStatus;
/**
* An alert condition (e.g. ActiveThreads > 100) as configured in an alert
definition.
@@ -366,6 +368,13 @@ public class AlertCondition implements Serializable {
this.category = category;
}
+ /**
+ * Identifies the measurement definition of the metric that is to be compared when
determining
+ * if the condition is true. This is null if the condition category is not a
metric-related one
+ * (metric related categories are THRESHOLD, TRAIT, BASELINE and CHANGE; others are
not).
+ *
+ * @return measurement definition or null
+ */
public MeasurementDefinition getMeasurementDefinition() {
return this.measurementDefinition;
}
@@ -374,6 +383,19 @@ public class AlertCondition implements Serializable {
this.measurementDefinition = measurementDefinition;
}
+ /**
+ * The name of the condition whose semantics are different based on this
condition's category:
+ *
+ * AVAILABILITY: n/a (null)
+ * THRESHOLD: the name of the metric (TODO: today its the display name, very bad for
i18n purposes)
+ * BASELINE: the name of the metric (TODO: today its the display name, very bad for
i18n purposes)
+ * CHANGE: the name of the metric (TODO: today its the display name, very bad for
i18n purposes)
+ * TRAIT: the name of the trait (TODO: today its the display name, very bad for i18n
purposes)
+ * CONTROL: the name of the operation (not its display name)
+ * EVENT: the level of event to compare with (DEBUG, INFO, WARN, ERROR, FATAL)
+ *
+ * @return additional information about the condition
+ */
public String getName() {
return this.name;
}
@@ -382,6 +404,14 @@ public class AlertCondition implements Serializable {
this.name = name;
}
+ /**
+ * One of these comparators: "<", ">" or "=".
+ * This will be null if the condition does not compare values. Only THRESHOLD
+ * and BASELINE condition categories use comparators; other types of conditions
+ * will return <code>null</code>.
+ *
+ * @return comparator string
+ */
public String getComparator() {
return this.comparator;
}
@@ -390,6 +420,13 @@ public class AlertCondition implements Serializable {
this.comparator = comparator;
}
+ /**
+ * Returns the threshold to compare a measurement value to see if the condition is
true.
+ * This is only valid for conditions of category THRESHOLD and BASELINE. All other
+ * condition types will return <code>null</code>.
+ *
+ * @return threshold value or null
+ */
public Double getThreshold() {
return this.threshold;
}
@@ -398,6 +435,18 @@ public class AlertCondition implements Serializable {
this.threshold = threshold;
}
+ /**
+ * The option string is optional and its semantics differ based on the category of
this condition:
+ * AVAILABILITY: the {@link AvailabilityType} to trigger off of (DOWN or UP)
+ * THRESHOLD: n/a
+ * BASELINE: one of "min", "max" or "mean" - indicates
what the threshold is compared to (min/max/avg baseline value)
+ * CHANGE: n/a
+ * TRAIT: n/a
+ * CONTROL: the {@link OperationRequestStatus} name (SUCCESS, FAILURE, etc).
+ * EVENT: the regular expression of the message to match (which may be empty string
if not specified)
+ *
+ * @return additional information about the condition
+ */
public String getOption() {
return this.option;
}