1 package org.kuali.ole.deliver.controller;
2
3 import org.kuali.ole.deliver.bo.OleDeliverRequestBo;
4 import org.kuali.ole.deliver.drools.DroolsExchange;
5 import org.kuali.ole.deliver.form.CheckinForm;
6 import org.kuali.ole.deliver.form.CircForm;
7 import org.kuali.rice.krad.util.GlobalVariables;
8 import org.kuali.rice.krad.web.form.UifFormBase;
9 import org.springframework.stereotype.Controller;
10 import org.springframework.validation.BindingResult;
11 import org.springframework.web.bind.annotation.ModelAttribute;
12 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.servlet.ModelAndView;
14
15 import javax.servlet.http.HttpServletRequest;
16 import javax.servlet.http.HttpServletResponse;
17 import java.util.HashMap;
18 import java.util.Map;
19
20
21
22
23
24 @Controller
25 @RequestMapping(value = "/autoCheckoutController")
26 public class AutoCheckoutController extends CircController {
27
28 Map<String, Boolean> keyMap;
29
30 @RequestMapping(params = "methodToCall=backgroundCheckout")
31 public ModelAndView backgroundCheckout(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
32 HttpServletRequest request, HttpServletResponse response) throws Exception {
33 CircForm circForm = (CircForm) form;
34 String formKey = request.getParameter("checkinFormKey");
35 if (!getKeyMap().containsKey(formKey)) {
36 getKeyMap().put(formKey, Boolean.TRUE);
37 } else {
38 CheckinForm checkinForm = (CheckinForm) GlobalVariables.getUifFormManager().getSessionForm(formKey);
39 if (null != checkinForm) {
40 circForm.setSelectedCirculationDesk(checkinForm.getSelectedCirculationDesk());
41 circForm.setAutoCheckout(true);
42 DroolsExchange droolsExchange = checkinForm.getDroolsExchange();
43 if (null != droolsExchange) {
44 OleDeliverRequestBo requestBo = (OleDeliverRequestBo) droolsExchange.getFromContext("requestBo");
45 if (null != requestBo) {
46 circForm.setPatronBarcode(requestBo.getBorrowerBarcode());
47 circForm.setItemBarcode(requestBo.getItemId());
48
49 }
50 }
51 }
52 ModelAndView modelAndView = searchPatron(circForm, result, request, response);
53 getKeyMap().remove(formKey);
54 return modelAndView;
55 }
56 return getUIFModelAndView(circForm);
57 }
58
59
60 public Map<String, Boolean> getKeyMap() {
61 if (null == keyMap) {
62 keyMap = new HashMap<>();
63 }
64 return keyMap;
65 }
66
67 public void setKeyMap(Map<String, Boolean> keyMap) {
68 this.keyMap = keyMap;
69 }
70 }