Package org.rhq.core.domain.criteria

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


    }

    @Override
    protected void fetchResourceType(final CountDownLatch latch, final VLayout layout) {
        //locate resource reference
        ResourceCriteria criteria = new ResourceCriteria();
        criteria.addFilterId(this.resourceId);

        //locate the resource
        GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
            new AsyncCallback<PageList<ResourceComposite>>() {
                @Override
View Full Code Here


            }
        });
    }

    private Resource loadResourceWithSchedules(int resourceId) {
        ResourceCriteria resourceCriteria = new ResourceCriteria();
        resourceCriteria.addFilterId(resourceId);
        resourceCriteria.fetchSchedules(true);
        Resource resourceWithSchedules = getResource(resourceCriteria);
        assert resourceWithSchedules != null : "could not obtain resource from DB";
        assert resourceWithSchedules.getSchedules() != null && resourceWithSchedules.getSchedules().size() == 1 : "missing schedule";
        return resourceWithSchedules;
    }
View Full Code Here

    protected void loadData() {
        final DashboardPortlet storedPortlet = this.portletWindow.getStoredPortlet();
        final Configuration portletConfig = storedPortlet.getConfiguration();
        //populate composite data
        //locate resourceRef
        ResourceCriteria criteria = new ResourceCriteria();
        criteria.addFilterId(this.resourceId);
        criteria.fetchResourceConfigurationUpdates(false);
        criteria.fetchOperationHistories(false);

        //locate the resource
        GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
            new AsyncCallback<PageList<ResourceComposite>>() {
                @Override
                public void onFailure(Throwable caught) {
                    Log.debug("Error retrieving resource composite for resource [" + resourceId + "]:"
                        + caught.getMessage());
                    currentlyLoading = false;
                }

                @Override
                public void onSuccess(PageList<ResourceComposite> results) {
                    if (!results.isEmpty()) {
                        resourceComposite = results.get(0);
                        //instantiate view

                        PageControl lastFive = new PageControl(0, 5);
                        ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
                        criteria.setPageControl(lastFive);
                        //TODO: spinder: move this up into the pageControl.
                        criteria.addSortStatus(PageOrdering.DESC);
                        criteria.addFilterResourceIds(resourceId);

                        resourceHistoryTable = new ResourceConfigurationHistoryCriteriaView(resourceComposite
                            .getResourcePermission().isConfigureWrite(), resourceId);
                    } else {
                        resourceHistoryTable = new ResourceConfigurationHistoryCriteriaView(resourceComposite
View Full Code Here

        alertDefinitionManager.createAlertDefinitionInNewTransaction(getOverlord(), alertDef, newResource.getId(), true);

        //obvious, right? This needs to be done for the alert subsystem to become aware of the new def
        LookupUtil.getAlertConditionCacheManager().reloadAllCaches();

        ResourceCriteria crit = new ResourceCriteria();
        crit.addFilterId(newResource.getId());
        crit.fetchCurrentAvailability(true);
        Resource fromDb = resourceManager.findResourcesByCriteria(getOverlord(), crit).get(0);

        assertEquals(AvailabilityType.UNKNOWN, fromDb.getCurrentAvailability().getAvailabilityType());

        //ask for the live avail - the mock agent response will return "DOWN" the first time
View Full Code Here

        assertEquals("Unexpected number of alerts on the resource.", 1, alerts.size());
    }

    // we can add a lot more here, but this mainly exists to test some criteria stuff not obviously tested elsewhere
    public void testFindByResourceCriteria() {
        ResourceCriteria c = new ResourceCriteria();

        List<Resource> result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertNotNull(result);
        assertEquals(1, result.size());

        c.addFilterPluginName("TES");
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(1, result.size());

        c.setStrict(true);
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(0, result.size());

        c.setStrict(false);
        c.setCaseSensitive(true);
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(0, result.size());

        c.setCaseSensitive(false);
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(1, result.size());

        c.setStrictFilters("foo");
        c.setCaseSensitiveFilters("foo");
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(1, result.size());

        c.setStrictFilters("pluginName", "foo");
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(0, result.size());

        c.setStrictFilters(null);
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(1, result.size());

        c.setCaseSensitiveFilters("pluginName", "foo");
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(0, result.size());

        c.setCaseSensitiveFilters("pluginName", "foo");
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(0, result.size());

        c.setStrictFilters("pluginName", "foo");
        c.setCaseSensitiveFilters("pluginName", "foo");
        c.addFilterPluginName("test");
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(1, result.size());

        c.addFilterPluginName("TEST");
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(0, result.size());

        c.addFilterPluginName("testy");
        result = resourceManager.findResourcesByCriteria(getOverlord(), c);
        assertEquals(0, result.size());
    }
View Full Code Here

                    AlertDefinition alertDef = copyValues(record);
                    if (alertDef.getParentId() != null && alertDef.getParentId().intValue() > 0) {
                        final Integer templateId = alertDef.getParentId().intValue();
                        final Integer resourceId = alertDef.getResource().getId();

                        ResourceCriteria resCriteria = new ResourceCriteria();
                        resCriteria.addFilterId(resourceId);
                        resCriteria.fetchResourceType(true);

                        GWTServiceLookup.getResourceService().findResourcesByCriteria(resCriteria,
                            new AsyncCallback<PageList<Resource>>() {
                                @Override
                                public void onSuccess(PageList<Resource> result) {
View Full Code Here

        //result count
        final String resultCount;
        String resultCountRaw = portletConfig.getSimpleValue(Constant.RESULT_COUNT, Constant.RESULT_COUNT_DEFAULT);
        resultCount = (resultCountRaw.trim().isEmpty()) ? Constant.RESULT_COUNT_DEFAULT :  resultCountRaw;

        ResourceCriteria criteria = new ResourceCriteria();
        criteria.addFilterId(resourceId);
        criteria.fetchResourceType(true);

        //locate the resource
        GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
                new AsyncCallback<PageList<ResourceComposite>>() {
                    @Override
View Full Code Here

                + (System.currentTimeMillis() - start) + " ms.");

            assert resourceNames.size() == resourceCount;//assert all resources loaded/created

            //query the results and delete the resources
            ResourceCriteria criteria = new ResourceCriteria();
            criteria.addFilterName(prefix);
            criteria.addSortName(PageOrdering.DESC); // use DESC just to make sure sorting on name is different than insert order
            criteria.setPaging(0, 47);

            //iterate over the results with CriteriaQuery
            CriteriaQueryExecutor<Resource, ResourceCriteria> queryExecutor = new CriteriaQueryExecutor<Resource, ResourceCriteria>() {
                @Override
                public PageList<Resource> execute(ResourceCriteria criteria) {
View Full Code Here

                + (System.currentTimeMillis() - start) + " ms.");

            assert resourceNames.size() == resourceCount;//assert all resources loaded/created

            //query the results and delete the resources, use default ID search
            ResourceCriteria criteria = new ResourceCriteria();
            criteria.addFilterName(prefix);
            criteria.setPaging(0, 25);

            //iterate over the results with CriteriaQuery
            CriteriaQueryExecutor<Resource, ResourceCriteria> queryExecutor = new CriteriaQueryExecutor<Resource, ResourceCriteria>() {
                @Override
                public PageList<Resource> execute(ResourceCriteria criteria) {
View Full Code Here

                + (System.currentTimeMillis() - start) + " ms.");

            assert resourceNames.size() == resourceCount;//assert all resources loaded/created

            //query the results and delete the resources, use default ID search
            ResourceCriteria criteria = new ResourceCriteria();
            criteria.addFilterName(prefix);
            PageControl pc = new PageControl(0, 73);
            criteria.setPageControl(pc);
            assert pc.getOrderingFields().isEmpty() : "Should not have had any sorting defined";

            //iterate over the results with CriteriaQuery
            CriteriaQueryExecutor<Resource, ResourceCriteria> queryExecutor = new CriteriaQueryExecutor<Resource, ResourceCriteria>() {
                @Override
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.