Example #1
0
 // obsolete
 public List getOutline0(List articles) throws ZenoException {
   List result = new ArrayList();
   NodeComparator nodeComparator = new NodeComparator();
   Hashtable mainLinkTable = new Hashtable();
   collectLinks(mainLinkTable, "", -1);
   Iterator artit = articles.iterator();
   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);
     Integer artId = new Integer(art.getId());
     HashSet visited = new HashSet();
     List links = (List) mainLinkTable.get(artId);
     if (links != null) {
       Iterator it = links.iterator();
       while (it.hasNext()) {
         LinkImpl link = (LinkImpl) it.next();
         artNode.add(getNode(mainLinkTable, link, art.getId(), "", visited));
       }
       Collections.sort(artNode.getChildren(), nodeComparator);
     }
     result.add(artNode);
   }
   return result;
 }
Example #2
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 #3
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 #4
0
  public List getOutline(Hashtable mainLinkTable, List articles) throws ZenoException {

    comparator = new NodeComparator();
    List result = new ArrayList();
    Iterator artit = articles.iterator();
    List outlineLinks = new ArrayList();
    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);
      result.add(artNode);
    }
    Iterator resit = result.iterator();
    while (resit.hasNext()) {
      OutlineNode artNode = (OutlineNode) resit.next();
      genChildren(mainLinkTable, artNode, visited, null);
    }
    return result;
  }
Example #5
0
  public List getFullOutline(Hashtable mainLinkTable, List articles) throws ZenoException {

    comparator = new NodeComparator2();
    List result = new ArrayList();
    Iterator artit = articles.iterator();
    Hashtable resTable = genResTable(articles);
    Hashtable visited = new Hashtable();
    int nr = 1;
    while (artit.hasNext()) {
      ArticleImpl art = (ArticleImpl) artit.next();
      if (art instanceof Topic || visited.get(new Integer(art.getId())) == null) {
        OutlineNode artNode = new OutlineNode("", Integer.toString(art.getId()), art.getAlias());
        artNode.setPosition(Integer.toString(nr++));
        artNode.setResource(art);
        result.add(artNode);
        List outlineLinks = new ArrayList();
        collectOutlineLinks(mainLinkTable, art.id, outlineLinks);
        LinkImpl.fillLinks(factory, outlineLinks, resTable, false);
        genChildren(mainLinkTable, artNode, visited, art);
      }
    }
    return result;
  }