1 package org.kuali.ole.deliver.controller;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.ole.OLEConstants;
5 import org.kuali.ole.deliver.bo.FeeType;
6 import org.kuali.ole.deliver.bo.ItemBillHelperService;
7 import org.kuali.ole.deliver.form.ItemBillForm;
8 import org.kuali.ole.docstore.discovery.service.QueryServiceImpl;
9 import org.kuali.rice.krad.service.KRADServiceLocator;
10 import org.kuali.rice.krad.util.GlobalVariables;
11 import org.kuali.rice.krad.util.KRADConstants;
12 import org.kuali.rice.krad.web.controller.UifControllerBase;
13 import org.kuali.rice.krad.web.form.UifFormBase;
14 import org.springframework.stereotype.Controller;
15 import org.springframework.validation.BindingResult;
16 import org.springframework.web.bind.annotation.ModelAttribute;
17 import org.springframework.web.bind.annotation.RequestMapping;
18 import org.springframework.web.servlet.ModelAndView;
19
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26
27
28
29
30
31
32
33
34 @Controller
35 @RequestMapping(value = "/itemPatronBill")
36 public class ItemBillController extends UifControllerBase {
37
38 private static final Logger LOG = Logger.getLogger(ItemBillController.class);
39
40
41
42
43
44
45
46 @Override
47 protected ItemBillForm createInitialForm(HttpServletRequest request) {
48 return new ItemBillForm();
49 }
50
51
52
53
54
55
56
57
58
59
60 @Override
61 @RequestMapping(params = "methodToCall=start")
62 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
63 HttpServletRequest request, HttpServletResponse response) {
64 ItemBillForm itemBillForm = (ItemBillForm) form;
65 return super.start(itemBillForm, result, request, response);
66 }
67
68
69
70
71
72
73
74
75
76
77 @RequestMapping(params = "methodToCall=submit")
78 public ModelAndView submitItemBarcode(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
79 HttpServletRequest request, HttpServletResponse response) {
80 ItemBillForm itemBillForm = (ItemBillForm) form;
81 String itemBarcode = itemBillForm.getItemBarcode();
82 if (itemBarcode.equals("") || itemBarcode == null) {
83 GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(KRADConstants.GLOBAL_ERRORS, OLEConstants.ENTR_ITM_BAR);
84 return getUIFModelAndView(itemBillForm);
85 } else if (!(itemBarcode.equals("")) || itemBarcode != null) {
86 List<HashMap<String, Object>> documentList = QueryServiceImpl.getInstance().retriveResults(OLEConstants.ITM_BAR_DISP + itemBarcode);
87 if (documentList != null && documentList.size() == 0) {
88 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.ITM_BAR_NOT_AVAL);
89 return getUIFModelAndView(itemBillForm);
90 }
91 }
92 Map itemBarcodeMap = new HashMap();
93 itemBarcodeMap.put("itemBarcode", itemBarcode);
94 List<FeeType> feeTypeList = (List<FeeType>) KRADServiceLocator.getBusinessObjectService().findMatching(FeeType.class, itemBarcodeMap);
95 if (feeTypeList.size() == 0) {
96 GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(KRADConstants.GLOBAL_ERRORS, OLEConstants.BILL_NOT_AVAI_BAR);
97 return getUIFModelAndView(itemBillForm);
98 }
99 ItemBillHelperService itemBillHelperService = new ItemBillHelperService();
100 List<FeeType> feeTypes = itemBillHelperService.getItemBillDetails(itemBarcode);
101 itemBillForm.setFeeType(itemBillHelperService.getFeeTypeDetails(feeTypes != null && feeTypes.size() > 0 ? feeTypes.get(0) : null));
102 itemBillForm.setFeeTypes(feeTypes);
103 return getUIFModelAndView(itemBillForm, "ItemViewPage");
104 }
105
106
107
108
109
110
111
112
113
114
115 @RequestMapping(params = "methodToCall=clear")
116 public ModelAndView clearItemBarcode(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
117 HttpServletRequest request, HttpServletResponse response) {
118 ItemBillForm itemBillForm = (ItemBillForm) form;
119 itemBillForm.setItemBarcode("");
120 return getUIFModelAndView(itemBillForm, "ItemViewPage");
121
122 }
123
124
125
126
127 @Override
128 @RequestMapping(params = "methodToCall=close")
129 public ModelAndView close(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
130 HttpServletRequest request, HttpServletResponse response) {
131 return super.close(form, result, request, response);
132 }
133
134
135 }