Clover coverage report - Flock Flock - 0.7-dev
Coverage timestamp: Thu Jan 30 2003 01:35:37 EST
file stats: LOC: 92   Methods: 10
NCLOC: 71   Classes: 1
This license of Clover is provided to support the development of Flock only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
ShowAggregate.java - 0% 0% 0%
 1   
 package net.sf.flock.webapp.components;
 2   
 import java.util.Collection;
 3   
 import java.util.Map;
 4   
 import java.util.TreeMap;
 5   
 
 6   
 import net.sf.flock.FilterI;
 7   
 import net.sf.flock.FlockResourceException;
 8   
 import net.sf.flock.filter.Limit;
 9   
 import net.sf.flock.filter.MetaStartsWith;
 10   
 import net.sf.flock.filter.SortByDate;
 11   
 import net.sf.flock.webapp.FlockContext;
 12   
 import net.sf.tapestry.ApplicationRuntimeException;
 13   
 import net.sf.tapestry.BaseComponent;
 14   
 import net.sf.tapestry.event.PageDetachListener;
 15   
 import net.sf.tapestry.event.PageEvent;
 16   
 import net.sf.tapestry.form.IPropertySelectionModel;
 17   
 import net.sf.tapestry.form.StringPropertySelectionModel;
 18   
 
 19   
 public class ShowAggregate extends BaseComponent implements PageDetachListener {
 20   
 
 21   
     private final static Map ITEM_COUNTS = new TreeMap();
 22   
     static {
 23  0
         ITEM_COUNTS.put("Show 10", new Integer(10));
 24  0
         ITEM_COUNTS.put("Show 20", new Integer(20));
 25  0
         ITEM_COUNTS.put("Show 50", new Integer(50));
 26  0
         ITEM_COUNTS.put("Show All", new Integer(Integer.MAX_VALUE));
 27   
     }
 28   
     private final static String[] ITEM_COUNT_STR = (String[])ITEM_COUNTS.keySet().toArray(new String[3]);
 29   
 
 30   
     private String maxItems = ITEM_COUNT_STR[1];
 31   
 
 32   
     private String path = "/";
 33   
 
 34   
     private boolean allFolded = true;
 35   
 
 36  0
     public String getPath() {
 37  0
         return path;
 38   
     }
 39  0
     public void setPath(String path) {
 40  0
         this.path = path;
 41   
     }
 42   
 
 43   
 
 44  0
     public Collection getItems() {
 45  0
         try {
 46  0
             return FlockContext.getSubscriptionManager().findItems( new FilterI[] {
 47   
                 new MetaStartsWith("path", this.path), 
 48   
                 new SortByDate(),
 49   
                 new Limit(this.getMaxItemsInt()),
 50   
             });
 51   
         } catch (FlockResourceException e) {
 52  0
             throw new ApplicationRuntimeException(e);
 53   
         }        
 54   
     }
 55   
 
 56   
     /**
 57   
      * @see net.sf.tapestry.event.PageDetachListener#pageDetached(net.sf.tapestry.event.PageEvent)
 58   
      */
 59  0
     public void pageDetached(PageEvent evt) {
 60  0
         this.maxItems = ITEM_COUNT_STR[1];
 61  0
         this.path = "/";
 62  0
         this.allFolded = true;
 63   
     }
 64   
 
 65  0
     public IPropertySelectionModel getMaxItemsPropertySelection() {
 66  0
         return new StringPropertySelectionModel( ITEM_COUNT_STR );
 67   
     }
 68   
 
 69  0
     public String getMaxItems() {
 70  0
         return maxItems;
 71   
     }
 72   
 
 73  0
     public void setMaxItems(String maxItems) {
 74  0
         this.maxItems = maxItems;
 75  0
         this.fireObservedChange("maxItems", maxItems);
 76   
     }
 77   
     
 78  0
     private int getMaxItemsInt() {
 79  0
         return ((Integer)ITEM_COUNTS.get(this.maxItems)).intValue();
 80   
     }
 81   
 
 82  0
     public boolean isAllFolded() {
 83  0
         return allFolded;
 84   
     }
 85   
 
 86  0
     public void setAllFolded(boolean allFolded) {
 87  0
         this.allFolded = allFolded;
 88  0
         this.fireObservedChange("allFolded", allFolded);
 89   
     }
 90   
 
 91   
 }
 92