예제 #1
0
 private String findUniqueUrl(CategoryNode cat, String unid, String jspUrl) {
   List<AbstractNode> children = cat.getChildren();
   int childrenCount = children.size();
   for (int i = 0; i < childrenCount; i++) {
     if (StringUtil.equals(children.get(i).getJspUrl(), jspUrl)) {
       return unid;
     }
   }
   return jspUrl;
 }
예제 #2
0
 private CategoryNode findCategory(CategoryNode parent, String[] cats, int level) {
   List<AbstractNode> children = parent.getChildren();
   CategoryNode found = null;
   for (int i = 0; i < children.size(); i++) {
     AbstractNode c = children.get(i);
     if (c instanceof CategoryNode) {
       if (StringUtil.equals(cats[level], c.getName())) {
         found = (CategoryNode) c;
         break;
       }
     }
   }
   if (found == null) {
     found = new CategoryNode(parent, cats[level]);
     parent.getChildren().add(found);
   }
   if (level < cats.length - 1) {
     return findCategory(found, cats, level + 1);
   }
   return found;
 }
예제 #3
0
 private RootNode readSnippetsNodes() throws NotesException {
   Database db = ExtLibUtil.getCurrentDatabase();
   View v = db.getView("AllSnippetsFlat");
   try {
     RootNode root = new RootNode();
     String snippetSearch = (String) ExtLibUtil.getViewScope().get("snippetSearch");
     if (StringUtil.isNotEmpty(snippetSearch)) {
       v.FTSearch(snippetSearch);
       ViewEntryCollection col = v.getAllEntries();
       for (ViewEntry e = col.getFirstEntry(); e != null; e = col.getNextEntry()) {
         Vector<?> values = e.getColumnValues();
         String unid = e.getUniversalID();
         String cat = (String) values.get(0);
         String name = (String) values.get(1);
         String jspUrl = (String) values.get(2);
         CategoryNode c = findCategory(root, cat);
         SnippetNode snippet = new SnippetNode(c, name, cat, unid, jspUrl);
         c.getChildren().add(snippet);
       }
     } else {
       v.setAutoUpdate(false);
       ViewNavigator nav = v.createViewNav();
       nav.setBufferMaxEntries(500);
       for (ViewEntry e = nav.getFirst(); e != null; e = nav.getNext()) {
         Vector<?> values = e.getColumnValues();
         String unid = e.getUniversalID();
         String cat = (String) values.get(0);
         String name = (String) values.get(1);
         String jspUrl = (String) values.get(2);
         CategoryNode c = findCategory(root, cat);
         SnippetNode snippet = new SnippetNode(c, name, cat, unid, findUniqueUrl(c, unid, jspUrl));
         c.getChildren().add(snippet);
       }
     }
     return root;
   } finally {
     v.recycle();
   }
 }