Coverage Report - org.paneris.bibliomania.AllMessageboards
 
Classes in this File Line Coverage Branch Coverage Complexity
AllMessageboards
0%
0/28
0%
0/10
2.667
 
 1  
 package org.paneris.bibliomania;
 2  
 
 3  
 import java.util.Enumeration;
 4  
 import java.util.Vector;
 5  
 
 6  
 import org.melati.Melati;
 7  
 import org.webmacro.servlet.WebContext;
 8  
 
 9  0
 public class AllMessageboards extends BibliomaniaServlet {
 10  
 
 11  
   /**
 12  
    * 
 13  
    */
 14  
   private static final long serialVersionUID = 1L;
 15  
 
 16  
   protected String bibliomaniaHandle(Melati melati, WebContext context)
 17  
             throws Exception {
 18  
         
 19  0
     BibliomaniaDatabase db = (BibliomaniaDatabase) melati.getDatabase();
 20  0
     db.setupContext(melati, context, null, null);
 21  
     
 22  0
     Vector sectionGroups = load(db.getSectionGroupTable().selection());
 23  0
     Vector sections = load(db.getSectionTable().selection());
 24  0
     Vector authors = load(db.getAuthorTable().selection());
 25  0
     Vector books =  load(db.getBookTable().selection());
 26  
     
 27  0
     authors = ensure(authors, books);
 28  0
     sections = ensure(sections, authors);
 29  0
     sectionGroups = ensure(sectionGroups, sections);
 30  
     
 31  0
     context.put("sectionGroups",sectionGroups);    
 32  0
     context.put("sections",sections);    
 33  0
     context.put("authors",authors);    
 34  0
     context.put("books",books);    
 35  
     
 36  0
     return "AllMessageboards.wm";
 37  
   }
 38  
   
 39  
   private Vector ensure(Vector a, Vector b) {
 40  0
     for (Enumeration e = b.elements(); e.hasMoreElements();) {
 41  0
       Unit u = (Unit)e.nextElement();
 42  0
       if (!a.contains(u.getParentUnit())) { 
 43  0
         a.add(u.getParentUnit());
 44  
       }
 45  0
     }
 46  0
     return a;
 47  
   }
 48  
 
 49  
   private Vector load(Enumeration e) {
 50  0
     Vector v = new Vector();
 51  0
     while (e.hasMoreElements()) {
 52  0
       Unit u = (Unit)e.nextElement();
 53  0
       if (u.getMessageboard() != null && u.getMessageboard().isActive()) {
 54  0
         v.add(u);
 55  
       }
 56  0
     }
 57  0
     return v;
 58  
   }  
 59  
 }