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.exception.WorkflowServiceErrorImpl;
 22  
 import org.kuali.rice.kew.preferences.Preferences;
 23  
 import org.kuali.rice.kew.util.KEWConstants;
 24  
 import org.kuali.rice.kns.exception.ValidationException;
 25  
 import org.kuali.rice.kns.util.GlobalVariables;
 26  
 import org.kuali.rice.kns.util.KNSConstants;
 27  
 import org.kuali.rice.kns.web.struts.form.KualiForm;
 28  
 
 29  
 
 30  
 /**
 31  
  * Struts ActionForm for {@link PreferencesAction}.
 32  
  *
 33  
  * @see PreferencesAction
 34  
  *
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  */
 37  
 public class PreferencesForm extends KualiForm {
 38  
 
 39  
     private static final long serialVersionUID = 4536869031291955777L;
 40  
     private static final String ERR_KEY_REFRESH_RATE_WHOLE_NUM = "preferences.refreshRate";
 41  
     private static final String ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM = "preferences.pageSize";
 42  
         private Preferences preferences;
 43  0
     private String methodToCall = "";
 44  
     private String returnMapping;
 45  0
     private boolean showOutbox = true;
 46  
 
 47  
     // KULRICE-3137: Added a backLocation parameter similar to the one from lookups.
 48  
     private String backLocation;
 49  
     
 50  
         public String getReturnMapping() {
 51  0
         return returnMapping;
 52  
     }
 53  
     public void setReturnMapping(String returnMapping) {
 54  0
         this.returnMapping = returnMapping;
 55  0
     }
 56  0
     public PreferencesForm() {
 57  0
         preferences = new Preferences();
 58  0
     }
 59  
     public String getMethodToCall() {
 60  0
         return methodToCall;
 61  
     }
 62  
     public void setMethodToCall(String methodToCall) {
 63  0
         this.methodToCall = methodToCall;
 64  0
     }
 65  
     public Preferences getPreferences() {
 66  0
         return preferences;
 67  
     }
 68  
     public void setPreferences(Preferences preferences) {
 69  0
         this.preferences = preferences;
 70  0
     }
 71  
     public boolean isShowOutbox() {
 72  0
         return this.showOutbox;
 73  
     }
 74  
     public void setShowOutbox(boolean showOutbox) {
 75  0
         this.showOutbox = showOutbox;
 76  0
     }
 77  
     
 78  
         public String getBackLocation() {
 79  0
                 return this.backLocation;
 80  
         }
 81  
         public void setBackLocation(String backLocation) {
 82  0
                 this.backLocation = backLocation;
 83  0
         }
 84  
         
 85  
         /**
 86  
          * Retrieves the "returnLocation" parameter after calling "populate" on the superclass.
 87  
          * 
 88  
          * @see org.kuali.rice.kns.web.struts.form.KualiForm#populate(javax.servlet.http.HttpServletRequest)
 89  
          */
 90  
         @Override
 91  
         public void populate(HttpServletRequest request) {
 92  0
                 super.populate(request);
 93  
                 
 94  0
         if (getParameter(request, KNSConstants.RETURN_LOCATION_PARAMETER) != null) {
 95  0
             setBackLocation(getParameter(request, KNSConstants.RETURN_LOCATION_PARAMETER));
 96  
         }
 97  0
         }
 98  
 
 99  
     public void validatePreferences() {
 100  
      
 101  
         try {
 102  0
             new Integer(preferences.getRefreshRate().trim());
 103  0
         } catch (NumberFormatException e) {
 104  0
             GlobalVariables.getMessageMap().putError(ERR_KEY_REFRESH_RATE_WHOLE_NUM, "general.message", "ActionList Refresh Rate must be in whole minutes");
 105  0
         } catch (NullPointerException e1) {
 106  0
             GlobalVariables.getMessageMap().putError(ERR_KEY_REFRESH_RATE_WHOLE_NUM, "general.message", "ActionList Refresh Rate must be in whole minutes");
 107  0
         }
 108  
 
 109  
         try {
 110  0
             new Integer(preferences.getPageSize().trim());
 111  0
             if(new Integer(preferences.getPageSize().trim()) == 0){
 112  0
                      GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be non-zero ");
 113  
             }    
 114  0
         } catch (NumberFormatException e) {
 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
         } catch (NullPointerException e1) {
 117  0
             GlobalVariables.getMessageMap().putError(ERR_KEY_ACTION_LIST_PAGE_SIZE_WHOLE_NUM, "general.message", "ActionList Page Size must be in whole minutes");
 118  0
         }
 119  
       
 120  0
         if (GlobalVariables.getMessageMap().hasErrors()) {
 121  0
             throw new ValidationException("errors in preferences");
 122  
         }
 123  0
     }
 124  
 }