Search in sources :

Example 16 with NodeVo

use of com.alibaba.csp.sentinel.command.vo.NodeVo in project RuoYi-Cloud-Plus by JavaLionLi.

the class ResourceTreeNode method fromNodeVoList.

public static ResourceTreeNode fromNodeVoList(List<NodeVo> nodeVos) {
    if (nodeVos == null || nodeVos.isEmpty()) {
        return null;
    }
    ResourceTreeNode root = null;
    Map<String, ResourceTreeNode> map = new HashMap<>();
    for (NodeVo vo : nodeVos) {
        ResourceTreeNode node = fromNodeVo(vo);
        map.put(node.id, node);
        // real root
        if (node.parentId == null || node.parentId.isEmpty()) {
            root = node;
        } else if (map.containsKey(node.parentId)) {
            map.get(node.parentId).children.add(node);
        } else {
        // impossible
        }
    }
    return root;
}
Also used : HashMap(java.util.HashMap) NodeVo(com.alibaba.csp.sentinel.command.vo.NodeVo)

Aggregations

NodeVo (com.alibaba.csp.sentinel.command.vo.NodeVo)16 ResourceTreeNode (com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 GetMapping (org.springframework.web.bind.annotation.GetMapping)5 DefaultNode (com.alibaba.csp.sentinel.node.DefaultNode)1 Node (com.alibaba.csp.sentinel.node.Node)1