Package org.rhq.core.domain.alert

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


        }

        int modified = 0;

        for (Integer groupAlertDefinitionId : groupAlertDefinitionIds) {
            AlertDefinition groupAlertDefinition = entityManager.find(AlertDefinition.class, groupAlertDefinitionId);
            if (null == groupAlertDefinition || groupAlertDefinition.getEnabled() || groupAlertDefinition.getDeleted()) {
                continue;
            }

            // enable the template
            groupAlertDefinition.setEnabled(true);
            ++modified;

            // enable the child resource-level defs
            List<Integer> childDefinitionIds = getChildrenAlertDefinitionIds(groupAlertDefinitionId);
            if (childDefinitionIds.isEmpty()) {
View Full Code Here


        if (LOG.isDebugEnabled()) {
            LOG.debug("updateGroupAlertDefinition: " + groupAlertDefinition);
        }

        // first update the actual alert group alert definition
        AlertDefinition updated = null;
        try {
            updated = alertDefinitionManager.updateAlertDefinition(subject, groupAlertDefinition.getId(),
                groupAlertDefinition, resetMatching); // do not allow direct undeletes of an alert definition
        } catch (Throwable t) {
            throw new AlertDefinitionUpdateException("Failed to update a GroupAlertDefinition: "
                + groupAlertDefinition.toSimpleString(), t);
        }

        // overlord will be used for all system-side effects as a result of updating this alert template
        Subject overlord = subjectManager.getOverlord();
        Throwable firstThrowable = null;

        // update all of the definitions that were spawned from this group alert definition
        List<Integer> alertDefinitions = getChildrenAlertDefinitionIds(groupAlertDefinition.getId());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Need to update the following children alert definition ids: " + alertDefinitions);
        }
        List<Integer> alertDefinitionIdsInError = new ArrayList<Integer>();

        for (Integer alertDefinitionId : alertDefinitions) {
            try {
                alertDefinitionManager.updateDependentAlertDefinition(subject, alertDefinitionId, updated,
                    resetMatching);
            } catch (Throwable t) {
                // continue on error, update as many as possible
                if (firstThrowable == null) {
                    firstThrowable = t;
                }
                alertDefinitionIdsInError.add(alertDefinitionId);
            }
        }

        // if the subject deleted the alertDefinition spawned from a groupAlertDefinition, cascade update will recreate it
        List<Integer> resourceIds = getCommittedResourceIdsNeedingGroupAlertDefinitionApplication(overlord,
            groupAlertDefinition.getId(), getResourceGroupIdForAlertDefinitionId(groupAlertDefinition.getId()));
        List<Integer> resourceIdsInError = new ArrayList<Integer>();
        for (Integer resourceId : resourceIds) {
            try {
                // construct the child
                AlertDefinition childAlertDefinition = new AlertDefinition(updated);
                childAlertDefinition.setGroupAlertDefinition(groupAlertDefinition);

                // persist the child
                alertDefinitionManager.createAlertDefinitionInNewTransaction(subject, childAlertDefinition, resourceId,
                    false);
            } catch (Throwable t) {
View Full Code Here

        for (AlertDefinition groupAlertDefinition : groupAlertDefinitions) {
            for (Integer resourceId : addedResourceIds) {
                try {
                    // Construct the resource-level AlertDefinition by using the copy constructor.
                    AlertDefinition childAlertDefinition = new AlertDefinition(groupAlertDefinition);

                    // groupAlertDefinition is an attached entity. It is dangerous to pass attached entities (with
                    // Hibernate proxies for the current session) across sessions. Since the call to create the new
                    // AlertDefinition is performed in a new transaction, make sure not to pass the attached entity.
                    // Just use a simple stand-in to create the link to the group alert definition.
                    AlertDefinition groupAlertDefinitionPojo = new AlertDefinition();
                    groupAlertDefinitionPojo.setId(groupAlertDefinition.getId());
                    childAlertDefinition.setGroupAlertDefinition(groupAlertDefinitionPojo);

                    // Persist the resource-level (child) alert definition, cleanse any further proxies left
                    // over from the copy constructor.
                    HibernateDetachUtility.nullOutUninitializedFields(childAlertDefinition,
View Full Code Here

    private void convertNotificationsToInvalidAlertDefResults(PropertyList results,
        List<AlertNotification> invalidNotifications) {
        Set<AlertDefinition> processedDefs = new HashSet<AlertDefinition>();

        for (AlertNotification cliNotification : invalidNotifications) {
            AlertDefinition def = cliNotification.getAlertDefinition();

            if (!processedDefs.add(def)) {
                //skip this definition - it has more than one incorrect notifs and we already
                //included it in the output.
                continue;
            }

            PropertyMap alertDefinitionMap = new PropertyMap(PROP_ALERT_DEFINITION);

            alertDefinitionMap.put(new PropertySimple(PROP_ALERT_DEFINITION_ID, def.getId()));
            alertDefinitionMap.put(new PropertySimple(PROP_ALERT_DEFINITION_NAME, def.getName()));
            alertDefinitionMap.put(new PropertySimple(PROP_RESOURCE_ID, def.getResource().getId()));

            results.add(alertDefinitionMap);
        }
    }
View Full Code Here

    private Alert createAlertForResourceWithId(int resourceId, String resourceName, String alertDefinitionName,
        AlertPriority alertPriority) {
        Resource resource = new Resource();
        resource.setId(resourceId);
        resource.setName(resourceName);
        AlertDefinition alertDefinition = new AlertDefinition();
        alertDefinition.setName(alertDefinitionName);
        alertDefinition.setResource(resource);
        alertDefinition.setPriority(alertPriority);
        Alert alert = new Alert();
        alert.setAlertDefinition(alertDefinition);
        return alert;
    }
View Full Code Here

*/
    }

    public void testOperationTokens() {
        Resource r = new Resource(1234);
        AlertDefinition def = new AlertDefinition();
        def.setResource(r);
        Alert al = new Alert(def, System.currentTimeMillis());

        AlertTokenReplacer tr;
        OperationDefinition opDef = new OperationDefinition(123,"helloOps",null,"This is a test",0,"Just testing");
        tr = new AlertTokenReplacer(al,opDef, null);
View Full Code Here

            }
        }
        recoverAlertSelection.setValueMap(alertMap);

        if (alertDefinition != null) {
            AlertDefinition recoveryAlert = lookupAlertDefinition(alertDefinition.getRecoveryId());
            if (recoveryAlert != null) {
                String recoveryIdStr = String.valueOf(recoveryAlert.getId());
                recoverAlertSelection.setValue(recoveryIdStr);
                recoverAlertStatic.setValue(recoveryAlert.getName());
                refreshDisableWhenFiredSelection(recoveryIdStr);
            } else {
                recoverAlertSelection.setValue("0");
                recoverAlertStatic.setValue(getNoRecoveryMenuItemTitle());
                refreshDisableWhenFiredSelection("0");
View Full Code Here

    public Canvas getDetailsView(ListGridRecord record) {
        if (record == null) {
            return getDetailsView(0);
        }

        AlertDefinition alertDef = getAlertDefinitionDataSource().copyValues(record);
        SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this, alertDef);
        return singleAlertDefinitionView;
    }
View Full Code Here

    public SingleAlertDefinitionView getDetailsView(final Integer id) {
        final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this);

        if (id == 0) {
            // create an empty one with all defaults
            AlertDefinition newAlertDef = new AlertDefinition();
            newAlertDef.setDeleted(false);
            newAlertDef.setEnabled(true);
            newAlertDef.setPriority(AlertPriority.MEDIUM);
            newAlertDef.setParentId(0);
            newAlertDef.setConditionExpression(BooleanExpression.ANY);
            newAlertDef.setWillRecover(false);
            newAlertDef.setRecoveryId(0);
            newAlertDef.setAlertDampening(new AlertDampening(AlertDampening.Category.NONE));
            newAlertDef.setNotifyFiltered(false);
            newAlertDef.setControlFiltered(false);
            singleAlertDefinitionView.setAlertDefinition(newAlertDef);
            singleAlertDefinitionView.makeEditable();
        } else {
            final AlertDefinitionCriteria criteria = getDetailCriteria();
            criteria.addFilterId(id);
View Full Code Here

        testData.setGroupAlertDefinitionId(createGroupAlertDefinition(testData.getSubject(),
            testData.getResourceGroup()).getId());
    }

    private AlertDefinition createGroupAlertDefinition(Subject subject, ResourceGroup resourceGroup) {
        AlertDefinition alertDefinition = new AlertDefinition();
        alertDefinition.setName(AlertConditionOperator.AVAIL_GOES_UP.name());
        alertDefinition.setPriority(AlertPriority.MEDIUM);
        alertDefinition.setAlertDampening(new AlertDampening(AlertDampening.Category.NONE));
        alertDefinition.setConditionExpression(BooleanExpression.ANY);
        alertDefinition.setRecoveryId(0);
        alertDefinition.setGroup(resourceGroup);
        alertDefinition.setEnabled(true);
        AlertCondition alertCondition = new AlertCondition(alertDefinition, AlertConditionCategory.AVAILABILITY);
        alertCondition.setName(AlertConditionOperator.AVAIL_GOES_UP.name());
        alertDefinition.addCondition(alertCondition);
        groupAlertDefinitionManager.createGroupAlertDefinitions(subject, alertDefinition, resourceGroup.getId());
        return alertDefinition;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.alert.AlertDefinition

Copyright © 2018 www.massapicom. 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.