private void builShowableTree( TreeNodeWrapper currentNode, TreeNodeWrapper parent, ITreeNode currentTreeNode, Set<String> checkNodes) { if (checkNodes.contains(currentNode.getCode())) { currentNode.setOpen(true); ITreeNode[] children = currentTreeNode.getChildren(); for (int i = 0; i < children.length; i++) { ITreeNode newCurrentTreeNode = children[i]; TreeNodeWrapper newNode = new TreeNodeWrapper(newCurrentTreeNode); newNode.setParent(currentNode); currentNode.addChild(newNode); this.builShowableTree(newNode, currentNode, newCurrentTreeNode, checkNodes); } } }
@Override public TreeNodeWrapper getShowableTree( Set<String> treeNodesToOpen, ITreeNode fullTree, Collection<String> groupCodes) throws ApsSystemException { if (null == treeNodesToOpen || treeNodesToOpen.isEmpty()) { ApsSystemUtils.getLogger().info("No selected nodes"); return new TreeNodeWrapper(fullTree); } TreeNodeWrapper root = null; try { Set<String> checkNodes = new HashSet<String>(); this.buildCheckNodes(treeNodesToOpen, checkNodes, groupCodes); root = new TreeNodeWrapper(fullTree); root.setParent(root); this.builShowableTree(root, null, fullTree, checkNodes); } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "getShowableTree"); throw new ApsSystemException("Error creating showalble tree", t); } return root; }