|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
   package org.kuali.rice.kns.web.spring.controller;  | 
  |  17 |     | 
     | 
  |  18 |     | 
   import javax.servlet.http.HttpServletRequest;  | 
  |  19 |     | 
   import javax.servlet.http.HttpServletResponse;  | 
  |  20 |     | 
     | 
  |  21 |     | 
   import org.kuali.rice.core.util.RiceKeyConstants;  | 
  |  22 |     | 
   import org.kuali.rice.kns.inquiry.Inquirable;  | 
  |  23 |     | 
   import org.kuali.rice.kns.util.GlobalVariables;  | 
  |  24 |     | 
   import org.kuali.rice.kns.util.KNSConstants;  | 
  |  25 |     | 
   import org.kuali.rice.kns.web.spring.form.InquiryForm;  | 
  |  26 |     | 
   import org.kuali.rice.kns.web.spring.form.UifFormBase;  | 
  |  27 |     | 
   import org.springframework.stereotype.Controller;  | 
  |  28 |     | 
   import org.springframework.validation.BindingResult;  | 
  |  29 |     | 
   import org.springframework.web.bind.annotation.ModelAttribute;  | 
  |  30 |     | 
   import org.springframework.web.bind.annotation.RequestMapping;  | 
  |  31 |     | 
   import org.springframework.web.servlet.ModelAndView;  | 
  |  32 |     | 
     | 
  |  33 |     | 
     | 
  |  34 |     | 
     | 
  |  35 |     | 
     | 
  |  36 |     | 
     | 
  |  37 |     | 
     | 
  |  38 |    0 |    @Controller  | 
  |  39 |     | 
   @RequestMapping(value = "/inquiry")  | 
  |  40 |    0 |    public class InquiryController extends UifControllerBase { | 
  |  41 |    0 |            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(InquiryController.class);  | 
  |  42 |     | 
             | 
  |  43 |     | 
           @Override  | 
  |  44 |     | 
       protected InquiryForm createInitialForm(HttpServletRequest request) { | 
  |  45 |    0 |            return new InquiryForm();  | 
  |  46 |     | 
       }  | 
  |  47 |     | 
     | 
  |  48 |     | 
       @RequestMapping(params = "methodToCall=start")  | 
  |  49 |     | 
       @Override  | 
  |  50 |     | 
           public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, | 
  |  51 |     | 
                           HttpServletRequest request, HttpServletResponse response) { | 
  |  52 |    0 |            InquiryForm inquiryForm = (InquiryForm) form;  | 
  |  53 |     | 
             | 
  |  54 |    0 |                    return continueWithInquiry(inquiryForm, result, request, response);  | 
  |  55 |     | 
           }  | 
  |  56 |     | 
     | 
  |  57 |     | 
             | 
  |  58 |     | 
     | 
  |  59 |     | 
     | 
  |  60 |     | 
     | 
  |  61 |     | 
           @RequestMapping(params = "methodToCall=continueWithInquiry")  | 
  |  62 |     | 
           public ModelAndView continueWithInquiry(@ModelAttribute("KualiForm") InquiryForm inquiryForm, BindingResult result, | 
  |  63 |     | 
                           HttpServletRequest request, HttpServletResponse response) { | 
  |  64 |     | 
     | 
  |  65 |    0 |                    Object bo = retrieveBOFromInquirable(inquiryForm);  | 
  |  66 |    0 |                    checkBO(bo);  | 
  |  67 |     | 
     | 
  |  68 |    0 |                    inquiryForm.setBo(bo);  | 
  |  69 |     | 
     | 
  |  70 |    0 |                    return getUIFModelAndView(inquiryForm);  | 
  |  71 |     | 
           }  | 
  |  72 |     | 
     | 
  |  73 |     | 
             | 
  |  74 |     | 
     | 
  |  75 |     | 
     | 
  |  76 |     | 
     | 
  |  77 |     | 
     | 
  |  78 |     | 
     | 
  |  79 |     | 
     | 
  |  80 |     | 
     | 
  |  81 |     | 
           private void checkBO(Object bo) { | 
  |  82 |    0 |                    if (bo == null && GlobalVariables.getMessageMap().hasNoMessages()) { | 
  |  83 |    0 |                            throw new UnsupportedOperationException("The record you have inquired on does not exist."); | 
  |  84 |     | 
                   }  | 
  |  85 |    0 |            }  | 
  |  86 |     | 
     | 
  |  87 |     | 
           protected Object retrieveBOFromInquirable(InquiryForm inquiryForm) { | 
  |  88 |    0 |                    Inquirable kualiInquirable = inquiryForm.getInquirable();  | 
  |  89 |     | 
     | 
  |  90 |     | 
                     | 
  |  91 |    0 |                    Object  inquiryObject = kualiInquirable.getDataObject(inquiryForm.retrieveInquiryDecryptedPrimaryKeys());  | 
  |  92 |    0 |                    if (inquiryObject == null) { | 
  |  93 |    0 |                            LOG.error("No records found in inquiry action."); | 
  |  94 |    0 |                            GlobalVariables.getMessageMap().putError(KNSConstants.GLOBAL_ERRORS, RiceKeyConstants.ERROR_INQUIRY);  | 
  |  95 |     | 
                   }  | 
  |  96 |     | 
     | 
  |  97 |    0 |                    return inquiryObject;  | 
  |  98 |     | 
           }  | 
  |  99 |     | 
     | 
  |  100 |     | 
   }  |