protected OutlineNode getNode( Hashtable linkTable, Link link, int parentId, String linkLabel, Set visited) throws ZenoException { Integer otherId = new Integer((link.getSourceId() == parentId) ? link.getTargetId() : link.getSourceId()); OutlineNode node = genOutlineNode(link, parentId); if (visited.contains(otherId)) { node.setDuplicate(true); return node; } else { visited.add(otherId); List links = (List) linkTable.get(otherId); if (links != null) { Iterator it = links.iterator(); while (it.hasNext()) { LinkImpl link1 = (LinkImpl) it.next(); if ("".equals(linkLabel) || link1.getLabel().equals(linkLabel)) node.add(getNode(linkTable, link1, otherId.intValue(), linkLabel, visited)); else node.add(genOutlineNode(link1, otherId.intValue())); } Collections.sort(node.getChildren(), new NodeComparator()); } return node; } }
protected OutlineNode genOutlineNode(Link link, int parentId) { String linkLabel, id, alias; ZenoResource res; if (link.getSourceId() == parentId) { linkLabel = link.getLabel(); id = Integer.toString(link.getTargetId()); alias = link.getTargetAlias(); res = ((LinkImpl) link).getTargetResource(); } else { linkLabel = "-" + link.getLabel(); id = Integer.toString(link.getSourceId()); alias = link.getSourceAlias(); res = ((LinkImpl) link).getSourceResource(); } OutlineNode node = new OutlineNode(linkLabel, id, alias); node.setResource(res); return node; }