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