Package org.rhq.core.domain.resource.group.composite

Examples of org.rhq.core.domain.resource.group.composite.AutoGroupComposite


            query.setParameter("subject", user);
        }

        query.setParameter("id", resourceId);

        AutoGroupComposite result;
        try {
            result = (AutoGroupComposite) query.getSingleResult();
        } catch (NoResultException nore) {
            return null; // Better throw a PermissionException ?
        }

        if (isInventoryManager) {
            query = entityManager.createNamedQuery(Resource.QUERY_FIND_AVAILABILITY_BY_RESOURCE_ID_ADMIN);
        } else {
            query = entityManager.createNamedQuery(Resource.QUERY_FIND_AVAILABILITY_BY_RESOURCE_ID);
            query.setParameter("subject", user);
        }

        query.setParameter("id", resourceId);
        result.setResources(query.getResultList()); // query result is a List<ResourceWithAvailability>

        return result;
    }
View Full Code Here


            query.setParameter("subject", subject);
        }

        query.setParameter("ids", ids);

        AutoGroupComposite oneComp;
        try {
            oneComp = (AutoGroupComposite) query.getSingleResult();
        } catch (NoResultException nre) {
            return null; // better throw a PermissionException ?
        }

        if (isInventoryManager) {
            query = entityManager.createNamedQuery(Resource.QUERY_FIND_AVAILABILITY_BY_RESOURCE_IDS_ADMIN);
        } else {
            query = entityManager.createNamedQuery(Resource.QUERY_FIND_AVAILABILITY_BY_RESOURCE_IDS);
            query.setParameter("subject", subject);
        }

        query.setParameter("ids", ids);

        // We are not doing a query with constructor here, as this would fire a select per
        // resource and row. So we need to construct the ResourceWithAvailability objects ourselves.
        List<Object[]> objs = query.getResultList();
        for (Object[] ob : objs) {
            Resource r = (Resource) ob[0];
            AvailabilityType at = (AvailabilityType) ob[1];
            ResourceWithAvailability rwa = new ResourceWithAvailability(r, at);

            AutoGroupComposite comp = new AutoGroupComposite(oneComp);
            List res = new ArrayList(1); // hack to get around type safety
            res.add(rwa);
            comp.setResources(res);
            results.add(comp);
        }

        return results;
    }
View Full Code Here

                    children = new ArrayList<AutoGroupComposite>();
                displaySummary = new ArrayList<AutoGroupCompositeDisplaySummary>(children.size() + 1);

                // get the parent
                ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
                AutoGroupComposite parentComposite = resourceManager.getResourceAutoGroup(subject, parentId);
                if (parentComposite != null) {
                    parentComposite.setMainResource(true);
                    List<MetricDisplaySummary> metricSummaries = null;
                    metricSummaries = chartsManager.getMetricDisplaySummariesForMetrics(subject, parentId,
                        DataType.MEASUREMENT, begin, end, true, true);
                    displaySummary.add(0, new AutoGroupCompositeDisplaySummary(parentComposite, metricSummaries));
                }
View Full Code Here

    private List<AutoGroupComposite> getResourceChildren(Resource resource, Subject subject) {
        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
        List<AutoGroupComposite> children = resourceManager.findChildrenAutoGroups(subject, resource.getId());

        AutoGroupComposite resourceGroupComposite = resourceManager.getResourceAutoGroup(subject, resource.getId());
        if (resourceGroupComposite != null)
            resourceGroupComposite.setMainResource(true);
        else
            return new ArrayList<AutoGroupComposite>();

        // now increase everyone's depth by one to account for the resource
        for (AutoGroupComposite child : children) {
            child.setDepth(child.getDepth() + 1);
        }

        children.add(0, resourceGroupComposite);

        Resource parentResource = resourceManager.getParentResource(resource.getId());
        AutoGroupComposite parentGroupComposite = null;
        if (parentResource != null) {
            parentGroupComposite = resourceManager.getResourceAutoGroup(subject, parentResource.getId());
        }

        if (parentGroupComposite != null) {
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.group.composite.AutoGroupComposite

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.