Пример #1
0
            def _helperEstablishRelationShipParentToChild(graphParentUUID,graphChildUUID):
                if False == self.modelGraphItemsDatabase.has_key(graphParentUUID):
                    self.modelGraphItemsDatabase[graphParentUUID] = nep_tree_graphical.nepGraphicalNode(graphParentUUID,0)
                if False == self.modelGraphItemsDatabase.has_key(graphChildUUID):
                    self.modelGraphItemsDatabase[graphChildUUID] = nep_tree_graphical.nepGraphicalNode(graphChildUUID,0)

                parentItem = self.modelGraphItemsDatabase[graphParentUUID]
                childItem =self.modelGraphItemsDatabase[graphChildUUID]
                graphlinkUUUID = "link::"+graphParentUUID+"::"+graphChildUUID
                if False == self.modelGraphItemsDatabase.has_key(graphlinkUUUID):
                    self.modelGraphItemsDatabase[graphlinkUUUID] = nep_tree_graphical.nepGraphicalNode(graphlinkUUUID,0)

                linkItem = self.modelGraphItemsDatabase[graphlinkUUUID]
                linkItem.graphItemLevel = parentItem.graphItemLevel+0.5
                childItem.graphItemLevel = parentItem.graphItemLevel+1.0
                parentItem.addSubUUID(graphChildUUID)
                parentItem.addLinkUUID(graphlinkUUUID)
                childItem.addSuperUUID(graphParentUUID)
                childItem.addLinkUUID(graphlinkUUUID)
                linkItem.addNodeUUID(graphChildUUID)
                linkItem.addNodeUUID(graphParentUUID)
Пример #2
0
    def buildTrees(self, vpcID = 'vpc.all', filter = None):
        """
        Build both the logical and graphical tree for a given VPC and filter. Pass vpc.all for all
        information with no VPC and vpc.classic for the "No VPC" part
        """
            #TODO add code to delete the tree if it already exists as well as the self.modelGraphItemsDatabase
        print "buildTrees"
        print vpcID
        objectsToUse = None
        if vpcID == 'vpc.all':
            #compute without taking in account VPC
            objectsToUse = self.levelDisplayObjects
            tmpArray = []

            modelLogicalRootNode = nep_tree_logical.nepLogicalNode(self.logicalRootUUID);
            for idx in range(len(self.levelDisplayIdentifiers)):
                 for anObjectUUID in self.levelDisplayObjects.keys():
                    if self.levelDisplayObjects[anObjectUUID].has_key('logical_level'):
#                         print anObjectUUID+ " " + str(self.levelDisplayObjects[anObjectUUID]["logical_level"])
                        if self.levelDisplayObjects[anObjectUUID]["logical_level"] == idx:
                            aNode = nep_tree_logical.nepLogicalNode(anObjectUUID)
                            if self.levelDisplayObjects[anObjectUUID].has_key('logical_parent') == False:
                                modelLogicalRootNode.addChild(aNode)
                            else:
                                for oneNode in tmpArray:
                                    if oneNode.representedObject ==  self.levelDisplayObjects[anObjectUUID]['logical_parent']:
                                        oneNode.addChild(aNode)
                            tmpArray.append(aNode)

            self.modelLogicalRootNode = modelLogicalRootNode
        elif vpcID == 'vpc.classic':
            #TODO all in the "non vpc land"
            self.modelLogicalRootNode = None
        else:
            #TODO all in the "non vpc land"
            self.modelLogicalRootNode = None

            # Now we build the graphical tree
        if self.modelLogicalRootNode != None:
            self.modelGraphItemsDatabase["root:"+self.logicalRootUUID] = nep_tree_graphical.nepGraphicalNode("root:"+self.logicalRootUUID,-1);
            self.modelGraphicalRootNode = self.modelGraphItemsDatabase["root:"+self.logicalRootUUID]

                # this help does the full job of linking a graph parent to a child, creating the items
                # and putting the links
            def _helperEstablishRelationShipParentToChild(graphParentUUID,graphChildUUID):
                if False == self.modelGraphItemsDatabase.has_key(graphParentUUID):
                    self.modelGraphItemsDatabase[graphParentUUID] = nep_tree_graphical.nepGraphicalNode(graphParentUUID,0)
                if False == self.modelGraphItemsDatabase.has_key(graphChildUUID):
                    self.modelGraphItemsDatabase[graphChildUUID] = nep_tree_graphical.nepGraphicalNode(graphChildUUID,0)

                parentItem = self.modelGraphItemsDatabase[graphParentUUID]
                childItem =self.modelGraphItemsDatabase[graphChildUUID]
                graphlinkUUUID = "link::"+graphParentUUID+"::"+graphChildUUID
                if False == self.modelGraphItemsDatabase.has_key(graphlinkUUUID):
                    self.modelGraphItemsDatabase[graphlinkUUUID] = nep_tree_graphical.nepGraphicalNode(graphlinkUUUID,0)

                linkItem = self.modelGraphItemsDatabase[graphlinkUUUID]
                linkItem.graphItemLevel = parentItem.graphItemLevel+0.5
                childItem.graphItemLevel = parentItem.graphItemLevel+1.0
                parentItem.addSubUUID(graphChildUUID)
                parentItem.addLinkUUID(graphlinkUUUID)
                childItem.addSuperUUID(graphParentUUID)
                childItem.addLinkUUID(graphlinkUUUID)
                linkItem.addNodeUUID(graphChildUUID)
                linkItem.addNodeUUID(graphParentUUID)

                # this is the call back used to build the graphical tree when parsing/traversing the logical
            def _buildGraphTreeForNode(node):
                graphicalUUID = ("root:"+node.representedObject) if (node == modelLogicalRootNode) else ("item:"+node.representedObject)
                subLevelRepartition = {};
                for aLogicalChildNode in node.childrenNodes:
                    tmpIndex = self.levelDisplayObjects[aLogicalChildNode.representedObject]['logical_level']
                    if False == subLevelRepartition.has_key(tmpIndex):
                        subLevelRepartition[tmpIndex] = []
                    subLevelRepartition[tmpIndex].append(aLogicalChildNode.representedObject)

                for aLevelKey in subLevelRepartition.keys():
                    levelElements = subLevelRepartition[aLevelKey]
                    if 1 == len(levelElements):
                        childItemGraphicalUUID = "item:"+levelElements[0];
                        _helperEstablishRelationShipParentToChild(graphicalUUID, childItemGraphicalUUID)
                    else:
                        childGroupGraphicalUUID = "group:"+node.representedObject+":"+str(aLevelKey)
                        _helperEstablishRelationShipParentToChild(graphicalUUID, childGroupGraphicalUUID)
                        childMultiGraphicalUUID = "multi:"+node.representedObject+":"+str(aLevelKey)
                        _helperEstablishRelationShipParentToChild(graphicalUUID, childMultiGraphicalUUID)
                        for anLevelElement in levelElements:
                            subChildGRaphUUID = "item:"+anLevelElement;
                            _helperEstablishRelationShipParentToChild(childGroupGraphicalUUID, subChildGRaphUUID);
                            _helperEstablishRelationShipParentToChild(childMultiGraphicalUUID, subChildGRaphUUID);

                    #build the graphical tree
            self.modelLogicalRootNode.trasverse(_buildGraphTreeForNode)