Package org.rhq.core.domain.criteria

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


        });
    }

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

        printRequestCriteria(request);
        criteria.addFilterId(getFilter(request, "id", Integer.class));
        criteria.addFilterParentResourceId(getFilter(request, "parentId", Integer.class));
        criteria.addFilterCurrentAvailability(getFilter(request, AVAILABILITY.propertyName(), AvailabilityType.class));
        criteria.addFilterResourceCategories(getArrayFilter(request, CATEGORY.propertyName(), ResourceCategory.class));
        criteria.addFilterIds(getArrayFilter(request, FILTER_RESOURCE_IDS, Integer.class));
        criteria.addFilterExplicitGroupIds(getFilter(request, FILTER_GROUP_ID, Integer.class));
        criteria.addFilterName(getFilter(request, NAME.propertyName(), String.class));
        criteria.addFilterResourceTypeId(getFilter(request, TYPE.propertyName(), Integer.class));
        criteria.addFilterPluginName(getFilter(request, PLUGIN.propertyName(), String.class));
        criteria.addFilterTagNamespace(getFilter(request, "tagNamespace", String.class));
        criteria.addFilterTagSemantic(getFilter(request, "tagSemantic", String.class));
        criteria.addFilterTagName(getFilter(request, "tagName", String.class));
        criteria.addFilterVersion(getFilter(request, "version", String.class));
        criteria.addFilterParentResourceCategory(getFilter(request, FILTER_PARENT_CATEGORY, ResourceCategory.class));

        // we never want to filter on null status - that would return resources for every status (committed, new, deleted, etc).
        // we want to rely on whatever the default setting is for the criteria and only override that if we explicitly have a status to filter.
        InventoryStatus invStatusFilter = getFilter(request, INVENTORY_STATUS.propertyName(), InventoryStatus.class);
        if (invStatusFilter != null) {
            criteria.addFilterInventoryStatus(invStatusFilter);
        }

        InventoryStatus parentInvStatusFilter = getFilter(request, PARENT_INVENTORY_STATUS.propertyName(),
            InventoryStatus.class);
        if (parentInvStatusFilter != null) {
            List<InventoryStatus> statuses = new ArrayList<InventoryStatus>(1);
            statuses.add(parentInvStatusFilter);
            criteria.addFilterParentInventoryStatuses(statuses);
        }

        //@todo: Remove me when finished debugging search expression
        Log.debug(" *** ResourceCriteria Search String: " + getFilter(request, "search", String.class));
        criteria.setSearchExpression(getFilter(request, "search", String.class));

        // filter out unsortable fields (i.e. fields sorted client-side only)
        PageControl pageControl = getPageControl(request);
        pageControl.removeOrderingField(AncestryUtil.RESOURCE_ANCESTRY);
        criteria.setPageControl(pageControl);

        return criteria;
    }
