Package org.rhq.core.domain.criteria

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


            }
        }

        EventSource source = findEventSourceById(sourceId);

        EventCriteria criteria = new EventCriteria();
        criteria.addSortId(PageOrdering.ASC);
        criteria.addFilterSourceId(source.getId());
        if (startTime>0) {
            criteria.addFilterStartTime(startTime);
        }
        if (endTime>0) {
            criteria.addFilterEndTime(endTime);
        }
        if (page!=null) {
            criteria.setPaging(page,pageSize);
        }
        else if (startTime==0 && endTime==0) {
            PageControl pageControl = new PageControl();
            pageControl.setPageSize(200);
            criteria.setPageControl(pageControl);
        }
        if (severity!=null) {
            criteria.addFilterSeverities(EventSeverity.valueOf(severity.toUpperCase()));
        }

        Response.ResponseBuilder builder = getEventsAsBuilderForCriteria(headers, criteria, uriInfo);

        return builder.build();
View Full Code Here


            } catch (Exception e) {
                throw new BadArgumentException("severity",severity + " is bad. Allowed values are DEBUG, INFO, WARN, ERROR, FATAL");
            }
        }

        EventCriteria criteria = new EventCriteria();
        criteria.addSortId(PageOrdering.ASC);

        criteria.addFilterResourceId(resourceId);
        if (startTime>0) {
            criteria.addFilterStartTime(startTime);
        }
        if (endTime>0) {
            criteria.addFilterEndTime(endTime);
        }
        if (page!=null) {
            criteria.setPaging(page,pageSize);
        }
        else if (startTime==0 && endTime==0) {
            PageControl pageControl = new PageControl();
            pageControl.setPageSize(200);
            criteria.setPageControl(pageControl);
        }
        if (severity!=null) {
            criteria.addFilterSeverities(EventSeverity.valueOf(severity.toUpperCase()));
        }

        Response.ResponseBuilder builder = getEventsAsBuilderForCriteria(headers, criteria, uriInfo);

        return builder.build();
