Пример #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;
 }
Пример #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;
  }
Пример #3
0
 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;
 }
Пример #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;
  }
Пример #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;
  }