Examples of AlertCriteria


Examples of org.rhq.core.domain.criteria.AlertCriteria

        dataManager.findLiveData(getOverlord(), resource.getId(), new int[] { dynamicMeasuremenDef.getId()}, Long.MAX_VALUE);
        // wait for our JMS messages to process and see if we get any alerts
        Thread.sleep(3000);

        //check that the alert fired when the value of the measurement changed.
        AlertCriteria aCrit = new AlertCriteria();
        aCrit.addFilterResourceIds(resource.getId());

        List<Alert> alerts = LookupUtil.getAlertManager().findAlertsByCriteria(getOverlord(), aCrit);
        assertEquals("Unexpected number of alerts on the resource.", 1, alerts.size());
    }
View Full Code Here

Examples of org.rhq.core.domain.criteria.AlertCriteria

     * @param id Primary key of the alert
     * @return Alert domain object
     * @throws StuffNotFoundException if no such alert exists in the system.
     */
    private Alert findAlertWithId(int id) {
        AlertCriteria criteria = new AlertCriteria();
        criteria.addFilterId(id);
        List<Alert> alerts = alertManager.findAlertsByCriteria(caller,criteria);
        if (alerts.isEmpty()) {
            throw new StuffNotFoundException("Alert with id " + id);
        }

View Full Code Here

Examples of org.rhq.core.domain.criteria.AlertCriteria

        AlertPriority[] prioritiesFilter = getArrayFilter(request, FILTER_PRIORITIES, AlertPriority.class);
        if (prioritiesFilter == null || prioritiesFilter.length == 0) {
            return null; // user didn't select any priorities - return null to indicate no data should be displayed
        }

        AlertCriteria criteria = new AlertCriteria();
        // There's no need to add a priorities filter to the criteria if the user specified all priorities.
        if (prioritiesFilter.length != AlertPriority.values().length) {
            criteria.addFilterPriorities(prioritiesFilter);
        }

        Date startDateFilter = getFilter(request, DateFilterItem.START_DATE_FILTER, Date.class);
        if(startDateFilter != null){
            Date startOfDay =   DateFilterItem.adjustTimeToStartOfDay(startDateFilter);
            criteria.addFilterStartTime(startOfDay.getTime());
        }

        Date endDateFilter = getFilter(request, DateFilterItem.END_DATE_FILTER, Date.class);
        if( endDateFilter!= null){
            Date endOfDay = DateFilterItem.adjustTimeToEndOfDay(endDateFilter);
            criteria.addFilterEndTime(endOfDay.getTime());
        }
        criteria.addFilterResourceIds(getArrayFilter(request, FILTER_RESOURCE_IDS, Integer.class));
        criteria.addFilterEntityContext(entityContext);
        criteria.fetchConditionLogs(true);
//        criteria.fetchGroupAlertDefinition(true);

        AlertFilter[] alertFilters = getArrayFilter(request, FILTER_STATUS, AlertFilter.class);
        if(alertFilters != null && alertFilters.length > 0) {
            // This feels duplicate from AlertsPortletDataSource..
            for(AlertFilter filter : alertFilters) {
                if(filter.equals(AlertFilter.ACKNOWLEDGED_STATUS)) {
                    criteria.addFilterUnacknowledgedOnly(true);
                } else if(filter.equals(AlertFilter.RECOVERED_STATUS)) {
                    criteria.addFilterRecovered(true);
                } else if(filter.equals(AlertFilter.RECOVERY_TYPE)) {
                    criteria.addFilterRecoveryIds(Integer.valueOf(0)); // Filter all alerts with recoveryId = 0
                }
            }
        }

        String nameFilter = getFilter(request, FILTER_NAME, String.class);
        if(nameFilter != null && nameFilter.length() > 0) {
            criteria.addFilterName(nameFilter);
        }

        return criteria;
    }
View Full Code Here

