Package org.rhq.core.domain.criteria

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


            });
    }

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

        if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
            int resourceId = getFilter(request, CriteriaField.RESOURCE_ID, Integer.class);
            criteria.addFilterResourceIds(resourceId);
        }

        if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_OPERATION_HISTORY_ID)) {
            int groupOperationHistoryId = getFilter(request, CriteriaField.GROUP_OPERATION_HISTORY_ID, Integer.class);
            criteria.addFilterGroupOperationHistoryId(groupOperationHistoryId);
        }

        return criteria;
    }
View Full Code Here


       
        if (remoteClient == null) {
            throw new IllegalStateException("The waitForScheduledOperationToComplete() method requires a connection to the RHQ server.");
        }
       
        ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
        criteria.addFilterJobId(schedule.getJobId());
        criteria.addFilterResourceIds(schedule.getResource().getId());
        criteria.addSortStartTime(PageOrdering.DESC);
        criteria.setPaging(0, 1);
        criteria.fetchOperationDefinition(true);
        criteria.fetchParameters(true);
        criteria.fetchResults(true);

        ResourceOperationHistory history = null;

        int i = 0;
View Full Code Here

            OperationManagerRemote operationManager = remoteClient.getProxy(OperationManagerRemote.class);

            ResourceOperationSchedule schedule = operationManager.scheduleResourceOperation(remoteClient.getSubject(),
                resourceId, definition.getName(), 0, 0, 0, 30000, parameters, "Executed from commandline");

            ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
            criteria.addFilterJobId(schedule.getJobId());
            criteria.addFilterResourceIds(resourceId);
            criteria.addSortStartTime(PageOrdering.DESC); // put most recent at top of results
            criteria.setPaging(0, 1); // only return one result, in effect the latest
            criteria.fetchOperationDefinition(true);
            criteria.fetchParameters(true);
            criteria.fetchResults(true);

            int retries = 10;
            ResourceOperationHistory history = null;
            while (history == null && retries-- > 0) {
                Thread.sleep(1000);
View Full Code Here

            return result.size();
        }

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

            // 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 op histories, apply a descending ordering on create time.
            int pageNumber = 0;
            int pageSize = Integer.valueOf(currentSetting);
            OrderingField orderingField = new OrderingField(OperationHistoryDataSource.Field.CREATED_TIME,
                PageOrdering.DESC);
            criteria.setPageControl(new PageControl(pageNumber, pageSize, orderingField));

            // status
            currentSetting = this.configuration.getSimpleValue(Constant.OPERATION_STATUS,
                Constant.OPERATION_STATUS_DEFAULT);
            String[] parsedValues = currentSetting.trim().split(",");
            if (!(currentSetting.trim().isEmpty() || parsedValues.length == OperationRequestStatus.values().length)) {
                OperationRequestStatus[] operationStatuses = new OperationRequestStatus[parsedValues.length];
                int indx = 0;
                for (String priority : parsedValues) {
                    OperationRequestStatus s = OperationRequestStatus.valueOf(priority);
                    operationStatuses[indx++] = s;
                }
                criteria.addFilterStatuses(operationStatuses);
            }

            //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.addFilterGroupOperationHistoryId(getEntityContext().getGroupId());
            }

            return criteria;
        }
View Full Code Here

                    waitingForPlugins = false;
                }

                @Override
                public void onSuccess(Void result) {
                    final ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
                    criteria.addFilterResourceIds(resourceId);
                    criteria.addFilterOperationName("retrieveAllPluginInfo");
                    criteria.addSortEndTime(PageOrdering.DESC);
                    criteria.fetchResults(true);
                    new Timer() {
                        @Override
                        public void run() {
                            GWTServiceLookup.getOperationService().findResourceOperationHistoriesByCriteria(criteria,
                                new AsyncCallback<PageList<ResourceOperationHistory>>() {
View Full Code Here

        if (statusFilter == null || statusFilter.length == 0) {
            return null; // user didn't select any severities - return null to indicate no data should be displayed
        }

        ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();

        criteria.addFilterStatuses(statusFilter);

        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.type) {
        case Resource:
            criteria.addFilterResourceIds(entityContext.resourceId);
            break;

        case ResourceGroup:
            criteria.addFilterGroupOperationHistoryId(entityContext.groupId);
            break;
        }

        return criteria;
    }
View Full Code Here

TOP

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

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.