Package org.rhq.core.domain.criteria

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


        PageList<BundleFile> files = bundleManager.findBundleFilesByCriteria(overlord, bfCriteria);
        assert files.size() == 1 : files;
        assert files.get(0).getPackageVersion().getGeneralPackage().getName().equals("testDeleteBundleVersion") : files;

        BundleVersionCriteria bvCriteria = new BundleVersionCriteria();
        BundleCriteria bCriteria = new BundleCriteria();

        // delete the first one - this deletes the BV but the bundle should remain intact
        bundleManager.deleteBundleVersion(subject, bv2.getId(), true);
        bvCriteria.addFilterId(bv2.getId());
        PageList<BundleVersion> bvResults = bundleManager.findBundleVersionsByCriteria(subject, bvCriteria);
        assert bvResults.size() == 0;
        bCriteria.addFilterId(b1.getId());
        PageList<Bundle> bResults = bundleManager.findBundlesByCriteria(subject, bCriteria);
        assert bResults.size() == 1 : "Should not have deleted bundle yet, 1 version still exists";

        // delete the second one - this deletes last BV thus the bundle should also get deleted
        bundleManager.deleteBundleVersion(subject, bv1.getId(), true);
        bvCriteria.addFilterId(bv1.getId());
        bvResults = bundleManager.findBundleVersionsByCriteria(subject, bvCriteria);
        assert bvResults.size() == 0;
        bCriteria.addFilterId(b1.getId());
        bResults = bundleManager.findBundlesByCriteria(subject, bCriteria);
        assert bResults.size() == 0 : "Should have deleted bundle since no versions exists anymore";

        // make sure our composite query is OK and can show us 0 bundles, too
        PageList<BundleWithLatestVersionComposite> composites;
        bCriteria = new BundleCriteria();
        composites = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(subject, bCriteria);
        assert composites.size() == 0;
    }