Examples of org.rhq.core.domain.criteria.AlertCriteria

        // access through the static singleton only
        super();
    }

    private void show(int alertId) {
        AlertCriteria criteria = new AlertCriteria();
        criteria.addFilterId(alertId);
        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();
View Full Code Here

Examples of org.rhq.core.domain.criteria.AlertCriteria

        });
    }

    @Override
    protected AlertCriteria getFetchCriteria(DSRequest request) {
        AlertCriteria criteria = new AlertCriteria();

        //retrieve previous settings from portlet config
        if ((portlet != null) && (this.portlet instanceof DashboardPortlet)) {
            Configuration portletConfig = configuration;
            //filter priority, if null or empty then no priority filtering
            String currentSetting = portletConfig.getSimpleValue(Constant.ALERT_PRIORITY,
                Constant.ALERT_PRIORITY_DEFAULT);
            if (!currentSetting.trim().isEmpty()) {
                String[] parsedValues = currentSetting.trim().split(",");

                if (parsedValues.length < AlertPriority.values().length) {
                    AlertPriority[] filterPriorities = new AlertPriority[parsedValues.length];
                    int indx = 0;
                    for (String priority : parsedValues) {
                        AlertPriority p = AlertPriority.valueOf(priority);
                        filterPriorities[indx++] = p;
                    }
                    criteria.addFilterPriorities(filterPriorities);
                }
            }

            PageControl pc = new PageControl();
            //result sort order
            currentSetting = portletConfig.getSimpleValue(Constant.RESULT_SORT_ORDER,
                Constant.RESULT_SORT_ORDER_DEFAULT);
            if (currentSetting.trim().isEmpty()) {
                pc.setPrimarySortOrder(PageOrdering.valueOf(Constant.RESULT_SORT_ORDER_DEFAULT));
            } else {
                pc.setPrimarySortOrder(PageOrdering.valueOf(currentSetting));
            }

            //result timeframe if enabled
            PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
            if (null != property && Boolean.valueOf(property.getBooleanValue())) {//then proceed setting

                boolean isAdvanced = Boolean.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_BEGIN_END_FLAG,
                    Constant.METRIC_RANGE_BEGIN_END_FLAG_DEFAULT));
                if (isAdvanced) {
                    //Advanced time settings
                    currentSetting = portletConfig.getSimpleValue(Constant.METRIC_RANGE, Constant.METRIC_RANGE_DEFAULT);
                    String[] range = currentSetting.split(",");
                    if (range.length == 2) {
                        criteria.addFilterStartTime(Long.valueOf(range[0]));
                        criteria.addFilterEndTime(Long.valueOf(range[1]));
                    }
                } else {
                    //Simple time settings
                    property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
                    if (property != null) {
                        Integer lastN = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_LASTN,
                            Constant.METRIC_RANGE_LASTN_DEFAULT));
                        Integer units = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_UNIT,
                            Constant.METRIC_RANGE_UNIT_DEFAULT));
                        ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, units);
                        criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
                        criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
                    }
                }
            }

            //result count
            currentSetting = portletConfig.getSimpleValue(Constant.RESULT_COUNT, Constant.RESULT_COUNT_DEFAULT);
            if (currentSetting.trim().isEmpty()) {
                pc.setPageSize(Integer.valueOf(Constant.RESULT_COUNT_DEFAULT));
            } else {
                pc.setPageSize(Integer.valueOf(currentSetting));
            }

            criteria.setPageControl(pc);

            if (groupId != null) {
                criteria.addFilterResourceGroupIds(groupId);
            }
            if ((resourceIds != null) && (resourceIds.length > 0)) {
                criteria.addFilterResourceIds(resourceIds);
            }
        }
        criteria.fetchAlertDefinition(true);
        criteria.fetchRecoveryAlertDefinition(true);
        criteria.fetchConditionLogs(true);
        return criteria;
    }
View Full Code Here

