Package org.rhq.core.domain.criteria

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


        MeasurementDataManagerUtility dataUtil = MeasurementDataManagerUtility.getInstance(rhqDs);

        // Loop over the definitions, find matching schedules and create a MetricDisplaySummary for each definition
        for (int definitionId : measurementDefinitionIds) {

            MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
            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);
            }
            criteria.addFilterDefinitionIds(definitionId);
            criteria.clearPaging();//disable paging as the code assumes all the results will be returned.

            PageList<MeasurementSchedule> theSchedules = scheduleManager.findSchedulesByCriteria(subject, criteria);
            int totalScheduleCount = theSchedules.getTotalSize();

            criteria.addFilterEnabled(true);
            criteria.setPageControl(PageControl.getSingleRowInstance()); // get single row only, we want totalSize
            theSchedules = scheduleManager.findSchedulesByCriteria(subject, criteria);
            int collecting = theSchedules.getTotalSize();

            /*
             * If no metric is collecting, stop here as we have nothing to contribute
View Full Code Here


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

        MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
        criteria.clearPaging(); //important to avoid setting the ordering in the generated query
        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);
        }
        criteria.addFilterDefinitionIds(ArrayUtils.wrapInArray(measurementDefinitionIds));

        CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
        ;
        generator.alterProjection("measurementschedule.id");
        String measurementScheduleSubQuery = generator.getParameterReplacedQuery(false);
View Full Code Here

                definitionIntervalMap.put(definition.getId(), definition.getDefaultInterval());
                definitionEnabledMap.put(definition.getId(), definition.isDefaultOn());
            }
        } else {
            // Do general criteria setup.
            MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();

            switch (context.type) {
            case Resource:
                criteria.addFilterResourceId(context.resourceId);
                break;
            case ResourceGroup:
                criteria.addFilterResourceGroupId(context.groupId);
                break;
            case AutoGroup:
                criteria.addFilterAutoGroupParentResourceId(context.parentResourceId);
                criteria.addFilterAutoGroupResourceTypeId(context.resourceTypeId);
                break;
            }

            criteria.setPageControl(pc); // for primary return list, use passed PageControl
            pc.addDefaultOrderingField("definition.displayName");

            // Get the core definitions.
            CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);

            // We previously used the following altered projection for the criteria query:
            //
            //   generator.alterProjection(" distinct measurementschedule.definition");
            //
            // Hibernate4 no longer allowed for the generated criteria JPQL for this projection:
            //
            //    SELECT distinct measurementschedule.definition
            //      FROM MeasurementSchedule measurementschedule
            // LEFT JOIN measurementschedule.definition orderingField0
            //     WHERE ( measurementschedule.resource.id IN ( :resourceId ) )
            //  ORDER BY orderingField0.displayName ASC
            //
            // It causes:
            //   SQLGrammarException: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
            //
            // In essence, using DISTINCT now requires that we use the LEFT JOIN alias in the select
            // list.  To support this we could probably have made some tricky coding changes to the
            // generator. But seeing that this would be to support non-default criteria queries (i.e
            // the altered projection using DISTINCT), of which this is the only one in the code base,
            // and we are in control of the order by clause, and therefore are predictably working with
            // the JPQL above, I've chosen to just make a change to the custom altered projection, using
            // the JPQL to guide me.
            generator.alterProjection(" distinct orderingField0");
            generator.alterCountProjection(" count(distinct orderingField0)");
            CriteriaQueryRunner<MeasurementDefinition> queryRunner = new CriteriaQueryRunner(criteria, generator,
                entityManager);
            definitions = queryRunner.execute();

            // Reset paging -- remove ordering, add group by.
            criteria.setPageControl(PageControl.getUnlimitedInstance());
            generator.setGroupByClause(" measurementschedule.definition.id ");

            // Get the interval results.
            generator.alterProjection("" //
                + " measurementschedule.definition.id, " //
                + " min(measurementschedule.interval), " //
                + " max(measurementschedule.interval) ");
            Query query = generator.getQuery(entityManager);
            List<Object[]> definitionIntervalResults = query.getResultList();

            // Get the enabled results.
            criteria.addFilterEnabled(true);
            generator.alterProjection(" measurementschedule.definition.id, count(measurementschedule.id) ");
            query = generator.getQuery(entityManager);
            List<Object[]> definitionEnabledResults = query.getResultList();

            // Generate intermediate maps for intervals and enabled values.
View Full Code Here

        }
    }

    @Override
    public void saveNewBaselines(Set<Integer> scheduleIds, Map<Integer, MeasurementBaseline> baselines) {
        MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
        criteria.addFilterIds(scheduleIds.toArray(new Integer[scheduleIds.size()]));
        criteria.setPageControl(PageControl.getUnlimitedInstance());
        List<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByCriteria(
            subjectManager.getOverlord(), criteria);
        for (MeasurementSchedule schedule : schedules) {
            MeasurementBaseline baseline = baselines.get(schedule.getId());
            baseline.setScheduleId(schedule.getId());
View Full Code Here

    @Deprecated
    @Override
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public org.rhq.enterprise.server.measurement.MeasurementAggregate getAggregate(Subject subject, int scheduleId, long startTime, long endTime) {
        MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
        criteria.addFilterId(scheduleId);
        criteria.fetchResource(true);

        PageList<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByCriteria(
            subjectManager.getOverlord(), criteria);
        if (schedules.isEmpty()) {
            throw new MeasurementException("Could not fine MeasurementSchedule with the id[" + scheduleId + "]");
View Full Code Here

    @Override
    public MeasurementAggregate getMeasurementAggregate(Subject subject, int scheduleId, long startTime, long endTime) {
        Stopwatch stopwatch = new Stopwatch().start();
        try {
            MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
            criteria.addFilterId(scheduleId);
            criteria.fetchResource(true);

            PageList<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByCriteria(
                subjectManager.getOverlord(), criteria);
            if (schedules.isEmpty()) {
                throw new MeasurementException("Could not fine MeasurementSchedule with the id[" + scheduleId + "]");
View Full Code Here

        if (startTime > endTime) {
            throw new IllegalArgumentException("Start date " + startTime + " is not before " + endTime);
        }

        MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
        criteria.addFilterResourceGroupId(groupId);
        criteria.addFilterDefinitionIds(definitionId);
        criteria.setPageControl(PageControl.getUnlimitedInstance());
        PageList<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByCriteria(subject,
            criteria);

        MetricsServer metricsServer = storageClientManager.getMetricsServer();
        AggregateNumericMetric summary = metricsServer.getSummaryAggregate(map(schedules), startTime, endTime);
View Full Code Here

            if (!authorizationManager.canViewGroup(subject, context.groupId)) {
                throw new PermissionException("User [" + subject.getName()
                    + "] does not have permission to view measurement data for resourceGroup[id=" + context.groupId
                    + "]");
            }
            MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
            criteria.addFilterResourceGroupId(context.getGroupId());
            criteria.addFilterDefinitionIds(definitionId);
            criteria.setPageControl(PageControl.getUnlimitedInstance());
            PageList<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByCriteria(subject,
                criteria);
            List<List<MeasurementDataNumericHighLowComposite>> data =
                new ArrayList<List<MeasurementDataNumericHighLowComposite>>();
View Full Code Here

        CacheKey key = new CacheKey("existsScheduleForCaller", (31 * (1 + scheduleId) * 31 * (1 + caller.getId())));
        Boolean accessible = (Boolean) cache.get(key);
        if (accessible != null) {
            return accessible.booleanValue();
        } else {
            MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
            criteria.addFilterId(scheduleId);
            PageList<MeasurementSchedule> schedules = scheduleManager.findSchedulesByCriteria(caller, criteria);
            if (schedules.isEmpty()) {
                cache.put(key, Boolean.FALSE);
                return false;
            }
View Full Code Here

        recentMeasurementsContent.addChild(column);
        recentMeasurementsContent.markForRedraw();
    }

    private void fetchEnabledSchedules(final CountDownLatch latch) {
        MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
        criteria.addFilterEnabled(true);
        criteria.fetchDefinition(true);
        criteria.setPageControl(PageControl.getUnlimitedInstance());
        addFilterKey(criteria);
        GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria,
            new AsyncCallback<PageList<MeasurementSchedule>>() {

                @Override
View Full Code Here

TOP

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

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.