Coverage Report - org.kuali.rice.kew.preferences.web.PreferencesForm
 
Classes in this File Line Coverage Branch Coverage Complexity
PreferencesForm
0%
0/41
0%
0/6
1.615
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.preferences.web;
 18  
 
 19  
 import javax.servlet.http.HttpServletRequest;
 20  
 
 21  
 import org.kuali.rice.kew.preferences.Preferences;
 22  
 import org.kuali.rice.kns.web.struts.form.KualiForm;
 23  
 import org.kuali.rice.krad.exception.ValidationException;
 24  
 import org.kuali.rice.krad.util.GlobalVariables;
 25  
 import org.kuali.rice.krad.util.KRADConstants;
 26  
 
 27  
 
 28  
 /**
 29  
  * Struts ActionForm for {@link PreferencesAction}.
 30  
  *
 31  
  * @see PreferencesAction
 32  
  *
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  */
 35  
 public class PreferencesForm extends KualiForm {
 36  
 
 37  
     private static final long serialVersionUID = 4536869031291955777L;
 38  
     private static final String ERR_KEY_REFRESH_RATE_WHOLE_NUM = "preferences.refreshRate";
 39  
     private static final String ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM = "preferences.pageSize";
 40  
         private Preferences preferences;
 41  0
     private String methodToCall = "";
 42  
     private String returnMapping;
 43  0
     private boolean showOutbox = true;
 44  
 
 45  
     // KULRICE-3137: Added a backLocation parameter similar to the one from lookups.
 46  
     private String backLocation;
 47  
     
 48  
         public String getReturnMapping() {
 49  0
         return returnMapping;
 50  
     }
 51  
     public void setReturnMapping(String returnMapping) {
 52  0
         this.returnMapping = returnMapping;
 53  0
     }
 54  0
     public PreferencesForm() {
 55  0
         preferences = new Preferences();
 56  0
     }
 57  
     public String getMethodToCall() {
 58  0
         return methodToCall;
 59  
     }
 60  
     public void setMethodToCall(String methodToCall) {
 61  0
         this.methodToCall = methodToCall;
 62  0
     }
 63  
     public Preferences getPreferences() {
 64  0
         return preferences;
 65  
     }
 66  
     public void setPreferences(Preferences preferences) {
 67  0
         this.preferences = preferences;
 68  0
     }
 69  
     public boolean isShowOutbox() {
 70  0
         return this.showOutbox;
 71  
     }
 72  
     public void setShowOutbox(boolean showOutbox) {
 73  0
         this.showOutbox = showOutbox;
 74  0
     }
 75  
     
 76  
         public String getBackLocation() {
 77  0
                 return this.backLocation;
 78  
         }
 79  
         public void setBackLocation(String backLocation) {
 80  0
                 this.backLocation = backLocation;
 81  0
         }
 82  
         
 83  
         /**
 84  
          * Retrieves the "returnLocation" parameter after calling "populate" on the superclass.
 85  
          * 
 86  
          * @see org.kuali.rice.krad.web.struts.form.KualiForm#populate(javax.servlet.http.HttpServletRequest)
 87  
          */
 88  
         @Override
 89  
         public void populate(HttpServletRequest request) {
 90  0
                 super.populate(request);
 91  
                 
 92  0
         if (getParameter(request, KRADConstants.RETURN_LOCATION_PARAMETER) != null) {
 93  0
             setBackLocation(getParameter(request, KRADConstants.RETURN_LOCATION_PARAMETER));
 94  
         }
 95  0
         }
 96  
 
 97  
     public void validatePreferences() {
 98  
      
 99  
         try {
 100  0
             new Integer(preferences.getRefreshRate().trim());
 101  0
         } catch (NumberFormatException e) {
 102  0
             GlobalVariables.getMessageMap().putError(ERR_KEY_REFRESH_RATE_WHOLE_NUM, "general.message", "ActionList Refresh Rate must be in whole minutes");
 103  0
         } catch (NullPointerException e1) {
 104  0
             GlobalVariables.getMessageMap().putError(ERR_KEY_REFRESH_RATE_WHOLE_NUM, "general.message", "ActionList Refresh Rate must be in whole minutes");
 105  0
         }
 106  
 
 107  
         try {
 108  0
             new Integer(preferences.getPageSize().trim());
 109  0
             if(new Integer(preferences.getPageSize().trim()) == 0){
 110  0
                      GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be non-zero ");
 111  
             }    
 112  0
         } catch (NumberFormatException e) {
 113  0
             GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be in whole minutes");
 114  0
         } catch (NullPointerException e1) {
 115  0
             GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be in whole minutes");
 116  0
         }
 117  
       
 118  0
         if (GlobalVariables.getMessageMap().hasErrors()) {
 119  0
             throw new ValidationException("errors in preferences");
 120  
         }
 121  0
     }
 122  
 }