Example #1
0
  protected void genChildren(Hashtable linkTable, OutlineNode node, Hashtable visited, Article root)
      throws ZenoException {

    Integer nodeId = new Integer(node.getId());
    OutlineNode rnode = (OutlineNode) visited.get(nodeId);
    if (rnode != null) {
      node.setDuplicate(true);
      node.setOriginalPosition(rnode.getPosition());
      rnode.setDuplicated(true);
      return;
    }

    visited.put(nodeId, node);

    List links = (List) linkTable.get(nodeId);
    if (links != null) {
      Iterator it = links.iterator();
      while (it.hasNext()) {
        LinkImpl link1 = (LinkImpl) it.next();
        OutlineNode cnode = genOutlineNode(link1, nodeId.intValue());
        if (root != null) cnode.genMark(root);
        if (!extended || cnode.getResource() != null) node.add(cnode);
      }
      Collections.sort(node.getChildren(), comparator);
    }
    Iterator cit = node.getChildren().iterator();
    int nr = 1;
    while (cit.hasNext()) {
      OutlineNode cnode = (OutlineNode) cit.next();
      String newPosition = node.getPosition() + "." + nr++;
      cnode.setPosition(newPosition);
      genChildren(linkTable, cnode, visited, root);
    }
  }
Example #2
0
  protected List getXOutline(Hashtable mainLinkTable, List articles) throws ZenoException {

    comparator = new NodeComparator2();
    List result = new ArrayList();
    Iterator artit = articles.iterator();
    List outlineLinks = new ArrayList();
    Hashtable resTable = new Hashtable();
    Hashtable visited = new Hashtable();
    int nr = 1;
    while (artit.hasNext()) {
      ArticleImpl art = (ArticleImpl) artit.next();
      OutlineNode artNode = new OutlineNode("", Integer.toString(art.getId()), art.getAlias());
      artNode.setPosition(Integer.toString(nr++));
      artNode.setResource(art);
      collectOutlineLinks(mainLinkTable, art.id, outlineLinks);
      resTable.put(new Integer(art.getId()), art);
      result.add(artNode);
    }
    LinkImpl.fillLinks(factory, outlineLinks, resTable, false);
    Iterator resit = result.iterator();
    while (resit.hasNext()) {
      OutlineNode artNode = (OutlineNode) resit.next();
      Article root = (Article) artNode.getResource();
      genChildren(mainLinkTable, artNode, visited, root);
    }
    return result;
  }
Example #3
0
 public List groupNodes(List nodes) {
   List result = new ArrayList();
   List nodegroup = null;
   int ltopid = -1;
   Iterator nit = nodes.iterator();
   while (nit.hasNext()) {
     OutlineNode node = (OutlineNode) nit.next();
     int ctopid = ((ArticleImpl) node.getResource()).getTopicId();
     if (ctopid != ltopid) {
       nodegroup = new ArrayList();
       result.add(nodegroup);
     }
     nodegroup.add(node);
   }
   return result;
 }