Bug 741743

Summary: leaf nodes in Resource tree incorrectly show expand-node icon
Product: [Other] RHQ Project Reporter: Ian Springer <ian.springer>
Component: Core UIAssignee: Nobody <nobody>
Status: NEW --- QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4.1CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 729848    

Description Ian Springer 2011-09-27 19:32:54 UTC
This is misleading, since it suggests that the Resource has children. Once an expand-node icon is clicked, it disappears, since at that point the tree impl tries to load the children and realizes there aren't any.

To fix this, we'll need to add a new 'hasChildResources' boolean field to ResourceLineageComposite, that the GUI can check to determine if the Resource has children and render the node correctly. This field could be initialized in ResourceManagerBean.getResourceLineageAndSiblings() by executing the following code for each of the "children":

        Query childCountQuery;
        if (authorizationManager.isInventoryManager(user)) {
            childCountQuery = PersistenceUtility.createCountQuery(entityManager,                     Resource.QUERY_FIND_CHILDREN_BY_CATEGORY_AND_INVENTORY_STATUS_ADMIN);
        } else {
            childCountQuery = PersistenceUtility.createCountQuery(entityManager,
                Resource.QUERY_FIND_CHILDREN_BY_CATEGORY_AND_INVENTORY_STATUS);
            childCountQuery.setParameter("subject", user);
        }

        childCountQuery.setParameter("parent", resource);
        childCountQuery.setParameter("category", null);
        childCountQuery.setParameter("status", InventoryStatus.COMMITTED);
        long childCount = (Long) childCountQuery.getSingleResult();

        composite.setHasChildResources(childCount > 0);

However, we'll need to check that this addition doesn't significantly increase the time it takes to load the tree.