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