Coverage Report - com.buckosoft.PicMan.web.SpinContactsForm
 
Classes in this File Line Coverage Branch Coverage Complexity
SpinContactsForm
0%
0/37
0%
0/8
1.25
 
 1  
 /******************************************************************************
 2  
  * SpinContactsForm.java - A bean to wrap the Contact Spinner in a form friendly package
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2006 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.PicMan.web;
 9  
 
 10  
 import java.util.HashMap;
 11  
 import java.util.List;
 12  
 
 13  
 import com.buckosoft.BSAccount.web.BSAccountUserWebSession;
 14  
 import com.buckosoft.PicMan.business.PicManFacade;
 15  
 import com.buckosoft.PicMan.db.DatabaseFacade;
 16  
 import com.buckosoft.PicMan.domain.Chain;
 17  
 import com.buckosoft.PicMan.domain.Set;
 18  
 
 19  
 /** A bean to wrap the Contact Spinner in a form friendly package
 20  
  * @author Dick Balaska
 21  
  */
 22  0
 public class SpinContactsForm {
 23  
 
 24  
         private        BSAccountUserWebSession        userWebSession;
 25  0
         private        Chain                        chain = null;
 26  0
         private        boolean                        filtersSaved = false;
 27  
 
 28  
         private PicManFacade        pmf;
 29  
         private DatabaseFacade        dbf;
 30  
         
 31  0
         public void setPicMan(PicManFacade pmf) { this.pmf = pmf; }
 32  0
         public PicManFacade getPicMan() { return(pmf); }
 33  
 
 34  0
         public void setDatabase(DatabaseFacade dbf) { this.dbf = dbf; }
 35  0
         public DatabaseFacade getDatabase() { return(dbf); }
 36  
 
 37  0
         public        BSAccountUserWebSession        getUserWebSession() { return(userWebSession); }
 38  0
         public        void                setUserWebSession(BSAccountUserWebSession us) { userWebSession = us; }
 39  
 
 40  0
         public Chain                getChain() { return(chain); }
 41  0
         public void                        setChain(Chain chain) { this.chain = chain; }
 42  
 
 43  0
         public List<Set>        getSets() { return(dbf.getSets()); }
 44  0
         public List<Integer>getSizes() { return(dbf.getSizes()); }
 45  0
         public int                        getSizeCount() { return(dbf.getSizeCount()); }
 46  
         
 47  0
         public List<Chain>        getChains() { return(dbf.getChains()); }
 48  
 
 49  
         public        String                getSetSizeCheckboxesHtml() {
 50  0
                 return(pmf.getSetSizeCheckboxesHtml(chain));
 51  
         }
 52  
 
 53  
         public boolean isFiltersSaved() {
 54  0
                 return filtersSaved;
 55  
         }
 56  
         public void setFiltersSaved(boolean filtersSaved) {
 57  0
                 this.filtersSaved = filtersSaved;
 58  0
         }
 59  
         
 60  
         /** Get a String of the set names as Javascript
 61  
          * @return A string
 62  
          */ 
 63  
         public String getSetNamesAsJavaScript() {
 64  0
                 HashMap<String, Boolean>        hasSets = new HashMap<String, Boolean>();
 65  0
                 List<Set>                sets = dbf.getSets();
 66  0
                 int[]                        sizes = dbf.getSizeArray();
 67  0
                 StringBuffer        sb = new StringBuffer();
 68  
                 
 69  0
                 for (Set set : sets) {
 70  0
                         String        setName = set.getName();
 71  0
                         for (int sizesIndex=0; sizesIndex<sizes.length; sizesIndex++) {
 72  0
                                 int        size = sizes[sizesIndex];
 73  0
                                 if (chain.hasSetSize(setName, size)) {
 74  0
                                         hasSets.put(setName, new Boolean(true));
 75  
                                 }
 76  
                         }
 77  0
                 }
 78  0
                 sb.append("var i=0;\nvar hSets = new Array();\n");
 79  0
                 for (String key : hasSets.keySet()) {
 80  0
                         sb.append("hSets[i++] = \"");
 81  0
                         sb.append(key);
 82  0
                         sb.append("\";\n");
 83  0
                 }
 84  
                 
 85  0
                 return(sb.toString());
 86  
         }
 87  
 }