View Full Code Here


            // This fetch limits the number of resources that can be returned to protect against fetching a massive
            // number of children for a parent. Doing so may cause an unacceptably slow tree rendering, too much vertical
            // scroll, or perhaps even hang the gui if it consumed too many resources.  To see all children the
            // user will need to visit the Inventory->Children view for the resource.
            ResourceCriteria criteria = new ResourceCriteria();
            criteria.addFilterParentResourceId(Integer.parseInt(parentResourceId));
            // we must sort the results to ensure that if cropped we at least show the same results each time
            criteria.addSortName(PageOrdering.ASC);

            resourceService.findResourcesByCriteriaBounded(criteria, -1, -1, new AsyncCallback<List<Resource>>() {
                public void onFailure(Throwable caught) {
                    CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_loadFailed_children(), caught);
                    response.setStatus(RPCResponse.STATUS_FAILURE);
View Full Code Here

        return resourceMgr.findResourceComplianceCounts(caller);
    }

    @Override
    protected ResourceCriteria getDetailsQueryCriteria(Integer resourceTypeId, String version) {
        ResourceCriteria criteria = super.getDetailsQueryCriteria(resourceTypeId, version);
        criteria.fetchDriftDefinitions(true);
        return criteria;
    }
View Full Code Here

                        });
                    } else {
                        final int platformResourceId = Integer.valueOf(platformId);
                        final Resource parentResourceStub = new Resource(platformResourceId);

                        ResourceCriteria fetchCriteria = new ResourceCriteria();
                        fetchCriteria.addFilterParentResourceId(platformResourceId);
                        fetchCriteria.addFilterResourceCategories(ResourceCategory.SERVER);
                        fetchCriteria.addFilterInventoryStatuses(statuses);
                        fetchCriteria.clearPaging();
                        fetchCriteria.addSortName(PageOrdering.ASC);
                        resourceService.findResourcesByCriteria(fetchCriteria, new AsyncCallback<PageList<Resource>>() {
                            public void onFailure(Throwable caught) {
                                CoreGUI.getErrorHandler().handleError(MSG.view_autoDiscoveryQ_loadFailure(), caught);
                                for (AsyncCallback failedFetchListener : failedFetchListeners) {
                                    failedFetchListener.onFailure(caught);
View Full Code Here

        availAndErrorRefresher.stop();
        super.onDestroy();
    }

    private void loadTags(final TagEditorView tagEditorView) {
        ResourceCriteria criteria = new ResourceCriteria();
        criteria.addFilterId(resource.getId());
        criteria.fetchTags(true);
        GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria,
            new AsyncCallback<PageList<Resource>>() {
                public void onFailure(Throwable caught) {
                    CoreGUI.getErrorHandler().handleError(MSG.view_titleBar_common_loadTagsFailure(resource.getName()),
                        caught);
View Full Code Here

                        processResponse(request.getRequestId(), response);
                    }
                });

        } else if (request.getCriteria().getValues().containsKey("resourceId")) {
            ResourceCriteria rCriteria = new ResourceCriteria();
            rCriteria.addFilterId(request.getCriteria().getAttributeAsInt("resourceId"));
            rCriteria.fetchResourceType(true);

            GWTServiceLookup.getResourceService().findResourcesByCriteria(rCriteria,
                new AsyncCallback<PageList<Resource>>() {
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError(MSG.dataSource_schedules_loadFailed(), caught);
View Full Code Here

            env.add(createLargeGroupWithNormalUserRoleAccessWithInventoryStatus(lgeWithTypes, gac.total, gac.down,
                gac.unknown, gac.disabled, gac.uncommitted, Permission.CONFIGURE_READ));
            lgeWithTypes = env.get(0);
        }

        ResourceCriteria criteria = new ResourceCriteria();
        List<Resource> result;

        SessionTestHelper.simulateLogin(env.get(0).normalSubject);

        criteria.addFilterParentResourceId(lgeWithTypes.platformResource.getId());
        criteria.setPageControl(PageControl.getUnlimitedInstance());
        result = resourceManager.findResourcesByCriteria(env.get(0).normalSubject, criteria);
        assert null != result;
        assert result.size() == 1100 : "Expected unbounded query to return all 1100 resources";

        result = resourceManager.findResourcesByCriteriaBounded(env.get(0).normalSubject, criteria, 2000, 100);
View Full Code Here

    }

    private void queryResource(Integer entityId, final Integer measurementDefId) {
        ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();

        ResourceCriteria resourceCriteria = new ResourceCriteria();
        resourceCriteria.addFilterId(entityId);
        resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() {
            @Override
            public void onFailure(Throwable caught) {
                CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught);
            }
View Full Code Here

    }

    private void fetchFavorites(Set<Integer> resourceIds, final Set<Integer> groupIds,
        final AsyncCallback<Favorites> callback) {

        ResourceCriteria criteria = new ResourceCriteria();
        criteria.addFilterIds(resourceIds.toArray(new Integer[resourceIds.size()]));
        GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria,
            new AsyncCallback<PageList<Resource>>() {
                public void onFailure(Throwable caught) {
                    callback.onFailure(caught);
                }

                public void onSuccess(final PageList<Resource> resources) {

                    if (groupIds.isEmpty()) {
                        callback.onSuccess(new Favorites(resources, new PageList<ResourceGroupComposite>()));
                        return;
                    }

                    ResourceGroupCriteria criteria = new ResourceGroupCriteria();
                    criteria.addFilterIds(groupIds.toArray(new Integer[groupIds.size()]));
                    GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
                        new AsyncCallback<PageList<ResourceGroupComposite>>() {
                            public void onFailure(Throwable caught) {
                                callback.onFailure(caught);
                            }
View Full Code Here

     * @param opId if not-null, the selected operation
     * @param args if not-null (and opId is not null), this will prepopulate the argument config
     */
    private void setSpecificResource(final int resourceId, final Integer opId, final Configuration args) {
        singleResourceTextItem.setAttribute(RESOURCE_ID_ATTRIBUTE, resourceId);
        ResourceCriteria criteria = new ResourceCriteria();
        criteria.addFilterId(resourceId);
        criteria.fetchResourceType(true);
        GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria,
            new AsyncCallback<PageList<Resource>>() {
                @Override
                public void onSuccess(PageList<Resource> result) {
                    if (result.size() > 0) {
View Full Code Here

TOP

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

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.