Package org.rhq.core.domain.alert

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


                em.persist(dynamicSchedule);
            }
        });

        alertDefinition = new AlertDefinition();
        AlertCondition cond = new AlertCondition(alertDefinition, AlertConditionCategory.CHANGE);
        cond.setName(DYNAMIC_DEF_NAME);
        cond.setMeasurementDefinition(dynamicMeasuremenDef);
        alertDefinition.setName("liveDataTestAlert");
        alertDefinition.setResource(resource);
View Full Code Here


        record.setAttribute("recovered", from.getRecoveryTime());
        if(from.getRecoveryTime() != null && from.getRecoveryTime().longValue() > 0) {
            record.setAttribute("recoveredTime", new Date(from.getRecoveryTime().longValue()));
        }

        AlertDefinition alertDefinition = from.getAlertDefinition();

        record.setAttribute("definitionId", alertDefinition.getId());
        Resource resource = alertDefinition.getResource();
        record.setAttribute("name", alertDefinition.getName());
        record.setAttribute("description", alertDefinition.getDescription());
        record.setAttribute("priority", ImageManager.getAlertIcon(alertDefinition.getPriority()));

        // for ancestry handling
        record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
        record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
        record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
        record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());

        AlertDefinition groupAlertDefinition = alertDefinition.getGroupAlertDefinition();
        Integer parentId = alertDefinition.getParentId();
        if (groupAlertDefinition != null && groupAlertDefinition.getGroup() != null) {
            boolean isAutogroup = groupAlertDefinition.getGroup().getAutoGroupParentResource() != null;
            record.setAttribute(FIELD_PARENT, (isAutogroup ? "#Resource/AutoGroup/" : "#ResourceGroup/")
                + groupAlertDefinition.getGroup().getId() + "/Alerts/Definitions/" + groupAlertDefinition.getId());
            record.setLinkText(MSG.view_alert_definition_for_group());
        } else if (parentId != null && parentId.intValue() != 0) {
            record.setAttribute(
                FIELD_PARENT,
                LinkManager.getAdminTemplatesEditLink(AlertDefinitionTemplateTypeView.VIEW_ID.getName(), resource
View Full Code Here

        GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
            @Override
            public void onSuccess(PageList<Alert> result) {
                Alert alert = result.get(0);
                Integer parentId = alert.getAlertDefinition().getParentId();
                AlertDefinition groupAlertDefinition = alert.getAlertDefinition().getGroupAlertDefinition();
                if (groupAlertDefinition != null || (parentId != null && parentId.intValue() != 0)) {
                    fetchDefinitionWithGroupAndTemplate(alert);
                } else {
                    show(alert);
                }
View Full Code Here

    @Override
    public AlertDefinition updateAlertTemplate(AlertDefinition alertDefinition, boolean resetMatching)
        throws RuntimeException {
        try {
            AlertDefinition results = alertTemplateManager.updateAlertTemplate(getSessionSubject(), alertDefinition,
                resetMatching);
            return SerialUtility.prepare(results, "AlertTemplateService.updateAlertTemplate");
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
View Full Code Here

    @Path("/{id}/definition")
    @ApiOperation("Get the alert definition (basics) for the alert")
    public AlertDefinitionRest getDefinitionForAlert(@ApiParam("Id of the alert to show the definition") @PathParam("id") int alertId,
                                                     @Context UriInfo uriInfo) {
        Alert al = findAlertWithId(alertId);
        AlertDefinition def = al.getAlertDefinition();
        AlertDefinitionHandlerBean adhb = new AlertDefinitionHandlerBean();
        AlertDefinitionRest ret = adhb.definitionToDomain(def, false, uriInfo); // TODO allow 'full' parameter?
        return ret;
    }
View Full Code Here

    }

    public AlertRest alertToDomain(Alert al, UriInfo uriInfo, boolean slim) {
        AlertRest ret = new AlertRest();
        ret.setId(al.getId());
        AlertDefinition alertDefinition = al.getAlertDefinition();
        ret.setName(alertDefinition.getName());
        AlertDefinitionRest alertDefinitionRest;
        if (slim) {
            alertDefinitionRest = new AlertDefinitionRest(alertDefinition.getId());
        } else {
            AlertDefinitionHandlerBean adhb = new AlertDefinitionHandlerBean();
            alertDefinitionRest = adhb.definitionToDomain(alertDefinition, false, uriInfo);
        }
        ret.setAlertDefinition(alertDefinitionRest);
        ret.setDefinitionEnabled(alertDefinition.getEnabled());
        if (al.getAcknowledgingSubject()!=null) {
            ret.setAckBy(al.getAcknowledgingSubject());
            ret.setAckTime(al.getAcknowledgeTime());
        }
        ret.setAlertTime(al.getCtime());
        ret.setDescription(alertManager.prettyPrintAlertConditions(al,false));
        ret.setRecoveryTime(al.getRecoveryTime());

        Resource r = fetchResource(alertDefinition.getResource().getId());
        ResourceWithType rwt;
        if (slim) {
            rwt = new ResourceWithType(r.getName(),r.getId());
        } else {
            rwt = fillRWT(r,uriInfo);
        }
        ret.setResource(rwt);

        // add some links
        UriBuilder builder = uriInfo.getBaseUriBuilder();
        builder.path("/alert/{id}/conditions");
        URI uri = builder.build(al.getId());
        Link link = new Link("conditions",uri.toString());
        ret.addLink(link);
        builder = uriInfo.getBaseUriBuilder();
        builder.path("/alert/{id}/notifications");
        uri = builder.build(al.getId());
        link = new Link("notification",uri.toString());
        ret.addLink(link);
        builder = uriInfo.getBaseUriBuilder();
        builder.path("/alert/{id}/definition");
        uri = builder.build(al.getId());
        link = new Link("definition",uri.toString());
        ret.addLink(link);

        int resourceId = alertDefinition.getResource().getId();
        ret.addLink(createUILink(uriInfo,UILinkTemplate.RESOURCE_ALERT,resourceId,al.getId()));

        return ret;
    }
View Full Code Here

        AlertCondition goingDown = new AlertCondition();
        goingDown.setCategory(AlertConditionCategory.AVAILABILITY);
        goingDown.setComparator("==");
        goingDown.setOption(AvailabilityType.DOWN.toString());

        AlertDefinition def = new AlertDefinition();
        def.addCondition(goingDown);
        def.setName("Test alert definition");
        def.setPriority(AlertPriority.MEDIUM);
        def.setAlertDampening(new AlertDampening(AlertDampening.Category.NONE));
        def.setRecoveryId(0);
        alertDefinitionManager.createAlertDefinitionInNewTransaction(overlord, def, res.getId(), true);

        for (int MULTI : ROUNDS) {
            String round = String.format(ROUND__FORMAT, MULTI);
View Full Code Here

        ResourceType resourceType = resourceTypeMgr.getResourceTypeByNameAndPlugin(resourceTypeName, pluginName);
        assertNotNull("Cannot create alert template. Unable to find resource type for [name: " + resourceTypeName +
            ", plugin: " + pluginName + "]", resourceType);

        AlertDefinition alertDef = new AlertDefinition();
        alertDef.setName(name);
        alertDef.setPriority(AlertPriority.MEDIUM);
        alertDef.setResourceType(resourceType);
        alertDef.setConditionExpression(BooleanExpression.ALL);
        alertDef.setAlertDampening(new AlertDampening(AlertDampening.Category.NONE));
        alertDef.setRecoveryId(0);

        alertTemplateMgr.createAlertTemplate(subjectMgr.getOverlord(), alertDef, resourceType.getId());
    }
View Full Code Here

    }

    @Override
    protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean resetMatching,
        final AsyncCallback<AlertDefinition> resultReceiver) {
        AlertDefinition newAlertDefinition = new AlertDefinition(alertDefinition);
        newAlertDefinition.setId(alertDefinition.getId());
        ResourceType fakeResourceType = new ResourceType();
        fakeResourceType.setId(resourceType.getId());
        newAlertDefinition.setResourceType(fakeResourceType); // this was causing the serialization issues in GWT 2.5.0 (bz1058318)
        // the 3 lines above can go away after update to >= GWT 2.6.0 rc3
       
        if (alertDefinition.getId() == 0) {
            GWTServiceLookup.getAlertTemplateService().createAlertTemplate(alertDefinition,
                Integer.valueOf(this.resourceType.getId()), new AsyncCallback<Integer>() {
View Full Code Here

        priorityField.setAlign(Alignment.CENTER);
        priorityField.setShowHover(true);
        priorityField.setHoverCustomizer(new HoverCustomizer() {
            @Override
            public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
                AlertDefinition alertDef = (AlertDefinition) record.getAttributeAsObject(FIELD_OBJECT);
                switch (alertDef.getPriority()) {
                case HIGH: {
                    return MSG.common_alert_high();
                }
                case MEDIUM: {
                    return MSG.common_alert_medium();
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.