Examples of AlertConditionCategory


Examples of org.rhq.core.domain.alert.AlertConditionCategory

    }

    public static String formatAlertConditionForDisplay(AlertCondition condition) {
        StringBuilder str = new StringBuilder();

        AlertConditionCategory category = condition.getCategory();
        switch (category) {
        case AVAILABILITY: {
            str.append(MSG.common_title_availability());
            str.append(" [");
            AlertConditionOperator operator = AlertConditionOperator.valueOf(condition.getName().toUpperCase());
            switch (operator) {
            case AVAIL_GOES_DISABLED:
                str.append(MSG.view_alert_definition_condition_editor_operator_availability_goesDisabled());
                break;
            case AVAIL_GOES_DOWN:
                str.append(MSG.view_alert_definition_condition_editor_operator_availability_goesDown());
                break;
            case AVAIL_GOES_UNKNOWN:
                str.append(MSG.view_alert_definition_condition_editor_operator_availability_goesUnknown());
                break;
            case AVAIL_GOES_UP:
                str.append(MSG.view_alert_definition_condition_editor_operator_availability_goesUp());
                break;
            case AVAIL_GOES_NOT_UP:
                str.append(MSG.view_alert_definition_condition_editor_operator_availability_goesNotUp());
                break;
            default:
                str.append("*ERROR*");
            }
            str.append("]");

            break;
        }
        case AVAIL_DURATION: {
            str.append(MSG.view_alert_definition_condition_editor_availabilityDuration());
            str.append(" [");
            AlertConditionOperator operator = AlertConditionOperator.valueOf(condition.getName().toUpperCase());
            switch (operator) {
            case AVAIL_DURATION_DOWN:
                str.append(MSG.view_alert_definition_condition_editor_operator_availability_durationDown());
                break;
            case AVAIL_DURATION_NOT_UP:
                str.append(MSG.view_alert_definition_condition_editor_operator_availability_durationNotUp());
                break;
            default:
                str.append("*ERROR*");
            }
            str.append(" For ");

            long longValue = Long.valueOf(condition.getOption());
            MeasurementNumericValueAndUnits valueWithUnits;
            if (longValue % 3600 == 0) {
                if (longValue == 3600) {
                    valueWithUnits = new MeasurementNumericValueAndUnits(1.0d, MeasurementUnits.HOURS);
                } else {
                    valueWithUnits = MeasurementConverterClient.fit((double) longValue, MeasurementUnits.SECONDS,
                        MeasurementUnits.HOURS, MeasurementUnits.HOURS);
                }
            } else if (longValue == 60) {
                valueWithUnits = new MeasurementNumericValueAndUnits(1.0d, MeasurementUnits.MINUTES);
            } else {
                valueWithUnits = MeasurementConverterClient.fit((double) longValue, MeasurementUnits.SECONDS,
                        MeasurementUnits.MINUTES, MeasurementUnits.MINUTES);
            }
            String formatted = MeasurementConverterClient.format(String.valueOf(valueWithUnits.getValue()),
                valueWithUnits.getUnits());
            str.append(formatted);
            str.append("]");

            break;
        }
        case THRESHOLD: {
            double value = condition.getThreshold();
            MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
            String formatted = MeasurementConverterClient.format(value, units, true);

            if (condition.getOption() == null) {
                str.append(MSG.view_alert_common_tab_conditions_type_metric_threshold());
                str.append(" [");
                str.append(condition.getName());
                str.append(" ");
                str.append(condition.getComparator());
                str.append(" ");
                str.append(formatted);
                str.append("]");
            } else {
                // this is a calltime threshold condition
                str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_threshold());
                str.append(" [");
                if (condition.getMeasurementDefinition() != null) {
                    str.append(condition.getMeasurementDefinition().getDisplayName());
                    str.append(" ");
                }
                str.append(condition.getOption()); // MIN, MAX, AVG (never null)
                str.append(" ");
                str.append(condition.getComparator()); // <, >, =
                str.append(" ");
                str.append(formatted);
                str.append("]");
                if (condition.getName() != null && condition.getName().length() > 0) {
                    str.append(" ");
                    str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_destination());
                    str.append(" '");
                    str.append(condition.getName());
                    str.append("'");
                }
            }
            break;
        }
        case BASELINE: {
            str.append(MSG.view_alert_common_tab_conditions_type_metric_baseline());
            str.append(" [");
            str.append(condition.getName());
            str.append(" ");
            str.append(condition.getComparator());
            str.append(" ");

            double value = condition.getThreshold();
            MeasurementUnits units = MeasurementUnits.PERCENTAGE;
            String formatted = MeasurementConverterClient.format(value, units, true);
            str.append(formatted);

            str.append(" ").append(MSG.view_alert_common_tab_conditions_type_metric_baseline_verb()).append(" ");
            str.append(condition.getOption());
            str.append("]");
            break;
        }
        case CHANGE: {
            if (condition.getOption() == null) {
                str.append(MSG.view_alert_common_tab_conditions_type_metric_change());
                str.append(" [");
                str.append(condition.getName());
                str.append("]");
            } else {
                // this is a calltime change condition
                str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_change());
                str.append(" [");
                if (condition.getMeasurementDefinition() != null) {
                    str.append(condition.getMeasurementDefinition().getDisplayName());
                    str.append(" ");
                }
                str.append(condition.getOption()); // MIN, MAX, AVG (never null)
                str.append(" ");
                str.append(getCalltimeChangeComparator(condition.getComparator())); // LO, HI, CH
                str.append(" ");
                str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_change_verb());
                str.append(" ");

                double value = condition.getThreshold();
                MeasurementUnits units = MeasurementUnits.PERCENTAGE;
                String formatted = MeasurementConverterClient.format(value, units, true);
                str.append(formatted);

                str.append("]");
                if (condition.getName() != null && condition.getName().length() > 0) {
                    str.append(" ");
                    str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_destination());
                    str.append(" '");
                    str.append(condition.getName());
                    str.append("'");
                }
            }
            break;
        }
        case TRAIT: {
            str.append(MSG.view_alert_common_tab_conditions_type_metric_trait_change());
            str.append(" [");
            str.append(condition.getName());
            str.append("]");
            if (condition.getOption() != null && condition.getOption().length() > 0) {
                str.append(" ");
                str.append(MSG.view_alert_common_tab_conditions_type_metric_trait_matching());
                str.append(" '");
                str.append(condition.getOption());
                str.append("'");
            }

            break;
        }
        case CONTROL: {
            str.append(MSG.view_alert_common_tab_conditions_type_operation());
            str.append(" [");
            str.append(condition.getName());
            str.append("] ");
            str.append(MSG.view_alert_common_tab_conditions_type_operation_status());
            str.append(" [");
            str.append(condition.getOption());
            str.append("]");
            break;
        }
        case RESOURCE_CONFIG: {
            str.append(MSG.view_alert_common_tab_conditions_type_resource_configuration());
            break;
        }
        case EVENT: {
            str.append(MSG.view_alert_common_tab_conditions_type_event());
            str.append(" [");
            str.append(condition.getName());
            str.append("]");
            if (condition.getOption() != null && condition.getOption().length() > 0) {
                String eventDetailsRegexValue = "", eventSourcePathRegexValue = "";
                if (condition.getOption().contains(AlertCondition.ADHOC_SEPARATOR)) {
                    String[] regexes = condition.getOption().split(AlertCondition.ADHOC_SEPARATOR);
                    if (regexes.length > 0) {
                        eventDetailsRegexValue = regexes[0];
                        if (regexes.length > 1) {
                            eventSourcePathRegexValue = regexes[1];
                        }
                    }
                } else {
                    eventDetailsRegexValue = condition.getOption(); // old approach -> probably working with db before rhq 4.13
                }
                if (!eventSourcePathRegexValue.isEmpty()) {
                    str.append(" ");
                    str.append(MSG.view_alert_common_tab_conditions_type_event_matching());
                    str.append(" '");
                    str.append(eventSourcePathRegexValue);
                    str.append("'");
                }
                if (!eventDetailsRegexValue.isEmpty()) {
                    str.append(" ");
                    str.append(MSG.view_alert_common_tab_conditions_type_event_details_matching());
                    str.append(" '");
                    str.append(eventDetailsRegexValue);
                    str.append("'");
                }
            }
            break;
        }
        case DRIFT: {
            String configNameRegex = condition.getName();
            String pathNameRegex = condition.getOption();
            if (configNameRegex == null || configNameRegex.length() == 0) {
                if (pathNameRegex == null || pathNameRegex.length() == 0) {
                    // neither a config name regex nor path regex was specified
                    str.append(MSG.view_alert_common_tab_conditions_type_drift());
                } else {
                    // a path name regex was specified, but not a config name regex
                    str.append(MSG.view_alert_common_tab_conditions_type_drift_onlypaths(pathNameRegex));
                }
            } else {
                if (pathNameRegex == null || pathNameRegex.length() == 0) {
                    // a config name regex was specified, but not a path name regex
                    str.append(MSG.view_alert_common_tab_conditions_type_drift_onlyconfig(configNameRegex));
                } else {
                    // both a config name regex and a path regex was specified
                    str.append(MSG.view_alert_common_tab_conditions_type_drift_configpaths(pathNameRegex,
                        configNameRegex));
                }
            }
            break;
        }
        case RANGE: {
            String metricName = condition.getName();
            MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
            double loValue = condition.getThreshold();
            String formattedLoValue = MeasurementConverterClient.format(loValue, units, true);
            String formattedHiValue = condition.getOption();
            try {
                double hiValue = Double.parseDouble(formattedHiValue);
                formattedHiValue = MeasurementConverterClient.format(hiValue, units, true);
            } catch (Exception e) {
                formattedHiValue = "?[" + formattedHiValue + "]?"; // signify something is wrong with the value
            }

            // < means "inside the range", > means "outside the range" - exclusive
            // <= means "inside the range", >= means "outside the range" - inclusive

            if (condition.getComparator().equals("<")) {
                str.append(MSG.view_alert_common_tab_conditions_type_metric_range_inside_exclusive(metricName,
                    formattedLoValue, formattedHiValue));
            } else if (condition.getComparator().equals(">")) {
                str.append(MSG.view_alert_common_tab_conditions_type_metric_range_outside_exclusive(metricName,
                    formattedLoValue, formattedHiValue));
            } else if (condition.getComparator().equals("<=")) {
                str.append(MSG.view_alert_common_tab_conditions_type_metric_range_inside_inclusive(metricName,
                    formattedLoValue, formattedHiValue));
            } else if (condition.getComparator().equals(">=")) {
                str.append(MSG.view_alert_common_tab_conditions_type_metric_range_outside_inclusive(metricName,
                    formattedLoValue, formattedHiValue));
            } else {
                str.append("BAD COMPARATOR! Report this bug: " + condition.getComparator());
            }
            break;
        }
        default: {
            str.append(MSG.view_alert_common_tab_invalid_condition_category(category.name()));
            break;
        }
        }
        return str.toString();
    }
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertConditionCategory

    }

    private String prettyPrintAlertCondition(AlertCondition condition, boolean isShort) {
        StringBuilder str = new StringBuilder();

        AlertConditionCategory category = condition.getCategory();
        switch (category) {
        case AVAILABILITY: {
            AlertConditionOperator operator = AlertConditionOperator.valueOf(condition.getName().toUpperCase());
            String msg;
            switch (operator) {
            case AVAIL_GOES_DISABLED:
                msg = isShort ? AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_DISABLED_SHORT
                    : AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_DISABLED;
                break;
            case AVAIL_GOES_DOWN:
                msg = isShort ? AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_DOWN_SHORT
                    : AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_DOWN;
                break;
            case AVAIL_GOES_UNKNOWN:
                msg = isShort ? AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_UNKNOWN_SHORT
                    : AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_UNKNOWN;
                break;
            case AVAIL_GOES_UP:
                msg = isShort ? AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_UP_SHORT
                    : AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_UP;
                break;
            case AVAIL_GOES_NOT_UP:
            default:
                msg = isShort ? AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_NOT_UP_SHORT
                    : AlertI18NResourceKeys.ALERT_AVAILABILITY_GOES_NOT_UP;
                break;
            }
            str.append(AlertI18NFactory.getMessage(msg));

            break;
        }

        case AVAIL_DURATION: {
            AlertConditionOperator operator = AlertConditionOperator.valueOf(condition.getName().toUpperCase());
            String msg;
            switch (operator) {
            case AVAIL_DURATION_DOWN:
                msg = isShort ? AlertI18NResourceKeys.ALERT_AVAILABILITY_DURATION_DOWN_SHORT
                    : AlertI18NResourceKeys.ALERT_AVAILABILITY_DURATION_DOWN;
                break;
            case AVAIL_DURATION_NOT_UP:
            default:
                msg = isShort ? AlertI18NResourceKeys.ALERT_AVAILABILITY_DURATION_NOT_UP_SHORT
                    : AlertI18NResourceKeys.ALERT_AVAILABILITY_DURATION_NOT_UP;
                break;
            }
            str.append(AlertI18NFactory.getMessage(msg));
            str.append(" [");

            // stored in seconds but present in minutes
            String value = String.valueOf(Integer.valueOf(condition.getOption()) / 60);
            String formatted = MeasurementConverter.format(value, MeasurementUnits.MINUTES);
            str.append(formatted);
            str.append("]");

            break;
        }

        case THRESHOLD: {
            double value = condition.getThreshold();
            MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
            String formatted = MeasurementConverter.format(value, units, true);

            if (condition.getOption() == null) {
                String metricName = condition.getName();
                String comparator = condition.getComparator();
                str.append(metricName).append(' ').append(comparator).append(' ').append(formatted);
            } else {
                // this is a calltime threshold condition
                String metricName = "";
                if (condition.getMeasurementDefinition() != null) {
                    metricName = condition.getMeasurementDefinition().getDisplayName();
                }

                String limit = condition.getOption(); // MIN, MAX, AVG (never null)
                String comparator = condition.getComparator(); // <, >, =

                if (condition.getName() != null && condition.getName().length() > 0) {
                    String regex = condition.getName();
                    if (isShort) {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_THRESHOLD_WITH_EXPR_SHORT, metricName, limit,
                            comparator, formatted, regex));
                    } else {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_THRESHOLD_WITH_EXPR, metricName, limit,
                            comparator, formatted, regex));
                    }
                } else {
                    if (isShort) {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_THRESHOLD_SHORT, metricName, limit, comparator,
                            formatted));
                    } else {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_THRESHOLD,
                            metricName, limit, comparator, formatted));
                    }
                }
            }
            break;
        }
        case BASELINE: {
            String metricName = condition.getName();
            String comparator = condition.getComparator();
            double value = condition.getThreshold();
            MeasurementUnits units = MeasurementUnits.PERCENTAGE;
            String percentage = MeasurementConverter.format(value, units, true);
            String baselineThreshold = condition.getOption(); // mean, min, max

            if (isShort) {
                if (baselineThreshold.equalsIgnoreCase("min")) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MIN_SHORT, metricName,
                        comparator, percentage));
                } else if (baselineThreshold.equalsIgnoreCase("max")) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MAX_SHORT, metricName,
                        comparator, percentage));
                } else { // mean
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MEAN_SHORT, metricName,
                        comparator, percentage));
                }
            } else {
                if (baselineThreshold.equalsIgnoreCase("min")) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MIN, metricName,
                        comparator, percentage));
                } else if (baselineThreshold.equalsIgnoreCase("max")) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MAX, metricName,
                        comparator, percentage));
                } else { // mean
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_BASELINE_MEAN, metricName,
                        comparator, percentage));
                }
            }
            break;
        }
        case CHANGE: {
            if (condition.getOption() == null) {
                String metricName = condition.getName();
                if (isShort) {
                    str.append(AlertI18NFactory
                        .getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_SHORT, metricName));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED, metricName));
                }
            } else {
                // this is a calltime change condition
                double value = condition.getThreshold();
                MeasurementUnits units = MeasurementUnits.PERCENTAGE;
                String formatted = MeasurementConverter.format(value, units, true);

                String comparator;
                if ("HI".equalsIgnoreCase(condition.getComparator())) {
                    comparator = AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_GROWS);
                } else if ("LO".equalsIgnoreCase(condition.getComparator())) {
                    comparator = AlertI18NFactory
                        .getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_SHRINKS);
                } else { // CH
                    comparator = AlertI18NFactory
                        .getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_CHANGES);
                }

                String metricName = "";
                if (condition.getMeasurementDefinition() != null) {
                    metricName = condition.getMeasurementDefinition().getDisplayName();
                }

                String limit = condition.getOption(); // MIN, MAX, AVG (never null)

                if (condition.getName() != null && condition.getName().length() > 0) {
                    String regex = condition.getName();
                    if (isShort) {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_WITH_EXPR_SHORT, metricName, limit,
                            comparator, formatted, regex));
                    } else {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_WITH_EXPR, metricName, limit,
                            comparator, formatted, regex));
                    }
                } else {
                    if (isShort) {
                        str.append(AlertI18NFactory.getMessage(
                            AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE_SHORT, metricName, limit, comparator,
                            formatted));
                    } else {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CALLTIME_CHANGE,
                            metricName, limit, comparator, formatted));
                    }
                }
            }
            break;
        }
        case TRAIT: {
            String metricName = condition.getName();
            String expression = condition.getOption();

            if (expression != null && !expression.isEmpty()) {
                if (isShort) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_WITH_EXPR_SHORT,
                        metricName, expression));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_WITH_EXPR,
                        metricName, expression));
                }
            } else {
                if (isShort) {
                    str.append(AlertI18NFactory
                        .getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED_SHORT, metricName));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_METRIC_CHANGED, metricName));
                }
            }
            break;
        }
        case CONTROL: {
            String opName;
            try {
                Integer resourceTypeId = condition.getAlertDefinition().getResource().getResourceType().getId();
                String operationName = condition.getName();

                OperationDefinition definition = operationManager.getOperationDefinitionByResourceTypeAndName(
                    resourceTypeId, operationName, false);
                opName = definition.getDisplayName();
            } catch (Exception e) {
                opName = condition.getName(); // can't look up the op display name (are we in a test?), just use the op name
            }

            String status = condition.getOption();
            if (isShort) {
                str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_OPERATION_SHORT, opName, status));
            } else {
                str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_OPERATION, opName, status));
            }

            break;
        }
        case RESOURCE_CONFIG: {
            if (isShort) {
                str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RESOURCECONFIGCHANGE_SHORT));
            } else {
                str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RESOURCECONFIGCHANGE));
            }
            break;
        }
        case EVENT: {
            String severity = condition.getName();
            if (condition.getOption() != null && condition.getOption().length() > 0) {
                String expression = condition.getOption();
                String regexEventDetails = "", regexSourceLocation = "";
                if (expression.contains(AlertCondition.ADHOC_SEPARATOR)) {
                    String[] regexes = expression.split(AlertCondition.ADHOC_SEPARATOR);
                    if (regexes.length > 0) {
                        regexEventDetails = regexes[0];
                        if (regexes.length > 1) {
                            regexSourceLocation = regexes[1];
                        }
                    }
                } else {
                    regexEventDetails = expression; // old approach -> probably working with db before rhq 4.13
                }

                if (isShort) {
                    if (!regexEventDetails.isEmpty()) {
                        if (!regexSourceLocation.isEmpty()) {
                            str.append(AlertI18NFactory.getMessage(
                                AlertI18NResourceKeys.ALERT_EVENT_WITH_EXPR_WITH_SOURCE_SHORT, severity,
                                regexEventDetails, regexSourceLocation));
                        } else {
                            str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_WITH_EXPR_SHORT,
                                severity, regexEventDetails));
                        }
                    } else if (!regexSourceLocation.isEmpty()) {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_WITH_SOURCE_SHORT,
                            severity, regexSourceLocation));
                    } else {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_SHORT, severity));
                    }
                } else {
                    if (!regexEventDetails.isEmpty()) {
                        if (!regexSourceLocation.isEmpty()) {
                            str.append(AlertI18NFactory.getMessage(
                                AlertI18NResourceKeys.ALERT_EVENT_WITH_EXPR_WITH_SOURCE, severity, regexEventDetails,
                                regexSourceLocation));
                        } else {
                            str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_WITH_EXPR,
                                severity, regexEventDetails));
                        }
                    } else if (!regexSourceLocation.isEmpty()) {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_WITH_SOURCE, severity,
                            regexSourceLocation));
                    } else {
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT, severity));
                    }
                }
            } else {
                if (isShort) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT_SHORT, severity));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_EVENT, severity));
                }
            }
            break;
        }
        case DRIFT: {
            String configNameRegex = condition.getName();
            String pathNameRegex = condition.getOption();
            if (isShort) {
                if (configNameRegex == null || configNameRegex.length() == 0) {
                    if (pathNameRegex == null || pathNameRegex.length() == 0) {
                        // neither a config name regex nor path regex was specified
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_SHORT));
                    } else {
                        // a path name regex was specified, but not a config name regex
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_ONLYPATHS_SHORT,
                            pathNameRegex));
                    }
                } else {
                    if (pathNameRegex == null || pathNameRegex.length() == 0) {
                        // a config name regex was specified, but not a path name regex
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_ONLYCONFIG_SHORT,
                            configNameRegex));
                    } else {
                        // both a config name regex and a path regex was specified
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_CONFIGPATHS_SHORT,
                            pathNameRegex, configNameRegex));
                    }
                }
            } else {
                if (configNameRegex == null || configNameRegex.length() == 0) {
                    if (pathNameRegex == null || pathNameRegex.length() == 0) {
                        // neither a config name regex nor path regex was specified
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT));
                    } else {
                        // a path name regex was specified, but not a config name regex
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_ONLYPATHS,
                            pathNameRegex));
                    }
                } else {
                    if (pathNameRegex == null || pathNameRegex.length() == 0) {
                        // a config name regex was specified, but not a path name regex
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_ONLYCONFIG,
                            configNameRegex));
                    } else {
                        // both a config name regex and a path regex was specified
                        str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_DRIFT_CONFIGPATHS,
                            pathNameRegex, configNameRegex));
                    }
                }
            }
            break;
        }
        case RANGE: {
            String metricName = condition.getName();
            Double loValue = condition.getThreshold();
            String hiValueStr = condition.getOption();

            String loValueFormatted;
            String hiValueFormatted;
            MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
            if (units == null) {
                loValueFormatted = "" + loValue;
                hiValueFormatted = hiValueStr;
            } else {
                loValueFormatted = MeasurementConverter.format(loValue, units, true);
                try {
                    hiValueFormatted = MeasurementConverter.format(Double.parseDouble(hiValueStr), units, true);
                } catch (Exception e) {
                    hiValueFormatted = "?[" + hiValueStr + "]?";
                }
            }

            // < means "inside the range", > means "outside the range" - exclusive
            // <= means "inside the range", >= means "outside the range" - inclusive

            if ("<".equals(condition.getComparator())) {
                if (isShort) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RANGE_INSIDE_EXCL_SHORT,
                        metricName, loValueFormatted, hiValueFormatted));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RANGE_INSIDE_EXCL, metricName,
                        loValueFormatted, hiValueFormatted));
                }
            } else if (">".equals(condition.getComparator())) {
                if (isShort) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RANGE_OUTSIDE_EXCL_SHORT,
                        metricName, loValueFormatted, hiValueFormatted));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RANGE_OUTSIDE_EXCL, metricName,
                        loValueFormatted, hiValueFormatted));
                }
            } else if ("<=".equals(condition.getComparator())) {
                if (isShort) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RANGE_INSIDE_INCL_SHORT,
                        metricName, loValueFormatted, hiValueFormatted));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RANGE_INSIDE_INCL, metricName,
                        loValueFormatted, hiValueFormatted));
                }
            } else if (">=".equals(condition.getComparator())) {
                if (isShort) {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RANGE_OUTSIDE_INCL_SHORT,
                        metricName, loValueFormatted, hiValueFormatted));
                } else {
                    str.append(AlertI18NFactory.getMessage(AlertI18NResourceKeys.ALERT_RANGE_OUTSIDE_INCL, metricName,
                        loValueFormatted, hiValueFormatted));
                }
            } else {
                str.append("invalid range comparator [" + condition.getComparator() + "] (" + loValueFormatted + ","
                    + hiValueFormatted + ")");
            }

            break;
        }
        default: {
            str.append("unknown category [" + category.name() + "]");
            break;
        }
        }

        return str.toString();
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertConditionCategory

        if (alertDefinition.getDescription() != null && alertDefinition.getDescription().length() > 250) {
            alertDefinition.setDescription(alertDefinition.getDescription().substring(0, 250));
        }

        for (AlertCondition alertCondition : alertDefinition.getConditions()) {
            AlertConditionCategory alertConditionCategory = alertCondition.getCategory();
            if (alertConditionCategory == AlertConditionCategory.ALERT) {
                throw new InvalidAlertDefinitionException(
                    "AlertDefinitionManager does not yet support condition category: " + alertConditionCategory);
            }
            if (alertConditionCategory == AlertConditionCategory.BASELINE) {
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertConditionCategory

            String resourceFilter = getResourceFilter();
            String parentFilter = getParentFilter();
            Long startMillis = getDateBeginFilter() == null ? null : getDateBeginFilter().getTime();
            Long endMillis = getDateEndFilter() == null ? null : getDateEndFilter().getTime();
            String cleansedStatus = SelectItemUtils.cleanse(getCategoryFilter());
            AlertConditionCategory category = cleansedStatus == null ? null : AlertConditionCategory
                .valueOf(cleansedStatus);

            PageList<AlertDefinitionComposite> result;
            result = manager.getAlertDefinitions(getSubject(), resourceFilter, parentFilter, startMillis, endMillis,
                category, pc);
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertConditionCategory

            String resourceFilter = getResourceFilter();
            String parentFilter = getParentFilter();
            Long startMillis = getDateBeginFilter() == null ? null : getDateBeginFilter().getTime();
            Long endMillis = getDateEndFilter() == null ? null : getDateEndFilter().getTime();
            String cleansedStatus = SelectItemUtils.cleanse(getCategoryFilter());
            AlertConditionCategory category = cleansedStatus == null ? null : AlertConditionCategory
                .valueOf(cleansedStatus);

            PageList<AlertHistoryComposite> result;
            result = manager.getAlertHistories(getSubject(), resourceFilter, parentFilter, startMillis, endMillis,
                category, pc);
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertConditionCategory

                return conditionText;
            }

            private String formatCondition(AlertCondition condition) {
                StringBuilder builder = new StringBuilder();
                AlertConditionCategory category = condition.getCategory();
                AlertConditionOperator operator;
                String formattedThreshold;

                switch (category) {
                    case AVAILABILITY:
                        builder.append("Availability [");
                        operator = AlertConditionOperator.valueOf(condition.getName().toUpperCase());
                        switch (operator) {
                            case AVAIL_GOES_DISABLED:
                                builder.append("Goes disabled");
                                break;
                            case AVAIL_GOES_DOWN:
                                builder.append("Goes down");
                                break;
                            case AVAIL_GOES_UNKNOWN:
                                builder.append("Goes unknown");
                                break;
                            case AVAIL_GOES_UP:
                                builder.append("Goes up");
                                break;
                            case AVAIL_GOES_NOT_UP:
                                builder.append("Goes not up");
                                break;
                            default:
                                builder.append("*ERROR*");
                        }
                        builder.append("]");
                        break;
                    case AVAIL_DURATION:
                        builder.append("Availability Duration [");
                        operator = AlertConditionOperator.valueOf(condition.getName().toUpperCase());
                        switch (operator) {
                            case AVAIL_DURATION_DOWN:
                                builder.append("Stays Down");
                                break;
                            case AVAIL_DURATION_NOT_UP:
                                builder.append("Stays Not Up");
                                break;
                            default:
                                builder.append("*ERROR*");
                        }
                        builder.append(" For ");

                        String value = String.valueOf(Integer.valueOf(condition.getOption()) / 60);
                        String formatted = MeasurementConverter.format(value, MeasurementUnits.MINUTES);

                        builder.append(formatted).append("]");
                        break;
                    case THRESHOLD:
                        MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
                        formattedThreshold = MeasurementConverter.format(condition.getThreshold(), units, true);

                        if (condition.getOption() == null) {
                            builder.append("Metric Value Threshold [")
                                .append(condition.getName())
                                .append(" ")
                                .append(condition.getComparator())
                                .append(" ")
                                .append(formattedThreshold)
                                .append("]");
                        } else {
                            // this is a calltime threshold condition
                            builder.append("Call Time Value Threshold [");
                            if (condition.getMeasurementDefinition() != null) {
                                builder.append(condition.getMeasurementDefinition().getDisplayName()).append(" ");
                            }
                            builder.append(condition.getOption()) // MIN, MAX, AVG (never null)
                                .append(" ")
                                .append(condition.getComparator())  // <, >, =
                                .append(" ")
                                .append(formattedThreshold)
                                .append("]");
                            if (condition.getName() != null && condition.getName().length() > 0) {
                                builder.append(" with call destination matching '")
                                    .append(condition.getName())
                                    .append("'");
                            }
                        }
                        break;
                    case BASELINE:
                        formattedThreshold = MeasurementConverter.format(condition.getThreshold(),
                            MeasurementUnits.PERCENTAGE, true);
                        builder.append("Metric Value Baseline [")
                            .append(condition.getName())
                            .append(" ")
                            .append(condition.getComparator())
                            .append(" ")
                            .append(formattedThreshold)
                            .append(" of ")
                            .append(condition.getOption())
                            .append("]");
                        break;
                    case CHANGE:
                        if (condition.getOption() == null) {
                            builder.append("Metric Value Change [")
                                .append(condition.getName())
                                .append(" ")
                                .append("]");
                        } else {
                            // this is a calltime change condition
                            formattedThreshold = MeasurementConverter.format(condition.getThreshold(),
                                MeasurementUnits.PERCENTAGE, true);
                            builder.append("Call Time Value Changes [");
                            if (condition.getMeasurementDefinition() != null) {
                                builder.append(condition.getMeasurementDefinition().getDisplayName()).append(" ");
                            }
                            builder.append(condition.getOption()) // MIN, MAX, AVG (never null)
                                .append(" ")
                                .append(getCalltimeChangeComparator(condition.getComparator()))
                                .append(" by at least ")
                                .append(formattedThreshold)
                                .append("]");
                            if (condition.getName() != null && condition.getName().length() > 0) {
                                builder.append(" with call destination matching '")
                                    .append(condition.getName())
                                    .append("'");
                            }
                        }
                        break;
                    case TRAIT:
                        builder.append("Trait Change [")
                            .append(condition.getName())
                            .append("]");
                        if (condition.getOption() != null && condition.getOption().length() > 0) {
                            builder.append(" with trait value matching '")
                                .append(condition.getOption())
                                .append("'");
                        }                       
                        break;
                    case CONTROL:
                        builder.append("Operation Execution [")
                            .append(condition.getName())
                            .append("] with result status [")
                            .append(condition.getOption())
                            .append("]");
                        break;
                    case RESOURCE_CONFIG:
                        builder.append("Resource Configuration Change");
                        break;
                    case EVENT:
                        builder.append("Event Detection [")
                            .append(condition.getName())
                            .append("]");
                        if (condition.getOption() != null && condition.getOption().length() > 0) {
                            builder.append(" with event source matching '")
                                .append(condition.getOption())
                                .append("'");
                        }
                        break;
                    case DRIFT:
                        String configNameRegex = condition.getName();
                        String pathNameRegex = condition.getOption();
                        if (configNameRegex == null || configNameRegex.length() == 0) {
                            if (pathNameRegex == null || pathNameRegex.length() == 0) {
                                // neither a config name regex nor path regex was specified
                                builder.append("Drift Detection");
                            } else {
                                // a path name regex was specified, but not a config name regex
                                builder.append("Drift Detection for files that match \"")
                                    .append(pathNameRegex)
                                    .append("\"");
                            }
                        } else {
                            if (pathNameRegex == null || pathNameRegex.length() == 0) {
                                // a config name regex was specified, but not a path name regex
                                builder.append("Drift Detection for drift definition [")
                                    .append(configNameRegex)
                                    .append("]");
                            } else {
                                // both a config name regex and a path regex was specified
                                builder.append("Drift Detection for files that match \"")
                                    .append(pathNameRegex)
                                    .append("\" and for drift detection [")
                                    .append(configNameRegex)
                                    .append("]");
                            }
                        }
                        break;
                    case RANGE:
                        String metricName = condition.getName();
                        MeasurementUnits metricUnits = condition.getMeasurementDefinition().getUnits();
                        double loValue = condition.getThreshold();
                        String formattedLoValue = MeasurementConverter.format(loValue, metricUnits, true);
                        String formattedHiValue = condition.getOption();
                        try {
                            double hiValue = Double.parseDouble(formattedHiValue);
                            formattedHiValue = MeasurementConverter.format(hiValue, metricUnits, true);
                        } catch (Exception e) {
                            formattedHiValue = "?[" + formattedHiValue + "]?"; // signify something is wrong with the value
                        }

                        // < means "inside the range", > means "outside the range" - exclusive
                        // <= means "inside the range", >= means "outside the range" - inclusive

                        if (condition.getComparator().equals("<")) {
                            // Metric Value Range: [{0}] between [{1}] and [{2}], exclusive
                            builder.append("Metric Value Range: [")
                                .append(metricName)
                                .append("] between ")
                                .append(formattedLoValue)
                                .append("] and [")
                                .append(formattedHiValue)
                                .append("], exclusive");
                        } else if (condition.getComparator().equals(">")) {
                            // Metric Value Range: [{0}] outside [{1}] and [{2}], exclusive
                            builder.append("Metric Value Range: [")
                                .append(metricName)
                                .append("] outside [")
                                .append(formattedLoValue)
                                .append("] and [")
                                .append(formattedHiValue)
                                .append("], exclusive");
                        } else if (condition.getComparator().equals("<=")) {
                            // Metric Value Range: [{0}] between [{1}] and [{2}], inclusive
                            builder.append("Metric Value Range: [")
                                .append(metricName)
                                .append("] between [")
                                .append(formattedLoValue)
                                .append("] and [")
                                .append(formattedHiValue)
                                .append("], inclusive");
                        } else if (condition.getComparator().equals(">=")) {
                            // Metric Value Range: [{0}] outside [{1}] and [{2}], inclusive
                            builder.append("Metric Value Range: [")
                                .append(metricName)
                                .append("] outside [")
                                .append(formattedLoValue)
                                .append("] and [")
                                .append(formattedHiValue)
                                .append("], inclusive");
                        } else {
                            builder.append("BAD COMPARATOR! Report this bug: ").append(condition.getComparator());
                        }
                        break;
                    default:
                        // Invalid condition category - please report this as a bug: {0}
                        builder.append("Invalid condition category - please report this as a bug: ")
                            .append(category.getName());
                }
                return builder.toString();
            }

            private String getCalltimeChangeComparator(String comparator) {
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertConditionCategory

                    }
                }
            }

            final boolean calltimeCategory;
            final AlertConditionCategory category;

            String selectedCategory = conditionTypeSelectItem.getValue().toString();
            if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD)) {
                calltimeCategory = true;
                category = AlertConditionCategory.THRESHOLD;
            } else if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE)) {
                calltimeCategory = true;
                category = AlertConditionCategory.CHANGE;
            } else {
                calltimeCategory = false;
                category = AlertConditionCategory.valueOf(selectedCategory);
            }

            AlertCondition newCondition = new AlertCondition();
            newCondition.setCategory(category);

            switch (category) {
            case AVAILABILITY: {
                newCondition.setName(form.getValueAsString(AVAILABILITY_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(null);
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case AVAIL_DURATION: {
                newCondition.setName(form.getValueAsString(AVAILABILITY_DURATION_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                // entered in minutes, converted to seconds by DurationItem, and stored in seconds
                int duration = Integer.valueOf(form.getValueAsString(AVAILABILITY_DURATION_VAL_ITEMNAME));
                newCondition.setOption(String.valueOf(duration));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case THRESHOLD: {
                if (!calltimeCategory) {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(THRESHOLD_METRIC_ITEMNAME));
                    newCondition.setName(measDef.getDisplayName());
                    newCondition.setThreshold(getMeasurementValue(measDef,
                        form.getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
                    newCondition.setComparator(form.getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
                    newCondition.setOption(null);
                    newCondition.setMeasurementDefinition(measDef);
                } else {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME));
                    newCondition.setName(form.getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME));
                    newCondition.setThreshold(getMeasurementValue(measDef,
                        form.getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME)));
                    newCondition.setComparator(form.getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME));
                    newCondition.setOption(form.getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME));
                    newCondition.setMeasurementDefinition(measDef);
                }
                break;
            }

            case BASELINE: {
                MeasurementDefinition measDef = getMeasurementDefinition(form
                    .getValueAsString(BASELINE_METRIC_ITEMNAME));
                newCondition.setName(measDef.getDisplayName());
                newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE,
                    form.getValueAsString(BASELINE_PERCENTAGE_ITEMNAME)));
                newCondition.setComparator(form.getValueAsString(BASELINE_COMPARATOR_ITEMNAME));
                newCondition.setOption(form.getValueAsString(BASELINE_SELECTION_ITEMNAME));
                newCondition.setMeasurementDefinition(measDef);
                break;
            }

            case CHANGE: {
                if (!calltimeCategory) {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(CHANGE_METRIC_ITEMNAME));
                    newCondition.setName(measDef.getDisplayName());
                    newCondition.setComparator(null);
                    newCondition.setThreshold(null);
                    newCondition.setOption(null);
                    newCondition.setMeasurementDefinition(measDef);
                } else {
                    MeasurementDefinition measDef = getMeasurementDefinition(form
                        .getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME));
                    newCondition.setName(form.getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME));
                    newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE,
                        form.getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME)));
                    newCondition.setComparator(form.getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME));
                    newCondition.setOption(form.getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME));
                    newCondition.setMeasurementDefinition(measDef);
                }
                break;
            }

            case TRAIT: {
                MeasurementDefinition measDef = getMeasurementDefinition(form.getValueAsString(TRAIT_METRIC_ITEMNAME));
                newCondition.setName(measDef.getDisplayName());
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(form.getValueAsString(TRAIT_REGEX_ITEMNAME));
                newCondition.setMeasurementDefinition(measDef);
                break;
            }

            case CONTROL: {
                newCondition.setName(form.getValueAsString(OPERATION_NAME_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(form.getValueAsString(OPERATION_RESULTS_ITEMNAME));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case EVENT: {
                newCondition.setName(form.getValueAsString(EVENT_SEVERITY_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                Object regex1 = form.getValue(EVENT_REGEX_ITEMNAME);
                Object regex2 = form.getValue(EVENT_SOURCE_PATH_REGEX_ITEMNAME);
                newCondition.setOption((regex1 == null ? "" : regex1) + AlertCondition.ADHOC_SEPARATOR
                    + (regex2 == null ? "" : regex2));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case RESOURCE_CONFIG: {
                newCondition.setName(null);
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(null);
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case DRIFT: {
                newCondition.setName(form.getValueAsString(DRIFT_DEFNAME_REGEX_ITEMNAME));
                newCondition.setComparator(null);
                newCondition.setThreshold(null);
                newCondition.setOption(form.getValueAsString(DRIFT_PATHNAME_REGEX_ITEMNAME));
                newCondition.setMeasurementDefinition(null);
                break;
            }

            case RANGE: {
                MeasurementDefinition measDef = getMeasurementDefinition(form.getValueAsString(RANGE_METRIC_ITEMNAME));
                newCondition.setName(measDef.getDisplayName());
                newCondition.setThreshold(getMeasurementValue(measDef,
                    form.getValueAsString(RANGE_LO_ABSVALUE_ITEMNAME)));
                newCondition.setComparator(form.getValueAsString(RANGE_COMPARATOR_ITEMNAME));
                newCondition.setOption(getMeasurementValue(measDef, form.getValueAsString(RANGE_HI_ABSVALUE_ITEMNAME))
                    .toString());
                newCondition.setMeasurementDefinition(measDef);
                break;
            }

            default: {
                CoreGUI.getErrorHandler().handleError(
                    MSG.view_alert_common_tab_invalid_condition_category(category.name())); // should never happen
                break;
            }
            }
            if (editMode) {
                if (existingCondition.getId() != 0) {
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertConditionCategory

        AlertConditionCacheStats stats) {

        AlertCondition alertCondition = composite.getCondition();
        int alertConditionId = alertCondition.getId(); // auto-unboxing is safe here because as the PK it's guaranteed to be non-null

        AlertConditionCategory alertConditionCategory = alertCondition.getCategory();
        AlertConditionOperator alertConditionOperator = AlertConditionCacheUtils
            .getAlertConditionOperator(alertCondition);

        if (DataType.CALLTIME == composite.getDataType()) { // call-time cases start here
            if (alertConditionCategory == AlertConditionCategory.CHANGE) {
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertConditionCategory

        Iterator<AlertConditionLog> condLogsIterator = condLogs.iterator();

        for (AlertConditionBean alertCondBean : alertCondBeans) {
            AlertCondition cond = condsIterator.next();
            AlertConditionLog condLog = condLogsIterator.next();
            AlertConditionCategory category = cond.getCategory();

            if (category == AlertConditionCategory.CONTROL) {
                alertCondBean.setActualValue(RequestUtils.message(request, "alert.current.list.ControlActualValue"));
            } else if ((category == AlertConditionCategory.THRESHOLD) || (category == AlertConditionCategory.BASELINE)
                || (category == AlertConditionCategory.CHANGE)) {
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertConditionCategory

        return alertCondBeans;
    }

    @SuppressWarnings("deprecation")
    public static String formatAlertConditionForDisplay(AlertCondition cond, HttpServletRequest request) {
        AlertConditionCategory category = cond.getCategory();

        StringBuffer textValue = new StringBuffer();

        // first format the LHS of the operator
        if (category == AlertConditionCategory.CONTROL) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.