1 package org.kuali.ole.deliver.controller;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.ole.deliver.bo.*;
5 import org.kuali.ole.deliver.processor.LoanProcessor;
6 import org.kuali.ole.deliver.service.OleDeliverRequestDocumentHelperServiceImpl;
7 import org.kuali.ole.krad.OleInquiryController;
8 import org.kuali.rice.krad.web.controller.InquiryController;
9 import org.kuali.rice.krad.web.form.InquiryForm;
10 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
11 import org.kuali.rice.krad.web.form.UifFormBase;
12 import org.springframework.stereotype.Controller;
13 import org.springframework.validation.BindingResult;
14 import org.springframework.web.bind.annotation.ModelAttribute;
15 import org.springframework.web.bind.annotation.RequestMapping;
16 import org.springframework.web.bind.annotation.RequestMethod;
17 import org.springframework.web.servlet.ModelAndView;
18
19 import javax.servlet.http.HttpServletRequest;
20 import javax.servlet.http.HttpServletResponse;
21 import java.util.ArrayList;
22 import java.util.List;
23
24
25
26
27
28
29
30
31 @Controller
32 @RequestMapping(value = "/olePatronInquiry")
33 public class OlePatronDocumentInquiryController extends OleInquiryController {
34 private static final Logger LOG = Logger.getLogger(OlePatronDocumentInquiryController.class);
35
36 private LoanProcessor loanProcessor;
37
38 private LoanProcessor getLoanProcessor() {
39 if (loanProcessor == null) {
40 loanProcessor = new LoanProcessor();
41 }
42 return loanProcessor;
43 }
44
45 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=hidePatronLoanedItem")
46 public ModelAndView hidePatronLoanedItem(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
47 HttpServletRequest request, HttpServletResponse response) {
48
49 InquiryForm form = (InquiryForm) uifForm;
50 OlePatronDocument olePatronDocument=(OlePatronDocument)form.getDataObject();
51
52 olePatronDocument.setShowLoanedRecords(false);
53 return getUIFModelAndView(form);
54 }
55
56 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=showPatronLoanedItem")
57 public ModelAndView showPatronLoanedItem(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
58 HttpServletRequest request, HttpServletResponse response) {
59 InquiryForm form = (InquiryForm) uifForm;
60 OlePatronDocument olePatronDocument=(OlePatronDocument)form.getDataObject();
61 try {
62 olePatronDocument.setOleLoanDocuments(getLoanProcessor().getPatronLoanedItemBySolr(olePatronDocument.getOlePatronId()));
63 } catch (Exception e) {
64 LOG.error("While fetching loan records error occured" + e);
65 }
66 olePatronDocument.setShowLoanedRecords(true);
67 return getUIFModelAndView(form);
68 }
69
70 @Override
71 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request, HttpServletResponse response) {
72 return super.start(form, result, request, response);
73 }
74
75 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=showPatronRequestedRecords")
76 public ModelAndView showPatronRequestedRecords(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
77 HttpServletRequest request, HttpServletResponse response) {
78 LOG.debug("Patron View : showing Patron Requested Records");
79 InquiryForm form = (InquiryForm) uifForm;
80 OlePatronDocument olePatronDocument=(OlePatronDocument)form.getDataObject();
81 try {
82 OleDeliverRequestDocumentHelperServiceImpl requestService = new OleDeliverRequestDocumentHelperServiceImpl();
83 List<OleDeliverRequestBo> oleDeliverRequestBoList = olePatronDocument.getOleDeliverRequestBos();
84 if (oleDeliverRequestBoList.size() > 0) {
85 for (int i = 0; i < oleDeliverRequestBoList.size(); i++) {
86 OleItemSearch oleItemSearch = requestService.getItemDetailsForPatron(oleDeliverRequestBoList.get(i).getItemUuid());
87 if (oleItemSearch != null && oleItemSearch.getItemBarCode() != null) {
88 oleDeliverRequestBoList.get(i).setTitle(oleItemSearch.getTitle());
89 oleDeliverRequestBoList.get(i).setCallNumber(oleItemSearch.getCallNumber());
90 oleDeliverRequestBoList.get(i).setAuthor(oleItemSearch.getAuthor());
91 oleDeliverRequestBoList.get(i).setItemType(oleItemSearch.getItemType());
92 oleDeliverRequestBoList.get(i).setItemStatus(oleItemSearch.getItemStatus());
93 oleDeliverRequestBoList.get(i).setShelvingLocation(oleItemSearch.getShelvingLocation());
94 oleDeliverRequestBoList.get(i).setCopyNumber(oleItemSearch.getCopyNumber());
95 }
96 }
97 }
98 olePatronDocument.setOleDeliverRequestBos(oleDeliverRequestBoList);
99 } catch (Exception e) {
100 LOG.error("While fetching Patron Requested Records error occured" + e);
101 }
102 olePatronDocument.setShowRequestedItems(true);
103 return getUIFModelAndView(form);
104 }
105
106 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=hidePatronRequestedRecords")
107 public ModelAndView hidePatronRequestedRecords(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
108 HttpServletRequest request, HttpServletResponse response) {
109 LOG.debug("Patron View : Hiding Patron Loaned Records");
110 InquiryForm form = (InquiryForm) uifForm;
111 OlePatronDocument olePatronDocument=(OlePatronDocument)form.getDataObject();
112
113 olePatronDocument.setShowRequestedItems(false);
114 return getUIFModelAndView(form);
115 }
116
117 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=showTemporaryCirculationHistoryRecords")
118 public ModelAndView showTemporaryCirculationHistoryRecords(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
119 HttpServletRequest request, HttpServletResponse response) {
120 LOG.debug("Patron View : showing Patron TemporaryCirculationHistory Records");
121 InquiryForm form = (InquiryForm) uifForm;
122 OlePatronDocument olePatronDocument=(OlePatronDocument)form.getDataObject();
123 try {
124 olePatronDocument.setOleTemporaryCirculationHistoryRecords(getLoanProcessor().getPatronTemporaryCirculationHistoryRecords(olePatronDocument.getOlePatronId()));
125 } catch (Exception e) {
126 LOG.error("While fetching Patron TemporaryCirculationHistory Records error occured" + e);
127 }
128
129 olePatronDocument.setShowTemporaryCirculationHistoryRecords(true);
130 return getUIFModelAndView(form);
131 }
132 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=hideTemporaryCirculationHistoryRecords")
133 public ModelAndView hideTemporaryCirculationHistoryRecords(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
134 HttpServletRequest request, HttpServletResponse response) {
135 LOG.debug("Patron View : Hiding Patron Loaned Records");
136 InquiryForm form = (InquiryForm) uifForm;
137 OlePatronDocument olePatronDocument=(OlePatronDocument)form.getDataObject();
138
139 olePatronDocument.setShowTemporaryCirculationHistoryRecords(false);
140 return getUIFModelAndView(form);
141 }
142 }