Package org.rhq.core.domain.criteria

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


        MongoDBChangeSetEntry e4 = new MongoDBChangeSetEntry("c2-1.txt", FILE_ADDED);
        MongoDBChangeSetEntry e5 = new MongoDBChangeSetEntry("c3-1.txt", FILE_ADDED);
        c3.add(e4).add(e5);
        dao.save(c3);

        GenericDriftCriteria criteria = new GenericDriftCriteria();
        criteria.addFilterPath("c2-1.txt");

        List<MongoDBChangeSetEntry> entries = dao.findEntries(criteria);
        assertEntriesMatch("Failed to find change set entries with path filter", asList(e3, e4), entries);
    }
View Full Code Here


        MongoDBChangeSet c2 = createChangeSet(DRIFT, 2, 1, 1);
        c2.add(new MongoDBChangeSetEntry("c1-1.txt", FILE_CHANGED));

        dao.save(c2);

        GenericDriftCriteria criteria = new GenericDriftCriteria();
        criteria.addFilterChangeSetId(c2.getId());

        List<MongoDBChangeSet> actual = dao.findByDriftCriteria(criteria);

        assertChangeSetsMatchNoOrder("Failed to find change sets by drift criteria with change set id filter", asList(c2),
                actual);
View Full Code Here

        String pathFilter = getFilter(request, FILTER_PATH, String.class);

        // NOTE! This criteria does not allow for query-time definition name filtering. That filter is applied lazily
        // to the query results.

        GenericDriftCriteria criteria = new GenericDriftCriteria();
        // grab the change set for the drift
        criteria.fetchChangeSet(true);

        // only get the desired drift categories
        criteria.addFilterCategories(categoriesFilter);

        // only get the desired changeset version (substring match)
        if (null != changeSetFilter && !changeSetFilter.isEmpty()) {
            try {
                Integer version = Integer.valueOf(changeSetFilter);
                criteria.addFilterChangeSetStartVersion(version);
                criteria.addFilterChangeSetEndVersion(version);
            } catch (Exception e) {
                // ignore the specified filter, it's an invalid integer
                // do not fetch tracking entries from the coverage changeset
                criteria.addFilterChangeSetStartVersion(1);
            }
        } else {
            // do not fetch tracking entries from the coverage changeset
            criteria.addFilterChangeSetStartVersion(1);
        }

        // only get the desired paths (substring match)
        if (null != pathFilter && !pathFilter.isEmpty()) {
            criteria.addFilterPath(pathFilter);
        }

        // do not get planned drifts
        criteria.addFilterDriftHandlingModes(DriftHandlingMode.normal);

        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());
        }


        switch (entityContext.getType()) {
        case Resource:
            criteria.addFilterResourceIds(entityContext.getResourceId());
            break;
        case ResourceGroup:
            // TODO ?
            break;
        default:
View Full Code Here

            return result.size();
        }

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

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

            // We have to set a PageControl override here, or RPCDataSource will apply default paging based on the
            // request. But, once setting a paging override the CriteriaQueryGenerator will use it for
            // paging *and* sorting, so we need to also ensure our desired sorting is included in the override. So,
            // to get the most recent drifts, apply a descending ordering on create time.
            int pageNumber = 0;
            int pageSize = Integer.valueOf(currentSetting);
            OrderingField orderingField = new OrderingField("ctime", PageOrdering.DESC);
            criteria.setPageControl(new PageControl(pageNumber, pageSize, orderingField));

            // filter priority
            currentSetting = this.configuration.getSimpleValue(DRIFT_CATEGORY, DRIFT_CATEGORY_DEFAULT);
            String[] parsedValues = currentSetting.trim().split(",");
            if (!(currentSetting.trim().isEmpty() || parsedValues.length == 3)) {
                DriftCategory[] filterCategories = new DriftCategory[parsedValues.length];
                int i = 0;
                for (String priority : parsedValues) {
                    DriftCategory c = DriftCategory.valueOf(priority);
                    filterCategories[i++] = c;
                }
                criteria.addFilterCategories(filterCategories);
            }

            //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.addFilterResourceIds(getEntityContext().getResourceId());
                break;

            /*
            case ResourceGroup:
                criteria.addFilterResourceGroupIds(getEntityContext().getGroupId());
            */
            }

            criteria.fetchChangeSet(true);

            return criteria;
        }
View Full Code Here

TOP

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

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.