Examples of org.rhq.core.domain.criteria.AlertCriteria

        }
        if (page<0) {
            throw new BadArgumentException("page","Must be >=1");
        }

        AlertCriteria criteria = new AlertCriteria();

        if (size==-1) {
            PageControl pageControl = PageControl.getUnlimitedInstance();
            pageControl.setPageNumber(page);
            criteria.setPageControl(pageControl);
        }
        else {
            criteria.setPaging(page, size);
        }

        if (since!=null) {
            criteria.addFilterStartTime(since);
        }

        if (resourceId!=null) {
            criteria.addFilterResourceIds(resourceId);
        }
        if (definitionId!=null) {
            criteria.addFilterAlertDefinitionIds(definitionId);
        }

        if (!prio.equals("All")) {
            AlertPriority alertPriority = AlertPriority.valueOf(prio.toUpperCase());
            criteria.addFilterPriorities(alertPriority);
        }

        if(name != null && name.length() > 0) {
            criteria.addFilterName(name);
        }

        if (unacknowledgedOnly) {
            criteria.addFilterUnacknowledgedOnly(Boolean.TRUE);
        }

        criteria.addFilterRecovered(noRecovered);

        if(noRecoveryType) {
            criteria.addFilterRecoveryIds(Integer.valueOf(0));
        }

        criteria.addSortCtime(PageOrdering.DESC);

        PageList<Alert> alerts = alertManager.findAlertsByCriteria(caller,criteria);
        List<AlertRest> ret = new ArrayList<AlertRest>(alerts.size());
        for (Alert al : alerts) {
            AlertRest ar = alertToDomain(al, uriInfo, slim);
View Full Code Here

Examples of org.rhq.core.domain.criteria.AlertCriteria

    @Path("count")
    @ApiOperation("Return a count of alerts in the system depending on criteria")
    public IntegerValue countAlerts(@ApiParam(value = "If non-null only send alerts that have fired after this time, time is millisecond since epoch")
                        @QueryParam("since") Long since) {

        AlertCriteria criteria = new AlertCriteria();
        criteria.setPageControl(PageControl.getUnlimitedInstance());
        criteria.fetchAlertDefinition(false);
        criteria.fetchConditionLogs(false);
        criteria.fetchRecoveryAlertDefinition(false);
        criteria.fetchNotificationLogs(false);
        criteria.setRestriction(Criteria.Restriction.COUNT_ONLY);
        if (since!=null) {
            criteria.addFilterStartTime(since);
        }
        PageList<Alert> alerts = alertManager.findAlertsByCriteria(caller,criteria);
        int count = alerts.getTotalSize();

        return new IntegerValue(count);
View Full Code Here

Examples of org.rhq.core.domain.criteria.AlertCriteria

    private PageList<Alert> findStorageNodeAlerts(Subject subject, boolean allAlerts, StorageNode storageNode) {
        Integer[] resouceIdsWithAlertDefinitions = findResourcesWithAlertDefinitions(storageNode);
        PageList<Alert> alerts = new PageList<Alert>();

        if (resouceIdsWithAlertDefinitions != null && resouceIdsWithAlertDefinitions.length != 0) {
            AlertCriteria criteria = new AlertCriteria();
            criteria.setPageControl(PageControl.getUnlimitedInstance());
            criteria.addFilterResourceIds(resouceIdsWithAlertDefinitions);
            criteria.addSortCtime(PageOrdering.DESC);

            alerts = alertManager.findAlertsByCriteria(subject, criteria);

            if (!allAlerts) {
                //select on alerts that are not acknowledge
View Full Code Here

Examples of org.rhq.core.domain.criteria.AlertCriteria

        criteria.addFilterResourceCategories(ResourceCategory.SERVICE);
        criteria.setRestriction(Criteria.Restriction.COUNT_ONLY);
        resList = resourceManager.findResourcesByCriteria(caller,criteria);
        result.put("ServiceCount",String.valueOf(resList.getTotalSize()));

        AlertCriteria alertCriteria = new AlertCriteria();
        alertCriteria.setRestriction(Criteria.Restriction.COUNT_ONLY);
        PageList<Alert> alertList = alertManager.findAlertsByCriteria(caller,alertCriteria);
        result.put("AlertCount",String.valueOf(alertList.getTotalSize()));

        AlertDefinitionCriteria alertDefinitionCriteria = new AlertDefinitionCriteria();
        alertDefinitionCriteria.setRestriction(Criteria.Restriction.COUNT_ONLY);
View Full Code Here

Examples of org.rhq.core.domain.criteria.AlertCriteria

    private List<Alert> getAlerts(Subject subject, int resourceId, int count) {
        PageControl lastFive = new PageControl(0, count);
        lastFive.initDefaultOrderingField("ctime", PageOrdering.DESC);

        AlertCriteria criteria = new AlertCriteria();
        criteria.addFilterResourceIds(resourceId);
        criteria.setPageControl(lastFive);

        AlertManagerLocal alertManager = LookupUtil.getAlertManager();
        List<Alert> results = alertManager.findAlertsByCriteria(subject, criteria);
        return results;
    }
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.