public List<GraphNode> enumerateChildsGraph() { return enumerateChildsGraph(null); }
/** * @param f, can be null * @return */ public List<GraphNode> enumerateChildsGraph(Filter f) { List<GraphNode> retValue = new ArrayList<GraphNode>(); if(graphsSet != null) { if(f == null) retValue.addAll(graphsSet.values()); else { for(GraphNode g: graphsSet.values()) { String path = this.getPath() + "/" + g.getName(); if(f.acceptGraph(g, path)) retValue.add(g); } } } if(childsMap != null) { for(GraphTree child: childsMap.values()) { retValue.addAll(child.enumerateChildsGraph(f)); } } return retValue; }
private boolean evaluateFilter(ParamsBean params, JrdsJSONWriter w, HostsList root, Filter f) throws IOException { Collection<GraphTree> level = root.getTrees(); // We construct the graph tree root to use // The tree is parsed twice, that's not optimal Collection<GraphTree> rootToDo = new HashSet<GraphTree>(level.size()); for(GraphTree tree: level) { GraphTree testTree = f.setRoot(tree); if(testTree != null && !rootToDo.contains(testTree) && testTree.enumerateChildsGraph(f).size() > 0) { rootToDo.add(testTree); } } for(GraphTree tree: findRoot(rootToDo)) { sub(params, w, tree, "tree", f, "", tree.getPath().hashCode()); } return true; }
public List<GraphNode> getGraphs(JrdsServlet caller) { // Neither id or pid where specified, nothing can be done if(id == null && pid == null) return Collections.emptyList(); if(id != null) { GraphTree node = hostlist.getNodeById(id); if(node != null) { logger.debug(jrds.Util.delayedFormatString("Tree found: %s", node)); Filter filter = getFilter(); return node.enumerateChildsGraph(filter); } } GraphNode gn = getGraphNode(caller); if(gn != null) { logger.debug(jrds.Util.delayedFormatString("Graph found: %s", gn)); return Collections.singletonList(gn); } return Collections.emptyList(); }
for(GraphTree graphTree: hl.getTrees()) { logger.trace("Tree found: " + graphTree.getName()); for(GraphNode gn: graphTree.enumerateChildsGraph(null)) { if(!done.contains(gn.hashCode())) { done.add(gn.hashCode());
HostsList hostsList = new HostsList(propertiesManager); GraphTree gt = hostsList.getGraphTreeByHost(); for (GraphNode gn: gt.enumerateChildsGraph()) { GraphDesc gd = gn.getGraphDesc(); List<String> path = gd.getViewTree(gn);
@Test public void testCustomGraph() throws IOException { PropertiesManager pm = Tools.makePm(testFolder); pm.setProperty("tabs", "filtertab"); pm.update(); HostsList hl = new HostsList(pm); GraphDesc gd = new GraphDesc(); gd.setName("truc"); gd.setGraphTitle("title"); Map<String, GraphDesc> gdmap = new HashMap<String, GraphDesc>(); gdmap.put(gd.getName(), gd); Set<Tab> tabs = new HashSet<Tab>(); Map<Integer, GraphNode> graphMap = new HashMap<Integer, GraphNode>(); Map<String, GraphTree> graphTrees = new HashMap<String, GraphTree>(); hl.doCustomGraphs(gdmap, graphMap, graphTrees, tabs); hl.addGraphs(graphMap.values()); boolean found = false; GraphNode node = null; for(Tab t: tabs) { if(PropertiesManager.CUSTOMGRAPHTAB.equals(t.id)) { found = true; t.setHostlist(hl); node = t.getGraphTree().enumerateChildsGraph().get(0); } } Assert.assertNotNull(graphMap.get(node.hashCode())); Assert.assertTrue(found); Assert.assertNotEquals(graphTrees.size(), 0); } }