View Full Code Here


    public BundleVersion createBundleAndBundleVersion(Subject subject, String bundleName, String bundleDescription,
        int bundleTypeId, int[] bundleGroupIds, String bundleVersionName, String bundleVersionDescription,
        String version, String recipe) throws Exception {

        // first see if the bundle exists or not; if not, create one
        BundleCriteria criteria = new BundleCriteria();
        criteria.setStrict(true);
        criteria.addFilterBundleTypeId(Integer.valueOf(bundleTypeId));
        criteria.addFilterName(bundleName);
        criteria.clearPaging(); //disable paging as the code assumes all the results will be returned.

        PageList<Bundle> bundles = findBundlesByCriteria(subject, criteria);
        Bundle bundle;
        if (bundles.getTotalSize() == 0) {
            bundle = createBundle(subject, bundleName, bundleDescription, bundleTypeId, bundleGroupIds);
View Full Code Here

        String version = info.getRecipeParseResults().getBundleMetadata().getBundleVersion();
        String recipe = info.getRecipe();

        // first see if the bundle exists or not
        boolean createdBundle;
        BundleCriteria criteria = new BundleCriteria();
        criteria.setStrict(true);
        criteria.addFilterBundleTypeId(bundleType.getId());
        criteria.addFilterName(bundleName);

        PageList<Bundle> bundles = bundleManager.findBundlesByCriteria(subject, criteria);
        Bundle bundle;
        boolean isInitialVersion = (bundles.getTotalSize() == 0);
View Full Code Here

        bdc.fetchBundleVersion(true);
        bdc.fetchConfiguration(true);
        bdc.fetchDestination(true);
        BundleDeployment deployment = bundleManager.findBundleDeploymentsByCriteria(subject, bdc).get(0);

        BundleCriteria bc = new BundleCriteria();
        bc.addFilterDestinationId(deployment.getDestination().getId());
        Bundle bundle = bundleManager.findBundlesByCriteria(subject, bc).get(0);

        ResourceTypeCriteria rtc = new ResourceTypeCriteria();
        rtc.addFilterIgnored(false); // we only care about those that are not ignored
        rtc.addFilterBundleTypeId(bundle.getBundleType().getId());
View Full Code Here

        if (bundleType == null) {
            return;
        }

        BundleCriteria criteria = new BundleCriteria();
        criteria.addFilterBundleTypeId(bundleType.getId());

        //Use CriteriaQuery to automatically chunk/page through criteria query results
        CriteriaQueryExecutor<Bundle, BundleCriteria> queryExecutor = new CriteriaQueryExecutor<Bundle, BundleCriteria>() {
            @Override
            public PageList<Bundle> execute(BundleCriteria criteria) {
View Full Code Here

    }

    public class SelectedBundlesDataSource extends BundlesDataSource {
        @Override
        protected BundleCriteria getFetchCriteria(final DSRequest request) {
            BundleCriteria result = super.getFetchCriteria(request);
            if (null != result) {
                result.setStrict(false);
            }
            return result;
        }
View Full Code Here

            public void onClick(ClickEvent clickEvent) {

                // can change this back to SINGLE selection when we feel like it. currently allowing the wizard to
                // select the bundle.

                BundleCriteria bc = new BundleCriteria();
                bc.addFilterId(bundle.getId());
                BundleGWTServiceAsync bundleManager = GWTServiceLookup.getBundleService();
                bundleManager.findBundlesByCriteria(bc, new AsyncCallback<PageList<Bundle>>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        getErrorHandler().handleError(MSG.view_bundle_list_error1(bundle.getName()), caught);
View Full Code Here

        if (viewPath.isEnd() || viewPath.isNextEnd()) {

            if (bundleBeingViewed != bundleId) {
                bundleBeingViewed = bundleId;

                BundleCriteria criteria = new BundleCriteria();
                criteria.addFilterId(bundleId);
                criteria.fetchBundleVersions(true);
                criteria.fetchDestinations(true);
                criteria.fetchTags(true);

                GWTServiceLookup.getBundleService().findBundlesByCriteria(criteria,
                    new AsyncCallback<PageList<Bundle>>() {
                        @Override
                        public void onFailure(Throwable caught) {
View Full Code Here

        if (parentId == null) {

            // there is no parent - we are at the root of the tree
            // get the bundles and build the bundle groups (including unassigned) from that
            BundleCriteria criteria = new BundleCriteria();
            criteria.fetchBundleGroups(true);

            bundleService.findBundlesByCriteria(criteria, new AsyncCallback<PageList<Bundle>>() {
                public void onFailure(Throwable caught) {
                    CoreGUI.getErrorHandler().handleError(MSG.view_bundle_tree_loadFailure(), caught);
                    response.setStatus(DSResponse.STATUS_FAILURE);
                    processResponse(request.getRequestId(), response);
                }

                public void onSuccess(final PageList<Bundle> result) {
                    BundleGroup unassignedBundleGroup = new BundleGroup();
                    unassignedBundleGroup.setId(0); // ID=0 is an indicator we use to denote the unassigned group
                    unassignedBundleGroup.setName(MSG.view_bundle_tree_unassigned_name());
                    unassignedBundleGroup.setDescription(MSG.view_bundle_tree_unassigned_desc());

                    // Because findBundleGroupsByCriteria would not have given us all unassigned bundles, we used
                    // findBundlesByCriteria. But we need to organize our tree structure with groups at the top, so
                    // we need to put our results aggregated in groups.
                    HashMap<Integer, BundleGroup> visibleBundleGroups = new HashMap<Integer, BundleGroup>();
                    for (Bundle bundle : result) {
                        Set<BundleGroup> bundleBundleGroups = bundle.getBundleGroups();
                        if (bundleBundleGroups == null || bundleBundleGroups.isEmpty()) {
                            unassignedBundleGroup.addBundle(bundle);
                        } else {
                            for (BundleGroup bundleBundleGroup : bundleBundleGroups) {
                                BundleGroup theGroup = visibleBundleGroups.get(bundleBundleGroup.getId());
                                if (theGroup == null) {
                                    visibleBundleGroups.put(bundleBundleGroup.getId(), bundleBundleGroup);
                                    theGroup = bundleBundleGroup;
                                }
                                theGroup.addBundle(bundle);
                            }
                        }
                    }

                    final ArrayList<BundleGroup> allVisibleBundleGroups = new ArrayList<BundleGroup>(visibleBundleGroups.values());
                    if (!unassignedBundleGroup.getBundles().isEmpty()) {
                        allVisibleBundleGroups.add(unassignedBundleGroup);
                    }

                    BundleGroupCriteria bundleGroupCriteria = new BundleGroupCriteria();
                    bundleGroupCriteria.addFilterIds(visibleBundleGroups.keySet().toArray(new Integer[0]));
                    bundleService.findBundleGroupsByCriteria(bundleGroupCriteria, new AsyncCallback<PageList<BundleGroup>>() {
                        public void onFailure(Throwable caught) {
                            // just log a message, but keep going, this just means we can't show lock icons where applicable
                            CoreGUI.getErrorHandler().handleError(MSG.view_bundle_tree_loadFailure(), caught);
                        }

                        public void onSuccess(PageList<BundleGroup> result) {
                            // if any of the bundle group tree nodes represent bundle groups the user isn't allowed
                            // to see, then mark the node with a locked icon
                            HashSet<Integer> permittedBundleGroups = new HashSet<Integer>();
                            for (BundleGroup bg : result) {
                                permittedBundleGroups.add(bg.getId());
                            }
                            ListGridRecord[] dataRecords = buildRecords(allVisibleBundleGroups);
                            for (ListGridRecord dataRecord : dataRecords) {
                                // we only want to examine bundle group records - and they are the only ones
                                // with ID attributes that are a simple number without "_" character.
                                // Ignore the Unassigned Bundle Group (whose id = "0") - never show a lock for that.
                                TreeNode dataRecordNode = (TreeNode) dataRecord;
                                String idString = dataRecordNode.getAttribute("id");
                                if (!idString.contains("_") && !idString.equals("0")
                                    && !permittedBundleGroups.contains(Integer.valueOf(idString))) {
                                    dataRecordNode.setIcon(ImageManager.getLockedIcon());
                                    dataRecordNode.setEnabled(false);
                                }
                            }
                            response.setData(dataRecords);
                            response.setTotalRows(allVisibleBundleGroups.size());
                            processResponse(request.getRequestId(), response);
                        }
                    });
                }
            });

        } else {
            String[] splitParentId = parentId.split("_", 3); // <bundleGroupId>_<bundleId>_<and the rest>
            final Integer bundleGroupId = Integer.parseInt(splitParentId[0]);
            Integer tmp;
            try {
                tmp = Integer.parseInt(splitParentId[1]);
            } catch (NumberFormatException e) {
                tmp = null;
            }
            final Integer bundleId = tmp;

            // we are at an inner node, being asked to get the children of it
            if (parentId.endsWith("_versions")) {
                BundleVersionCriteria criteria = new BundleVersionCriteria();
                criteria.addFilterBundleId(bundleId);
                bundleService.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() {
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError(MSG.view_bundle_tree_loadFailure(), caught);
                        response.setStatus(DSResponse.STATUS_FAILURE);
                        processResponse(request.getRequestId(), response);
                    }

                    public void onSuccess(PageList<BundleVersion> result) {
                        response.setData(buildRecordsForKnownBundle(result, bundleGroupId, bundleId));
                        response.setTotalRows(result.getTotalSize());
                        processResponse(request.getRequestId(), response);
                    }
                });

            } else if (parentId.endsWith("_deployments")) {
                BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
                criteria.fetchBundleVersion(true);
                criteria.addFilterBundleId(bundleId);
                bundleService.findBundleDeploymentsByCriteria(criteria,
                        new AsyncCallback<PageList<BundleDeployment>>() {
                            public void onFailure(Throwable caught) {
                                CoreGUI.getErrorHandler().handleError(MSG.view_bundle_tree_loadFailure(), caught);
                            }

                            public void onSuccess(PageList<BundleDeployment> result) {
                                response.setData(buildRecordsForKnownBundle(result, bundleGroupId, bundleId));
                                processResponse(request.getRequestId(), response);
                            }
                        });

            } else if (parentId.endsWith("_destinations")) {
                BundleDestinationCriteria criteria = new BundleDestinationCriteria();
                criteria.addFilterBundleId(bundleId);
                criteria.fetchDeployments(true);
                bundleService.findBundleDestinationsByCriteria(criteria,
                    new AsyncCallback<PageList<BundleDestination>>() {
                        public void onFailure(Throwable caught) {
                            CoreGUI.getErrorHandler().handleError(MSG.view_bundle_tree_loadFailure(), caught);
                        }

                        public void onSuccess(PageList<BundleDestination> result) {
                            response.setData(buildRecordsForKnownBundle(result, bundleGroupId, bundleId));
                            processResponse(request.getRequestId(), response);
                        }
                    });
            } else {
                // we are at a child node under a bundle node - its an individual destination or deployment node
                BundleCriteria criteria = new BundleCriteria();
                criteria.addFilterId(bundleId);
                criteria.fetchDestinations(true);

                bundleService.findBundlesByCriteria(criteria, new AsyncCallback<PageList<Bundle>>() {
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError(MSG.view_bundle_tree_loadFailure(), caught);
                        response.setStatus(DSResponse.STATUS_FAILURE);
View Full Code Here

        });
    }

    @Override
    protected BundleCriteria getFetchCriteria(final DSRequest request) {
        BundleCriteria criteria = new BundleCriteria();
        criteria.addFilterTagNamespace(getFilter(request, "tagNamespace", String.class));
        criteria.addFilterTagSemantic(getFilter(request, "tagSemantic", String.class));
        criteria.addFilterTagName(getFilter(request, "tagName", String.class));
        criteria.addFilterBundleTypeId(getFilter(request, "bundleType", Integer.class));
        criteria.addFilterTagSemantic(getFilter(request, "tagSemantic", String.class));
        criteria.addFilterName(getFilter(request, "search", String.class));

        return criteria;
    }
View Full Code Here

TOP

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

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.