Examples of AutoGroupCompositeFlyweight


Examples of org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight

    public String toString() {
        if (level instanceof ResourceGroup) {
            ResourceGroup group = (ResourceGroup) level;
            return group.getName();
        } else if (level instanceof AutoGroupCompositeFlyweight) {
            AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) level;
            if (ag.getResourceType() != null) {
                return ag.getResourceType().getName();
            } else if (ag.getSubcategory() != null) {
                return ag.getSubcategory();
            }
        }
        return level.toString();
    }
View Full Code Here

Examples of org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight

                if (((ResourceFlyweight) child.getData()).getId() == selectedResourceId) {
                    ret = true;
                    break;
                }
            } else if (child.getData() instanceof AutoGroupCompositeFlyweight) {
                AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) child.getData();
                if (ag.getParentResource().getId() == selectedResourceId && ag.getResourceType() != null
                    && ag.getResourceType().getId() == selectedAGTypeId) {
                   
                    ret = true;
                    break;
                }
            }
View Full Code Here

Examples of org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight

        String parent = FacesContextUtility.getOptionalRequestParameter("parent");
        String type = FacesContextUtility.getOptionalRequestParameter("type");
        ResourceTreeNode node = (ResourceTreeNode) tree.getRowData(tree.getRowKey());

        if (node.getData() instanceof AutoGroupCompositeFlyweight) {
            AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) node.getData();
            if (ag.getParentResource() != null && ag.getResourceType() != null
                && String.valueOf(ag.getParentResource().getId()).equals(parent)
                && String.valueOf(ag.getResourceType().getId()).equals(type)) {
                return true;
            }
        } else if (node.getData() instanceof ResourceFlyweight) {
            if (String.valueOf(((ResourceFlyweight) node.getData()).getId()).equals(id)) {
                return Boolean.TRUE;
View Full Code Here

Examples of org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight

                }

                path += ("?id=" + flyweight.getId());
            }
        } else if (node.getData() instanceof AutoGroupCompositeFlyweight) {
            AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) node.getData();
            if (ag.getResourceType() == null) {
                //XXX this is a temporary measure. The subcategories will get the content page in the end.
                FacesContext.getCurrentInstance().addMessage("leftNavTreeForm:leftNavTree",
                    new FacesMessage(FacesMessage.SEVERITY_WARN, "No subcategory page exists.", null));
               
                return false;
            } else if (ag.getMemberCount() != node.getChildren().size()) {
                // you don't have access to every autogroup resource
                FacesContext.getCurrentInstance().addMessage(
                    "leftNavTreeForm:leftNavTree",
                    new FacesMessage(FacesMessage.SEVERITY_WARN,
                        "You must have view access to all resources in an autogroup to view it", null));

                return false;
            } else {
                path = "/rhq/autogroup/monitor/graphs.xhtml?parent=" + ag.getParentResource().getId() + "&type="
                    + ag.getResourceType().getId();
            }
        }

        try {
            response.sendRedirect(path);
View Full Code Here

Examples of org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight

    public String toString() {
        if (level == null) {
            return "";
        }
        if (level instanceof AutoGroupCompositeFlyweight) {
            AutoGroupCompositeFlyweight composite = ((AutoGroupCompositeFlyweight) level);
            return composite.getName();
        } else if (level instanceof ResourceWithAvailability) {
            return ((ResourceWithAvailability) level).getResource().getName();
        } else if (level instanceof ResourceFlyweight) {
            ResourceFlyweight fly = (ResourceFlyweight) level;
            String name = fly.getName();
View Full Code Here

Examples of org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight

        for (ResourceTreeNode childNode : parentNode.getMembers()) {
            for (ResourceTreeNode node : childNode.getChildren()) {
                Object level = node.getData();

                if (level instanceof AutoGroupCompositeFlyweight) {
                    AutoGroupCompositeFlyweight agc = (AutoGroupCompositeFlyweight) level;
                    Object key = agc.getResourceType() != null ? agc.getResourceType() : agc.getSubcategory();

                    ResourceGroupTreeNode childGroupNode = children.get(key);
                    if (childGroupNode == null) {
                        childGroupNode = new ResourceGroupTreeNode(level, parentNode);
                        children.put(key, childGroupNode);
View Full Code Here

Examples of org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight

                }
                avail = avail / resources.size();

                Object nodeData = null;
                if (key instanceof String) {
                    nodeData = new AutoGroupCompositeFlyweight(avail, parentResource, (String) key, resources.size());
                } else if (key instanceof ResourceTypeFlyweight) {
                    ResourceTypeFlyweight typeKey = (ResourceTypeFlyweight) key;

                    if (typeKey.isSingleton()) {
                        nodeData = resources.get(0);
                    } else {
                        boolean isDupResourceTypeName = dupResourceTypeNames.contains(typeKey.getName());
                        nodeData = new AutoGroupCompositeFlyweight(avail, parentResource, typeKey, resources.size(),
                            isDupResourceTypeName);
                    }
                }
                ResourceTreeNode node = new ResourceTreeNode(nodeData, parentNode);
                load(node);

                if (!recursivelyLocked(node)) {
                    parentNode.getChildren().add(node);
                }
            }
        } else {
            // #####################################################################################

            AutoGroupCompositeFlyweight compositeParent = (AutoGroupCompositeFlyweight) parentNode.getData();

            Map<Object, List<ResourceFlyweight>> children = new HashMap<Object, List<ResourceFlyweight>>();
            log.debug("composite parent" + compositeParent);
            if (compositeParent != null) {

                MembersCategoryHint membersCategory = MembersCategoryHint.NONE;
                MembersAvailabilityHint membersAvailabilityHint = MembersAvailabilityHint.UP;

                for (ResourceFlyweight res : compositeParent.getParentResource().getChildResources()) {
                    boolean process = false;
                    if (compositeParent.getSubcategory() != null) {
                        // parent is a sub category
                        if (res.getResourceType().getSubCategory() != null
                        //BZ1069545 This functionality is no longer needed since portal-war is no longer needed.
                        //&& compositeParent.getSubcategory().equals(
                        //    res.getResourceType().getSubCategory().getParentSubCategory())
                            && compositeParent.getParentResource().equals(res.getParentResource())) {

                            // A subSubCategory in a subcategory
                            addToList(children, res.getResourceType().getSubCategory(), res);
                            process = true;
                        } else if (compositeParent.getSubcategory().equals(res.getResourceType().getSubCategory())
                            && compositeParent.getParentResource().equals(res.getParentResource())) {
                            // Direct entries in a subcategory... now group them by autogroup (type)
                            addToList(children, res.getResourceType(), res);
                            process = true;
                        }
                    } else if (compositeParent.getResourceType() != null) {
                        if (compositeParent.getResourceType().equals(res.getResourceType())
                            && compositeParent.getParentResource().getId() == res.getParentResource().getId()) {

                            addToList(children, res.getResourceType(), res);
                            process = true;
                        }
                    }

                    if (process) {
                        //amend the overall category of all the members of the auto group.
                        switch (membersCategory) {
                        case NONE: //this is the first child, so let's use its category as a starting point
                            membersCategory = MembersCategoryHint.fromResourceCategory(res.getResourceType()
                                .getCategory());
                            break;
                        case MIXED: //this is the "final" state. The children type is not going to change from this.
                            break;
                        default: //check if this child has the same category as its previous siblings.
                            if (MembersCategoryHint.fromResourceCategory(res.getResourceType().getCategory()) != membersCategory) {
                                membersCategory = MembersCategoryHint.MIXED;
                            }
                        }

                        //amend the availability hint of the autogroup. If all resources are up, the hint is UP, if some of the resources
                        //are down, the hint is DOWN, if some of the resources' avail state is unknown, the hint is UNKNOWN.
                        //The down state has the highest priority.
                        switch (membersAvailabilityHint) {
                        case UP:
                            membersAvailabilityHint = MembersAvailabilityHint.fromAvailabilityType(res
                                .getCurrentAvailability().getAvailabilityType());
                            break;
                        case UNKNOWN:
                            if (res.getCurrentAvailability().getAvailabilityType() == AvailabilityType.DOWN) {
                                membersAvailabilityHint = MembersAvailabilityHint.DOWN;
                            }
                            break;
                        case DOWN:
                            ; //a "terminal" state... if some resource is down, the overall state is going to be down as that is the most important information.
                        }
                    }
                }

                compositeParent.setMembersCategoryHint(membersCategory);
                compositeParent.setMembersAvailabilityHint(membersAvailabilityHint);
            }

            AutoGroupCompositeFlyweight compositeParentNode = (AutoGroupCompositeFlyweight) parentNode.getData();

            for (Map.Entry<Object, List<ResourceFlyweight>> entry : children.entrySet()) {
                Object key = entry.getKey();
                List<ResourceFlyweight> resources = entry.getValue();

                if (compositeParentNode.getSubcategory() != null) {
                    double avail = 0;
                    for (ResourceFlyweight res : resources) {
                        avail += res.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP ? 1 : 0;
                    }
                    avail = avail / resources.size();

                    Object nodeData = null;
                    if (key instanceof String) {
                        nodeData = new AutoGroupCompositeFlyweight(avail, compositeParent.getParentResource(),
                            (String) key, resources.size());
                    } else if (key instanceof ResourceTypeFlyweight) {
                        ResourceTypeFlyweight typeKey = (ResourceTypeFlyweight) key;
                        if (typeKey.isSingleton()) {
                            nodeData = resources.get(0);
                        } else {
                            nodeData = new AutoGroupCompositeFlyweight(avail, compositeParent.getParentResource(),
                                typeKey, resources.size(), false);
                        }
                    }
                    ResourceTreeNode node = new ResourceTreeNode(nodeData, parentNode);
                    load(node);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.