View Full Code Here

    @Override
    public EventSeverity[] getSeverityBucketsByContext(Subject subject, EntityContext context, long begin, long end,
        int bucketCount) {

        EventCriteria criteria = new EventCriteria();
        criteria.addFilterStartTime(begin);
        criteria.addFilterEndTime(end);

        /*
         * if the bucket computation is pushed into the database, it saves on data transfer across the wire. this
         * solution is currently querying N number of strings (event.severity) and N number of longs (event.timestamp),
         * where N is the number of events between 'begin' and 'end'.  if the severity buckets are computed in a single
View Full Code Here

                    + "] does not have permission to view event history for autoGroup[parentResourceId="
                    + context.parentResourceId + ", resourceTypeId=" + context.resourceTypeId + "]");
            }
        }

        EventCriteria criteria = new EventCriteria();
        criteria.addFilterStartTime(begin);
        criteria.addFilterEndTime(end);
        criteria.addFilterSeverities(severities);
        if (source != null && !source.trim().equals("")) {
            criteria.addFilterSourceName(source);
        }
        if (detail != null && !detail.trim().equals("")) {
            criteria.addFilterDetail(detail);
        }

        criteria.setPageControl(pc);

        if (context.type == EntityContext.Type.Resource) {
            criteria.addFilterResourceId(context.resourceId);
        } else if (context.type == EntityContext.Type.ResourceGroup) {
            criteria.addFilterResourceGroupId(context.groupId);
        } else if (context.type == EntityContext.Type.AutoGroup) {
            criteria.addFilterAutoGroupParentResourceId(context.parentResourceId);
            criteria.addFilterAutoGroupResourceTypeId(context.resourceTypeId);
        }

        return findEventCompositesByCriteria(subject, criteria);
    }
View Full Code Here

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

        EventCriteria criteria = new EventCriteria();

        // This code is unlikely to be necessary as the encompassing view should be using an initial
        // sort specifier. But just in case, make sure we set the initial sort.  Note that we have to
        // manipulate the PageControl directly as per the restrictions on getFetchCriteria() (see jdoc).
        PageControl pageControl = getPageControl(request);
        if (pageControl.getOrderingFields().isEmpty()) {
            pageControl.initDefaultOrderingField("timestamp", PageOrdering.DESC);
        }

        // TODO: This call is broken in 2.2, http://code.google.com/p/smartgwt/issues/detail?id=490
        // when using AdvancedCriteria
        Map<String, Object> criteriaMap = request.getCriteria().getValues();

        criteria.addFilterSourceName((String) criteriaMap.get("source"));
        criteria.addFilterDetail((String) criteriaMap.get("detail"));
        if (criteriaMap.get("startTime")!=null) {
            Date tmp = (Date) criteriaMap.get("startTime");
            criteria.addFilterStartTime(tmp.getTime());
        }
        if (criteriaMap.get("endTime")!=null) {
            Date tmp = (Date) criteriaMap.get("endTime");
            criteria.addFilterEndTime(tmp.getTime());
        }
        // There's no need to add a severities filter to the criteria if the user specified all severities.
        if (severities.length != EventSeverity.values().length) {
            criteria.addFilterSeverities(severities);
        }

        criteria.addFilterEntityContext(entityContext);

        return criteria;
    }
View Full Code Here

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

    private void show(int eventId) {
        EventCriteria criteria = new EventCriteria();
        criteria.addFilterId(eventId);
        GWTServiceLookup.getEventService().findEventCompositesByCriteria(criteria,
            new AsyncCallback<PageList<EventComposite>>() {
                @Override
                public void onSuccess(PageList<EventComposite> result) {
                    EventComposite composite = result.get(0);
View Full Code Here

            return result.size();
        }

        @Override
        protected EventCriteria getFetchCriteria(DSRequest request) {
            EventCriteria criteria = new EventCriteria();
           
            // event source filter
            String currentSetting = this.configuration.getSimpleValue(Constant.EVENT_SOURCE, "");
            criteria.addFilterSourceName(currentSetting);

            // result count
            currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT,
                Constant.RESULT_COUNT_DEFAULT);

            int pageNumber = 0;
            int pageSize = Integer.valueOf(currentSetting);
            OrderingField orderingField = new OrderingField("timestamp", PageOrdering.DESC);
            criteria.setPageControl(new PageControl(pageNumber, pageSize, orderingField));

            // filter severity
            currentSetting = this.configuration
                .getSimpleValue(Constant.EVENT_SEVERITY, Constant.EVENT_SEVERITY_DEFAULT);
            String[] parsedValues = currentSetting.trim().split(",");
            if (!(currentSetting.trim().isEmpty() || parsedValues.length == EventSeverity.values().length)) {
                EventSeverity[] filterSeverities = new EventSeverity[parsedValues.length];
                int index = 0;
                for (String severity : parsedValues) {
                    EventSeverity p = EventSeverity.valueOf(severity);
                    filterSeverities[index++] = p;
                }
                criteria.addFilterSeverities(filterSeverities);
            }

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

                boolean isAdvanced = Boolean.valueOf(configuration.getSimpleValue(Constant.METRIC_RANGE_BEGIN_END_FLAG,
                    Constant.METRIC_RANGE_BEGIN_END_FLAG_DEFAULT));
                if (isAdvanced) {
                    //Advanced time settings
                    currentSetting = configuration.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 = configuration.getSimple(Constant.METRIC_RANGE_LASTN);
                    if (property != null) {
                        Integer lastN = Integer.valueOf(configuration.getSimpleValue(Constant.METRIC_RANGE_LASTN,
                            Constant.METRIC_RANGE_LASTN_DEFAULT));
                        Integer units = Integer.valueOf(configuration.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)));
                    }
                }
            }

            // add any context related filters
            switch (getEntityContext().type) {
            case Resource:
                criteria.addFilterResourceId(getEntityContext().getResourceId());
                break;
            case ResourceGroup:
                criteria.addFilterResourceGroupId(getEntityContext().getGroupId());
            case SubsystemView:
                // event resource name filter
                currentSetting = this.configuration.getSimpleValue(Constant.EVENT_RESOURCE, "");
                criteria.addFilterResourceName(currentSetting);
                break;
            default:
                // no default
                break;
            }
            criteria.fetchSource(true);

            return criteria;
        }
View Full Code Here

                    Event event = createEvent(eventSource, EventSeverity.INFO);
                    events.add(event);
                    em.persist(event);
                }
                em.flush();
                EventCriteria criteria = new EventCriteria();
                criteria.addFilterResourceId(resource.getId());
                criteria.setStrict(true);
                criteria.clearPaging();
                PageList<Event> foundEvents = eventManager.findEventsByCriteria(subjectManager.getOverlord(), criteria);
                assertNotNull(foundEvents);
                assertTrue("#findEventsByCriteria should have found all generated events",
                    events.containsAll(foundEvents) && foundEvents.containsAll(events));
            }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.criteria.EventCriteria

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.