Examples of AlertDefinitionRest


Examples of org.rhq.enterprise.server.rest.domain.AlertDefinitionRest

    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

Examples of org.rhq.enterprise.server.rest.domain.AlertDefinitionRest

    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);
View Full Code Here

Examples of org.rhq.enterprise.server.rest.domain.AlertDefinitionRest

        }

        PageList<AlertDefinition> defs = alertDefinitionManager.findAlertDefinitionsByCriteria(caller, criteria);
        List<AlertDefinitionRest> ret = new ArrayList<AlertDefinitionRest>(defs.size());
        for (AlertDefinition def : defs) {
            AlertDefinitionRest adr = definitionToDomain(def, full, uriInfo);
            ret.add(adr);
        }

        Response.ResponseBuilder builder = Response.ok();
View Full Code Here

Examples of org.rhq.enterprise.server.rest.domain.AlertDefinitionRest

        }

        EntityTag eTag = new EntityTag(Integer.toHexString(def.hashCode()));
        Response.ResponseBuilder builder = request.evaluatePreconditions(eTag);
        if (builder==null) {
            AlertDefinitionRest adr = definitionToDomain(def, full, uriInfo);
            builder = Response.ok(adr);
        }
        builder.tag(eTag);

        return builder.build();
View Full Code Here

Examples of org.rhq.enterprise.server.rest.domain.AlertDefinitionRest

        }

        AlertDefinition updatedDefinition = alertDefinitionManager.createAlertDefinitionInNewTransaction(caller,
            alertDefinition, resourceId, false);
        int definitionId = updatedDefinition.getId();
        AlertDefinitionRest uadr = definitionToDomain(updatedDefinition,true, uriInfo) ; // TODO param 'full' ?

        uadr.setId(definitionId);

        UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/alert/definition/{id}");
        URI uri = uriBuilder.build(definitionId);
View Full Code Here

Examples of org.rhq.enterprise.server.rest.domain.AlertDefinitionRest

        definition = alertDefinitionManager.updateAlertDefinitionInternal(caller, definitionId, definition, true,
            true, true);
        entityManager.flush();

        EntityTag eTag = new EntityTag(Integer.toHexString(definition.hashCode()));
        AlertDefinitionRest adr = definitionToDomain(definition, false, uriInfo);

        Response.ResponseBuilder builder = Response.ok(adr);
        builder.tag(eTag);

        return builder.build();
View Full Code Here

Examples of org.rhq.enterprise.server.rest.domain.AlertDefinitionRest

    }


    AlertDefinitionRest definitionToDomain(AlertDefinition def, boolean full, UriInfo uriInfo) {
        AlertDefinitionRest adr = new AlertDefinitionRest(def.getId());
        adr.setName(def.getName());
        adr.setEnabled(def.getEnabled());
        adr.setPriority(def.getPriority().getName());
        adr.setConditionMode(def.getConditionExpression().toString());
        adr.setRecoveryId(def.getRecoveryId());

        if (full) {
            Set<AlertCondition> conditions = def.getConditions();
            if (conditions.size() > 0) {
                List<AlertConditionRest> conditionRestList = new ArrayList<AlertConditionRest>(conditions.size());
                for (AlertCondition condition : conditions) {
                    AlertConditionRest acr = conditionToConditionRest(condition);
                    conditionRestList.add(acr);
                }
                adr.setConditions(conditionRestList);
            }
            List<AlertNotification> notifications = def.getAlertNotifications();
            if (notifications.size() > 0) {
                List<AlertNotificationRest> notificationRestList = new ArrayList<AlertNotificationRest>(notifications.size());
                for (AlertNotification notification : notifications) {
                    AlertNotificationRest anr = notificationToNotificationRest(notification);
                    notificationRestList.add(anr);
                }
                adr.setNotifications(notificationRestList);
            }
        }

        AlertDampening dampening = def.getAlertDampening();
        adr.setDampeningCategory(dampening.getCategory().name());
        if (dampening.getCategory()== AlertDampening.Category.NONE && def.getWillRecover()) {
            adr.setDampeningCategory(AlertDampening.Category.ONCE.name());
        }

        AlertDampening.TimeUnits units = dampening.getValueUnits();
        String s = units != null ? " " + units.name() : "";
        adr.setDampeningCount(dampening.getValue());
        units = dampening.getPeriodUnits();
        s = units != null ? " " + units.name() : "";
        adr.setDampeningPeriod(dampening.getPeriod());
        if (dampening.getPeriodUnits()!=null) {
            adr.setDampeningUnit(dampening.getPeriodUnits().name());
        }

        List<Link> links = adr.getLinks();
        if (def.getResource()!=null) {
            links.add(createUILink(uriInfo, UILinkTemplate.RESOURCE_ALERT_DEF, def.getResource().getId(), adr.getId()));
            links.add(getLinkToResource(def.getResource(), uriInfo, "resource"));
        } else if (def.getGroup() != null) {
            links.add(
                createUILink(uriInfo, UILinkTemplate.GROUP_ALERT_DEF, def.getGroup().getId(), adr.getId()));
            links.add(getLinkToGroup(def.getGroup(), uriInfo, "group"));
        } else {
            links.add(
                createUILink(uriInfo, UILinkTemplate.TEMPLATE_ALERT_DEF, def.getResourceType().getId(), adr.getId()));
            links.add(getLinkToResourceType(def.getResourceType(),uriInfo,"resourceType"));
        }

        return adr;
    }
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.