Coverage Report - org.kuali.rice.kns.web.struts.form.QuestionPromptForm
 
Classes in this File Line Coverage Branch Coverage Complexity
QuestionPromptForm
0%
0/59
0%
0/18
1.37
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.kuali.rice.kns.web.struts.form;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 
 21  
 import javax.servlet.http.HttpServletRequest;
 22  
 
 23  
 import org.kuali.rice.kns.question.Question;
 24  
 import org.kuali.rice.kns.service.KNSServiceLocator;
 25  
 import org.kuali.rice.kns.service.KNSServiceLocatorWeb;
 26  
 import org.kuali.rice.kns.util.KNSConstants;
 27  
 import org.kuali.rice.kns.util.WebUtils;
 28  
 
 29  
 /**
 30  
  * This class is the action form for all Question Prompts.
 31  
  * 
 32  
  * 
 33  
  */
 34  0
 public class QuestionPromptForm extends KualiForm {
 35  
     private static final long serialVersionUID = 1L;
 36  
     private ArrayList buttons;
 37  
     private String caller;
 38  
 
 39  
     private String formKey;
 40  
     private String questionIndex;
 41  
     private String questionText;
 42  
     private String questionType;
 43  
     private String title;
 44  
     private String context;
 45  
     private String reason;
 46  
     private String showReasonField;
 47  
     private String questionAnchor;
 48  
     private String methodToCallPath;
 49  
     private String docNum;
 50  
 
 51  
     /**
 52  
          * @return the docNum
 53  
          */
 54  
         public String getDocNum() {
 55  0
                 return this.docNum;
 56  
         }
 57  
 
 58  
         /**
 59  
          * @param docNum the docNum to set
 60  
          */
 61  
         public void setDocNum(String docNum) {
 62  0
                 this.docNum = docNum;
 63  0
         }
 64  
 
 65  
         /**
 66  
      * @return boolean
 67  
      */
 68  
     public String getShowReasonField() {
 69  0
         return showReasonField;
 70  
     }
 71  
 
 72  
     /**
 73  
      * @param showReasonField
 74  
      */
 75  
     public void setShowReasonField(String showReasonField) {
 76  0
         this.showReasonField = showReasonField;
 77  0
     }
 78  
 
 79  
     /**
 80  
      * @return Returns the buttons.
 81  
      */
 82  
     public ArrayList getButtons() {
 83  0
         return buttons;
 84  
     }
 85  
 
 86  
     /**
 87  
      * @return Returns the caller.
 88  
      */
 89  
     public String getCaller() {
 90  0
         return caller;
 91  
     }
 92  
 
 93  
     /**
 94  
      * @return Returns the formKey.
 95  
      */
 96  
     public String getFormKey() {
 97  0
         return formKey;
 98  
     }
 99  
 
 100  
     /**
 101  
      * @return Returns the questionIndex.
 102  
      */
 103  
     public String getQuestionIndex() {
 104  0
         return questionIndex;
 105  
     }
 106  
 
 107  
     /**
 108  
      * @return Returns the questionText.
 109  
      */
 110  
     public String getQuestionText() {
 111  0
         return questionText != null ? WebUtils.filterHtmlAndReplaceRiceMarkup(questionText) : questionText;
 112  
     }
 113  
 
 114  
     /**
 115  
      * @return Returns the questionName.
 116  
      */
 117  
     public String getQuestionType() {
 118  0
         return questionType;
 119  
     }
 120  
 
 121  
     /**
 122  
      * @return Returns the title.
 123  
      */
 124  
     public String getTitle() {
 125  0
         return title;
 126  
     }
 127  
 
 128  
     /**
 129  
      * @see org.kuali.rice.kns.web.struts.pojo.PojoForm#populate(javax.servlet.http.HttpServletRequest)
 130  
      */
 131  
     public void populate(HttpServletRequest request) {
 132  0
         super.populate(request);
 133  
 
 134  
         // set the title of the jsp, this should come from a resource bundle
 135  0
         title = KNSConstants.QUESTION_PAGE_TITLE;
 136  
 
 137  0
         if (request.getAttribute(KNSConstants.DOC_FORM_KEY) != null) {
 138  0
             this.setFormKey((String) request.getAttribute(KNSConstants.DOC_FORM_KEY));
 139  
         }
 140  0
         else if (request.getParameter(KNSConstants.DOC_FORM_KEY) != null) {
 141  0
             this.setFormKey(request.getParameter(KNSConstants.DOC_FORM_KEY));
 142  
         }
 143  
         
 144  0
         if (request.getAttribute(KNSConstants.DOC_NUM) != null) {
 145  0
             this.setFormKey((String) request.getAttribute(KNSConstants.DOC_NUM));
 146  
         }
 147  
         
 148  
 
 149  0
         if (request.getParameter(KNSConstants.RETURN_LOCATION_PARAMETER) != null) {
 150  0
             this.setBackLocation(request.getParameter(KNSConstants.RETURN_LOCATION_PARAMETER));
 151  
         }
 152  
 
 153  0
         if (getMethodToCall().equals(KNSConstants.START_METHOD)) { // don't do this for the processAnswer action otherwise it blows up
 154  0
             Question kualiQuestion = KNSServiceLocatorWeb.getQuestion(questionType);
 155  0
             if (kualiQuestion == null) {
 156  0
                 throw new RuntimeException("question implementation not found: " + request.getParameter(KNSConstants.QUESTION_IMPL_ATTRIBUTE_NAME));
 157  
             }
 158  
 
 159  
 
 160  
             // some questions types default these so we should default if not
 161  
             // present in request
 162  0
             if (questionText == null) {
 163  0
                 questionText = kualiQuestion.getQuestion();
 164  
             }
 165  
 
 166  0
             if (buttons == null) {
 167  0
                 buttons = kualiQuestion.getButtons();
 168  
             }
 169  
         }
 170  0
     }
 171  
 
 172  
     /**
 173  
      * @param buttons The buttons to set.
 174  
      */
 175  
     public void setButtons(ArrayList buttons) {
 176  0
         this.buttons = buttons;
 177  0
     }
 178  
 
 179  
     /**
 180  
      * @param caller The caller to set.
 181  
      */
 182  
     public void setCaller(String caller) {
 183  0
         this.caller = caller;
 184  0
     }
 185  
 
 186  
     /**
 187  
      * @param formKey The formKey to set.
 188  
      */
 189  
     public void setFormKey(String formKey) {
 190  0
         this.formKey = formKey;
 191  0
     }
 192  
 
 193  
     /**
 194  
      * @param questionIndex The questionIndex to set.
 195  
      */
 196  
     public void setQuestionIndex(String questionIndex) {
 197  0
         this.questionIndex = questionIndex;
 198  0
     }
 199  
 
 200  
     /**
 201  
      * @param questionText The questionText to set.
 202  
      */
 203  
     public void setQuestionText(String questionText) {
 204  0
         this.questionText = questionText;
 205  0
     }
 206  
 
 207  
     /**
 208  
      * @param questionName The questionName to set.
 209  
      */
 210  
     public void setQuestionType(String questionName) {
 211  0
         this.questionType = questionName;
 212  0
     }
 213  
 
 214  
     /**
 215  
      * @param title The title to set.
 216  
      */
 217  
     public void setTitle(String title) {
 218  0
         this.title = title;
 219  0
     }
 220  
 
 221  
     public String getContext() {
 222  0
         return context;
 223  
     }
 224  
 
 225  
     public void setContext(String context) {
 226  0
         this.context = context;
 227  0
     }
 228  
 
 229  
     /**
 230  
      * @return String
 231  
      */
 232  
     public String getReason() {
 233  0
         return reason;
 234  
     }
 235  
 
 236  
     /**
 237  
      * @param reason
 238  
      */
 239  
     public void setReason(String reason) {
 240  0
         this.reason = reason;
 241  0
     }
 242  
 
 243  
     public String getQuestionAnchor() {
 244  0
         return questionAnchor;
 245  
     }
 246  
 
 247  
     public void setQuestionAnchor(String questionAnchor) {
 248  0
         this.questionAnchor = questionAnchor;
 249  0
     }
 250  
 
 251  
     public String getMethodToCallPath() {
 252  0
         return methodToCallPath;
 253  
 }
 254  
     public void setMethodToCallPath(String methodToCallPath) {
 255  0
         this.methodToCallPath = methodToCallPath;
 256  0
     }
 257  
     
 258  
 }