View Javadoc

1   package org.kuali.ole.deliver.loan.controller;
2   
3   import org.apache.log4j.Logger;
4   import org.kuali.ole.LoanUtil;
5   import org.kuali.ole.OLEConstants;
6   import org.kuali.ole.deliver.circulationdesk.keyvalue.CirculationDeskChangeKeyValue;
7   import org.kuali.ole.deliver.loan.LoanProcessor;
8   import org.kuali.ole.deliver.loan.bo.OleLoanDocument;
9   import org.kuali.ole.deliver.loan.bo.OleLoanFastAdd;
10  import org.kuali.ole.deliver.loan.form.OleLoanForm;
11  import org.kuali.ole.deliver.loan.printSlip.OlePrintSlip;
12  import org.kuali.ole.docstore.model.xmlpojo.work.instance.oleml.*;
13  import org.kuali.ole.location.bo.OleLocation;
14  import org.kuali.ole.patron.bo.OlePatronDocument;
15  import org.kuali.ole.pojo.bib.BibliographicRecord;
16  import org.kuali.ole.service.OleDeliveryDocstoreService;
17  import org.kuali.ole.service.impl.OleDeliveryDocstoreServiceImpl;
18  import org.kuali.rice.krad.util.GlobalVariables;
19  import org.kuali.rice.krad.web.controller.UifControllerBase;
20  import org.kuali.rice.krad.web.form.UifFormBase;
21  import org.springframework.stereotype.Controller;
22  import org.springframework.validation.BindingResult;
23  import org.springframework.web.bind.annotation.ModelAttribute;
24  import org.springframework.web.bind.annotation.RequestMapping;
25  import org.springframework.web.servlet.ModelAndView;
26  
27  import javax.servlet.http.HttpServletRequest;
28  import javax.servlet.http.HttpServletResponse;
29  import java.sql.Timestamp;
30  import java.util.*;
31  
32  /**
33   * The LoanController is the controller class for processing all the actions that corresponds to the Loan functionality in OLE.
34   * The request mapping tag takes care of mapping the individual action to the corresponding functions.
35   */
36  @Controller
37  @RequestMapping(value = "/loancontroller")
38  public class LoanController extends UifControllerBase {
39  
40      private static final Logger LOG = Logger.getLogger(LoanController.class);
41  
42      private List<OleLoanDocument>  printDueDateSlipList = new ArrayList<OleLoanDocument>();
43  
44      /**
45       *  This method creates new OleLoan form
46       * @param request
47       * @return  OleLoanForm
48       */
49      @Override
50      protected OleLoanForm createInitialForm(HttpServletRequest request) {
51          return new OleLoanForm();
52      }
53  
54      /**
55       *  This method converts UifFormBase to OleLoanForm
56       * @param form
57       * @param result
58       * @param request
59       * @param response
60       * @return ModelAndView
61       */
62      @Override
63      @RequestMapping(params = "methodToCall=start")
64      public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
65                                HttpServletRequest request, HttpServletResponse response) {
66          LOG.debug("Inside the loan start method");
67          OleLoanForm oleLoanForm = (OleLoanForm) form;
68          String parameter =getLoanProcessor().getParameter(OLEConstants.MAX_TIME_CHECK_IN);
69          Integer maxTimeForCheckInDate = Integer.parseInt(parameter)*60;
70          oleLoanForm.setMaxTimeForCheckInDate(maxTimeForCheckInDate);
71          oleLoanForm.setCheckInDateMaxTime(maxTimeForCheckInDate);
72          oleLoanForm.setDateAlertMessage(OLEConstants.CHECK_IN_DATE);
73          oleLoanForm.setCurrentDate(new Date());
74          if(oleLoanForm.getCheckInDate()==null){
75              oleLoanForm.setCheckInDate(new Date());
76          }
77          return super.start(oleLoanForm, result, request, response);
78      }
79  
80      /**
81       *   This method displays information about a patron in UI.
82       * @param form
83       * @param result
84       * @param request
85       * @param response
86       * @return ModelAndView
87       */
88      @RequestMapping(params = "methodToCall=searchPatron")
89      public ModelAndView searchPatron(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
90                                       HttpServletRequest request, HttpServletResponse response) {
91          LOG.debug("Inside the search patron method");
92          OleLoanForm oleLoanForm = (OleLoanForm) form;
93          oleLoanForm.setInformation("");
94          oleLoanForm.setReturnInformation("");
95          LoanProcessor loanProcessor = getLoanProcessor();
96          try{
97              String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
98              LOG.info("session timeout"+maxSessionTime);
99              if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
100                 oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
101 
102             if(oleLoanForm.getCirculationDesk() ==null){
103                 LOG.error(OLEConstants.CIR_LOC_NULL);
104                 throw new Exception(OLEConstants.CIR_LOC_NULL);
105             }
106             List<OlePatronDocument> oleRealPatron= oleLoanForm.getRealPatronList();
107             if(oleRealPatron != null && oleRealPatron.size()>0 && !oleLoanForm.isSelfCheckOut()){
108                 for(int realPatron=0;realPatron<oleRealPatron.size();realPatron++){
109                     OlePatronDocument olePatronDocument = oleRealPatron.get(realPatron);
110                     if(olePatronDocument.isRealPatronCheck()){
111                         oleLoanForm.setRealPatronBarcode(olePatronDocument.getBarcode());
112                         oleLoanForm.setRealPatronFlag(false);
113                     }
114                 }
115             }
116             if(oleLoanForm.isSelfCheckOut()){
117                 oleLoanForm.setRealPatronFlag(false);
118             }
119 
120             OleLoanDocument oleLoanDocument = loanProcessor.getLoanDocument(oleLoanForm.getPatronBarcode(), oleLoanForm.getRealPatronBarcode(),oleLoanForm.isSelfCheckOut());
121             if(oleLoanDocument.getPatronUserNotes() != null){
122                 oleLoanForm.setPatronNoteFlag(true);
123                 oleLoanForm.setPatronUserNote(oleLoanDocument.getPatronUserNotes());
124                 oleLoanForm.setPatronNoteTypeId(oleLoanDocument.getPatronNoteTypeId());
125             }
126             if(oleLoanDocument.getRealPatron()!=null && oleLoanDocument.getRealPatron().size() > 1){
127                 oleLoanForm.setRealPatronList(oleLoanDocument.getRealPatron());
128                 oleLoanForm.setRealPatronFlag(true);
129             }
130             oleLoanForm.setBorrowerType(oleLoanDocument.getBorrowerTypeName());
131             oleLoanForm.setPatronName(oleLoanDocument.getPatronName());
132             oleLoanForm.setPatronId(oleLoanDocument.getPatronId());
133             oleLoanForm.setProxyPatronId(oleLoanDocument.getProxyPatronId());
134             oleLoanForm.setRealPatronName(oleLoanDocument.getRealPatronName());
135             oleLoanForm.setRealPatronType(oleLoanDocument.getRealPatronType());
136             oleLoanForm.setAddressVerified(oleLoanDocument.isAddressVerified());
137             oleLoanForm.setBlockLoan(oleLoanDocument.isBlockLoan());
138             oleLoanForm.setBorrowerTypeId(oleLoanDocument.getBorrowerTypeId());
139             oleLoanForm.setPreferredAddress(oleLoanDocument.getPreferredAddress());
140             oleLoanForm.setEmail(oleLoanDocument.getEmail());
141             oleLoanForm.setPhoneNumber(oleLoanDocument.getPhoneNumber());
142             oleLoanForm.setInformation("");
143             oleLoanForm.setExistingLoanList(loanProcessor.getPatronLoanedItem(oleLoanDocument.getPatronId()));
144             oleLoanForm.setDummyLoan(oleLoanDocument);
145             if(oleLoanDocument.getErrorMessage()!=null){
146                 oleLoanForm.setSuccess(false);
147                 oleLoanForm.setInformation("");
148                 oleLoanForm.setMessage(oleLoanDocument.getErrorMessage());
149                 oleLoanForm.setPatronName(null);
150             }
151         }catch (Exception e){
152             oleLoanForm.setInformation(e.getMessage());
153         }
154         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
155     }
156 
157     /**
158      * This method creates new loan for a patron..
159      * @param form
160      * @param result
161      * @param request
162      * @param response
163      * @return ModelAndView
164      */
165     @RequestMapping(params = "methodToCall=addItem")
166     public ModelAndView addItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
167                                 HttpServletRequest request, HttpServletResponse response) {
168         LOG.debug("Inside the add item method");
169         OleLoanForm oleLoanForm = (OleLoanForm) form;
170         oleLoanForm.setOleFormKey(oleLoanForm.getFormKey());
171         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
172         LOG.info("session timeout"+maxSessionTime);
173         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
174             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
175         oleLoanForm.setInformation("");
176         oleLoanForm.setReturnInformation("");
177         boolean renewalFlag=false;
178         List<OleLoanDocument> existItemList=new ArrayList<OleLoanDocument>();
179         if(oleLoanForm.getExistingLoanList()!=null && !oleLoanForm.getExistingLoanList().isEmpty())
180             existItemList.addAll(oleLoanForm.getExistingLoanList());
181         if(oleLoanForm.getLoanList()!=null && !oleLoanForm.getLoanList().isEmpty())
182             existItemList.addAll(oleLoanForm.getLoanList());
183         String item=oleLoanForm.getItem();
184         for(int i=0;i<existItemList.size();i++) {
185             OleLoanDocument oleLoanDocument=existItemList.get(i);
186             if(oleLoanDocument.getItemId() != null && oleLoanDocument.getItemId().equals(item)){
187                 oleLoanForm.setRenewalFlag(true);
188                 oleLoanForm.setSuccess(false);
189                 oleLoanForm.setMessage(OLEConstants.RENEWAL_ITM_POPUP);
190                 renewalFlag=true;
191                 break;
192             }
193         }
194 
195         if(!renewalFlag)  {
196 
197             try{
198                 List<OleLoanDocument> existingItemList = new ArrayList<OleLoanDocument>();
199                 OleLoanDocument oleLoanDocument = new OleLoanDocument();
200                 oleLoanDocument.setPatronId(oleLoanForm.getPatronId());
201                 oleLoanDocument.setProxyPatronId(oleLoanForm.getProxyPatronId());
202                 oleLoanDocument.setRealPatronBarcode(oleLoanForm.getRealPatronBarcode());
203                 oleLoanDocument.setRealPatronType(oleLoanForm.getRealPatronType());
204                 oleLoanDocument.setCirculationLocationId(oleLoanForm.getCirculationDesk());
205                 oleLoanDocument.setBorrowerTypeId(oleLoanForm.getBorrowerTypeId());
206                 oleLoanDocument.setBorrowerTypeName(oleLoanForm.getBorrowerType());
207                 oleLoanForm.setAddressVerified(false);
208                 oleLoanDocument = getLoanProcessor().addLoan(oleLoanForm.getPatronBarcode(),oleLoanForm.getItem(),oleLoanDocument);
209                 oleLoanForm.setItemUuid(oleLoanDocument.getItemUuid());
210                 oleLoanForm.setInstanceUuid(oleLoanDocument.getInstanceUuid());
211                 oleLoanForm.setOleItem(oleLoanDocument.getOleItem());
212                 oleLoanForm.setDueDateMap(oleLoanDocument.getLoanDueDate());
213                 oleLoanForm.setMessage(oleLoanDocument.getErrorMessage());
214                 if(oleLoanForm.getPatronName()==null){
215                     oleLoanForm.setPatronName(oleLoanDocument.getPatronName());
216                 }
217                 if(oleLoanDocument.getErrorMessage() == null){
218                     existingItemList.add(oleLoanDocument);
219                     oleLoanForm.setItem("");
220                     oleLoanForm.setInformation("");
221                 } else {
222                     oleLoanForm.setDueDateEmpty(oleLoanDocument.isDueDateEmpty());
223                     oleLoanForm.setDummyLoan(oleLoanDocument);
224                     oleLoanForm.setSuccess(false);
225                     oleLoanForm.setInformation("");
226                 }
227                 if(oleLoanForm.getLoanList()!=null && !oleLoanForm.getLoanList().isEmpty()){
228                     existingItemList.addAll(oleLoanForm.getLoanList());
229                 }
230                 oleLoanForm.setLoanList(existingItemList);
231                 List<OleLoanDocument> oleLoanDocumentList = new ArrayList<OleLoanDocument>();
232                 oleLoanDocumentList.add(oleLoanDocument);
233                 if(LoanUtil.getLoanUtil().getProperty("PRINT_DUE_DATE_PER_TRANSACTION").equalsIgnoreCase("Yes")){
234                     oleLoanForm.setDueDateSlip(true);
235                 }
236             }catch (Exception e){
237                 oleLoanForm.setInformation(e.getMessage());
238 
239             }
240         }
241         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
242     }
243 
244     /**
245      * This method  creates loan for a patron who is not able to borrow.
246      * @param form
247      * @param result
248      * @param request
249      * @param response
250      * @return  ModelAndView
251      */
252     @RequestMapping(params = "methodToCall=loan")
253     public ModelAndView loanPatron(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
254                                    HttpServletRequest request, HttpServletResponse response) {
255         LOG.debug("Inside the loan patron method");
256         OleLoanForm oleLoanForm = (OleLoanForm) form;
257         oleLoanForm.setInformation("");
258         oleLoanForm.setReturnInformation("");
259         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
260         LOG.info("session timeout"+maxSessionTime);
261         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
262             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
263         OleLoanDocument oleLoanDocumentChk = null;
264         ModelAndView overrideModelView = null;
265         if(oleLoanForm.getItem()==null){
266             try{
267 
268                 String principalId= GlobalVariables.getUserSession().getPrincipalId();
269                 Boolean overRideFlag=getLoanProcessor().checkOverRidePermission(principalId);
270                 if(!overRideFlag){
271                   oleLoanDocumentChk = getLoanProcessor().getLoanDocument(oleLoanForm.getPatronBarcode(),oleLoanForm.getRealPatronBarcode(),oleLoanForm.isSelfCheckOut());
272                     if(oleLoanDocumentChk.getErrorMessage()!= null){
273                         overrideModelView=this.overRide(form,result,request,response);
274                     }
275                 }
276             }catch (Exception e){
277                LOG.error("Check for Address Verified and Block Failed."+e.getMessage());
278                e.getMessage();
279             }
280 
281         }else{
282             overrideModelView=this.overRide(form,result,request,response);
283         }
284 
285 
286         if(overrideModelView==null){
287             try{
288                 List<OleLoanDocument> existingItemList = new ArrayList<OleLoanDocument>();
289                 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
290                 if(oleLoanDocument!=null){
291                     if(oleLoanForm.getDueDateMap()!=null){
292                         oleLoanDocument.setLoanDueDate(new java.sql.Timestamp(oleLoanForm.getDueDateMap().getTime()));
293                         getLoanProcessor().saveLoan(oleLoanDocument);
294                         existingItemList.add(oleLoanDocument);
295                         if(oleLoanForm.getLoanList()!=null && !oleLoanForm.getLoanList().isEmpty()){
296                             existingItemList.addAll(oleLoanForm.getLoanList());
297                         }
298                         oleLoanForm.setLoanList(existingItemList);
299                     }
300                     if(oleLoanForm.getPatronName()==null){
301                         oleLoanForm.setPatronName(oleLoanDocument.getPatronName());
302                     }
303                     oleLoanForm.setSuccess(true);
304                     oleLoanForm.setMessage(null);
305                     oleLoanForm.setItem("");
306                     oleLoanForm.setInformation("");
307                     oleLoanForm.setAddressVerified(false);
308                 }
309             }catch (Exception e){
310                 oleLoanForm.setInformation(e.getMessage());
311             }
312         }
313         oleLoanForm.setOleFormKey(oleLoanForm.getFormKey());
314         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
315     }
316 
317     /**
318      * This method doesn't allow a patron to be loaned.
319      *  @param form
320      * @param result
321      * @param request
322      * @param response
323      * @return ModelAndView
324      */
325     @RequestMapping(params = "methodToCall=noLoan")
326     public ModelAndView doNotLoanPatron(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
327                                         HttpServletRequest request, HttpServletResponse response) {
328         LOG.debug("Inside the do not loan patron method");
329         OleLoanForm oleLoanForm = (OleLoanForm) form;
330         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
331         LOG.info("session timeout"+maxSessionTime);
332         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
333             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
334         oleLoanForm.setAddressVerified(false);
335         oleLoanForm.setItem("");
336         oleLoanForm.setInformation("");
337         oleLoanForm.setReturnInformation("");
338         oleLoanForm.setDueDateSlip(false);
339         oleLoanForm.setMessage(null);
340         oleLoanForm.setSuccess(true);
341         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
342     }
343 
344     @RequestMapping(params = "methodToCall=displayFastAdd")
345     public ModelAndView displayFastAdd(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
346                                        HttpServletRequest request, HttpServletResponse response) {
347         LOG.debug("Inside the display Fast Add method");
348         OleLoanForm oleLoanForm = (OleLoanForm) form;
349         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
350         LOG.info("session timeout"+maxSessionTime);
351         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
352             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
353         String locationId = request.getParameter("locationId");
354         oleLoanForm.setInformation("");
355         oleLoanForm.setReturnInformation("");
356         try {
357             OleLocation location = getLoanProcessor().getLocationByLocationId(locationId);
358             if(location != null){
359                 OleLoanFastAdd oleLoanFastAdd = new OleLoanFastAdd();
360                 oleLoanFastAdd.setCirculationLocation(location.getLocationCode());
361                 oleLoanForm.setOleLoanFastAdd(oleLoanFastAdd);
362             }
363         } catch (Exception e) {
364             oleLoanForm.setInformation(e.getMessage());
365         }
366         return getUIFModelAndView(oleLoanForm, "FastAddItemViewPage");
367     }
368 
369 
370     @RequestMapping(params = "methodToCall=createFastAddItem")
371     public ModelAndView createFastAddItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
372                                           HttpServletRequest request, HttpServletResponse response) {
373         LOG.debug("Inside the create fast add item method");
374         OleLoanForm oleLoanForm = (OleLoanForm) form;
375         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
376         LOG.info("session timeout"+maxSessionTime);
377         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
378             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
379         oleLoanForm.setInformation("");
380         oleLoanForm.setReturnInformation("");
381         LoanProcessor loanProcessor = getLoanProcessor();
382         boolean validateFastAdd = false;
383 
384         try{
385            validateFastAdd = loanProcessor.validateFastAddItem(oleLoanForm.getOleLoanFastAdd().getBarcode());
386         }catch (Exception fastAdd){
387             oleLoanForm.setInformation(OLEConstants.FAST_ADD_ITM_VALIDATION_FAIL);
388         }
389         if(validateFastAdd){
390         BibliographicRecord bibliographicRecord=loanProcessor.getBibliographicRecord(oleLoanForm.getOleLoanFastAdd().getTitle());
391         Item item= loanProcessor.getItemRecord(oleLoanForm.getOleLoanFastAdd());
392         OleHoldings oleHoldings = loanProcessor.getHoldingRecord(item);
393         OleDeliveryDocstoreService oleDeliveryDocstoreService=new OleDeliveryDocstoreServiceImpl();
394         String responseXML=oleDeliveryDocstoreService.persistNewToDocstoreForIngest(bibliographicRecord,item,oleHoldings);
395 
396         if(responseXML==null)
397             oleLoanForm.setInformation(OLEConstants.FAST_ADD_ITM_ERR_INFO);
398         else
399             oleLoanForm.setInformation(OLEConstants.FAST_ADD_ITM_SUCCESS_INFO);
400         }else{
401             oleLoanForm.setInformation(OLEConstants.FAST_ADD_ITM_VALIDATION_FAIL);
402         }
403         return getUIFModelAndView(oleLoanForm, "FastAddItemViewPage");
404     }
405 
406     @RequestMapping(params = "methodToCall=deletePatronUserNote")
407     public ModelAndView deletePatronUserNote(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
408                                              HttpServletRequest request, HttpServletResponse response) {
409         LOG.debug("Inside the delete patron user note method");
410         OleLoanForm oleLoanForm = (OleLoanForm) form;
411         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
412         LOG.info("session timeout"+maxSessionTime);
413         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
414             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
415         oleLoanForm.setPatronNoteFlag(false);
416 
417         try {
418             getLoanProcessor().deletePatronUserNote(oleLoanForm.getPatronId(),oleLoanForm.getPatronNoteTypeId());
419         } catch (Exception e) {
420             oleLoanForm.setInformation(e.getMessage());
421         }
422         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
423     }
424 
425 
426     @RequestMapping(params = "methodToCall=editDueDate")
427     public ModelAndView editDueDate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
428                                     HttpServletRequest request, HttpServletResponse response) {
429         LOG.debug("Inside the edit due date method");
430         OleLoanForm oleLoanForm = (OleLoanForm) form;
431         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
432         LOG.info("session timeout"+maxSessionTime);
433         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
434             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
435         oleLoanForm.setInformation("");
436         oleLoanForm.setReturnInformation("");
437         //oleLoanForm.setAlterDueDateList(null);
438         List<OleLoanDocument> alterDueDateList = new ArrayList<OleLoanDocument>();
439         alterDueDateList = getLoanProcessor().setListValues(oleLoanForm.getLoanList(),oleLoanForm.getExistingLoanList(),false,null);
440 
441         if(alterDueDateList.size()!=0)  {
442             oleLoanForm.setAlterDueDateList(alterDueDateList);
443             oleLoanForm.setInformation("");
444             ModelAndView overrideModelView=this.overRide(form,result,request,response);
445             if(overrideModelView==null)
446                 oleLoanForm.setAlterDueDateFlag(true);
447         }
448         else
449             oleLoanForm.setInformation(OLEConstants.ALTER_DUE_DATE_ERR_INFO);
450 
451         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
452     }
453 
454     @RequestMapping(params = "methodToCall=updateDueDate")
455     public ModelAndView updateDueDate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
456                                       HttpServletRequest request, HttpServletResponse response) {
457         LOG.debug("Inside the update due date method");
458         OleLoanForm oleLoanForm = (OleLoanForm) form;
459         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
460         LOG.info("session timeout"+maxSessionTime);
461         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
462             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
463         oleLoanForm.setInformation("");
464         oleLoanForm.setReturnInformation("");
465         try{
466             getLoanProcessor().updateLoan(oleLoanForm.getAlterDueDateList());
467         }catch (Exception e){
468             oleLoanForm.setInformation(e.getMessage());
469         }
470         oleLoanForm.setAlterDueDateFlag(false);
471         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
472     }
473 
474     @RequestMapping(params = "methodToCall=closeAlterDueDate")
475     public ModelAndView closeAlterDueDate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
476                                       HttpServletRequest request, HttpServletResponse response) {
477         LOG.debug("Inside the close Alter due date method");
478         OleLoanForm oleLoanForm = (OleLoanForm) form;
479         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
480         LOG.info("session timeout"+maxSessionTime);
481         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
482             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
483         List<OleLoanDocument> resetAlterDueDate =oleLoanForm.getAlterDueDateList();
484         if(resetAlterDueDate!=null){
485             for(int restDueDate=0;restDueDate<resetAlterDueDate.size();restDueDate++){
486                 OleLoanDocument oleLoanDocument = (OleLoanDocument)resetAlterDueDate.get(restDueDate);
487                 oleLoanDocument.setLoanDueDate(new Timestamp(oleLoanDocument.getPastDueDate().getTime()));
488                 oleLoanDocument.setPastDueDate(null);
489             }
490         }
491 
492         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
493     }
494 
495     @RequestMapping(params = "methodToCall=claimsReturn")
496     public ModelAndView claimsReturn(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
497                                      HttpServletRequest request, HttpServletResponse response) {
498         LOG.debug("Inside the claims return method");
499         OleLoanForm oleLoanForm = (OleLoanForm) form;
500         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
501         LOG.info("session timeout"+maxSessionTime);
502         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
503             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
504         oleLoanForm.setInformation("");
505         oleLoanForm.setReturnInformation("");
506         boolean checkedItemsFlag=false;
507         for(int curremtLoan=0;curremtLoan< oleLoanForm.getExistingLoanList().size();curremtLoan++){
508             OleLoanDocument oleLoanDocument = (OleLoanDocument)oleLoanForm.getExistingLoanList().get(curremtLoan);
509             if(oleLoanDocument.isCheckNo())  {
510                 checkedItemsFlag=true;
511                 break;
512             }
513         }
514         if(checkedItemsFlag){
515             oleLoanForm.setInformation("");
516             ModelAndView overrideModelView=this.overRide(form,result,request,response);
517             if(overrideModelView==null)
518                 oleLoanForm.setClaimsReturnFlag(true);
519         }
520         else
521             oleLoanForm.setInformation(OLEConstants.CLAIMS_ITM_ERR_INFO);
522         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
523     }
524 
525     @RequestMapping(params = "methodToCall=applyClaimsReturn")
526     public ModelAndView applyClaimsReturn(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
527                                           HttpServletRequest request, HttpServletResponse response) {
528         LOG.debug("Inside the apply claims return method");
529         OleLoanForm oleLoanForm = (OleLoanForm) form;
530         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
531         LOG.info("session timeout"+maxSessionTime);
532         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
533             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
534         oleLoanForm.setInformation("");
535         oleLoanForm.setReturnInformation("");
536         List<OleLoanDocument> claimsList = new ArrayList<OleLoanDocument>();
537         LoanProcessor loanProcessor = getLoanProcessor();
538         claimsList = loanProcessor.setListValues(oleLoanForm.getLoanList(), oleLoanForm.getExistingLoanList(), oleLoanForm.isClaimsReturnFlag(), oleLoanForm.getClaimsReturnMap());
539         try{
540             loanProcessor.updateLoan(claimsList);
541         }catch (Exception e){
542             oleLoanForm.setInformation(e.getMessage());
543         }
544         oleLoanForm.setClaimsReturnFlag(false);
545         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
546     }
547 
548     @RequestMapping(params = "methodToCall=changeCirculationDeskLocation")
549     public ModelAndView changeCirculationDeskLocation(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
550                                                       HttpServletRequest request, HttpServletResponse response){
551         LOG.debug("Inside the change circulation desk location method");
552         OleLoanForm oleLoanForm = (OleLoanForm) form;
553         oleLoanForm.setConfirmMessage(OLEConstants.CHANGE_LOC_MESS);
554         oleLoanForm.setChangeLocationFlag(true);
555         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
556     }
557 
558     @RequestMapping(params = "methodToCall=resetLocation")
559     public ModelAndView resetLocation(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
560                                                       HttpServletRequest request, HttpServletResponse response){
561         LOG.debug("Inside the reset location method");
562         OleLoanForm oleLoanForm = (OleLoanForm) form;
563         oleLoanForm.setCirculationDesk(oleLoanForm.getPreviousCirculationDesk());
564         oleLoanForm.setChangeLocationFlag(false);
565         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
566     }
567     /**
568      *  This method clear UI for next borrower session..
569      * @param form
570      * @param result
571      * @param request
572      * @param response
573      * @return  ModelAndView
574      */
575     @RequestMapping(params = "methodToCall=saveAndClear")
576     public ModelAndView clearPatron(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
577                                     HttpServletRequest request, HttpServletResponse response) {
578         LOG.debug("Inside the clear patron method");
579         OleLoanForm oleLoanForm = (OleLoanForm) form;
580         String currentLocation = oleLoanForm.getCirculationDesk();
581         oleLoanForm.setPreviousCirculationDesk(currentLocation);
582         if(oleLoanForm.getLoanList() != null && oleLoanForm.getLoanList().size()>0 && !oleLoanForm.isChangeLocationFlag() && LoanUtil.getLoanUtil().getProperty("PRINT_DUE_DATE_PER_TRANSACTION").equalsIgnoreCase("No")){
583             oleLoanForm.setDueDateSlip(true);
584             printDueDateSlipList = oleLoanForm.getLoanList();
585         }
586         oleLoanForm.setAddressVerified(false);
587         oleLoanForm.setInformation("");
588         oleLoanForm.setReturnInformation("");
589         oleLoanForm.setBorrowerType(null);
590         oleLoanForm.setPatronBarcode(null);
591         oleLoanForm.setPatronName(null);
592         oleLoanForm.setProxyPatronId(null);
593         oleLoanForm.setRealPatronBarcode(null);
594         oleLoanForm.setPatronId(null);
595         oleLoanForm.setRealPatronList(null);
596         oleLoanForm.setLoanList(null);
597         oleLoanForm.setDueDateMap(null);
598         oleLoanForm.setExistingLoanList(null);
599         oleLoanForm.setDueDateMap(null);
600         oleLoanForm.setMessage(null);
601         oleLoanForm.setSuccess(true);
602 
603         oleLoanForm.setChangeLocationFlag(false);
604         oleLoanForm.setBlockLoan(false);
605         if(!"".equals(oleLoanForm.getNewPrincipalId())){
606             GlobalVariables.getUserSession().clearBackdoorUser();
607             oleLoanForm.setNewPrincipalId(null);
608         }
609         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
610     }
611 
612     /**
613      *  This method override permission..
614      * @param form
615      * @param result
616      * @param request
617      * @param response
618      * @return  ModelAndView
619      */
620     @RequestMapping(params = "methodToCall=overRide")
621     public ModelAndView overRide(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
622                                  HttpServletRequest request, HttpServletResponse response) {
623         LOG.debug("Inside the override method");
624         OleLoanForm oleLoanForm = (OleLoanForm) form;
625         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
626         LOG.info("session timeout"+maxSessionTime);
627         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
628             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
629         oleLoanForm.setInformation("");
630         oleLoanForm.setReturnInformation("");
631         oleLoanForm.setOverideMethodCall(oleLoanForm.getMethodToCall());
632         oleLoanForm.setOverrideFlag(true);
633         String principalId= GlobalVariables.getUserSession().getPrincipalId();
634         if(!"".equals(oleLoanForm.getNewPrincipalId()))
635             principalId=oleLoanForm.getNewPrincipalId();
636 
637         Boolean overRideFlag=getLoanProcessor().checkOverRidePermission(principalId);
638 
639         if(overRideFlag) {
640             if(!"".equals(oleLoanForm.getNewPrincipalId()) && oleLoanForm.getNewPrincipalId()!=null)
641                GlobalVariables.getUserSession().setBackdoorUser( oleLoanForm.getNewPrincipalId() );
642             oleLoanForm.setOverrideFlag(false);
643             oleLoanForm.setOverideMethodCall("");
644 
645             return null;
646         }
647         // GlobalVariables.getUserSession().clearBackdoorUser();
648         if(!"".equals(oleLoanForm.getNewPrincipalId()))
649             oleLoanForm.setOverrideLoginMessage(OLEConstants.OVERRIDE_LOGIN_ERR_INFO);
650         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
651     }
652 
653 
654     /**
655      *  This method no  override permission..
656      * @param form
657      * @param result
658      * @param request
659      * @param response
660      * @return  ModelAndView
661      */
662     @RequestMapping(params = "methodToCall=noOverRide")
663     public ModelAndView noOverRide(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
664                                    HttpServletRequest request, HttpServletResponse response) {
665         LOG.debug("Inside the no override method");
666         OleLoanForm oleLoanForm = (OleLoanForm) form;
667         String maxSessionTime = LoanUtil.getLoanUtil().getProperty("LOAN_SESSION_INACTIVE_TIME");
668         LOG.info("session timeout"+maxSessionTime);
669         if(maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
670             oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
671         oleLoanForm.setOverrideFlag(false);
672         oleLoanForm.setOverideMethodCall("");
673         oleLoanForm.setOverrideLoginMessage("");
674         oleLoanForm.setInformation("");
675         oleLoanForm.setReturnInformation("");
676         oleLoanForm.setNewPrincipalId(null);
677         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
678     }
679 
680     /**
681      *  This method renewal the existing item
682      * @param form
683      * @param result
684      * @param request
685      * @param response
686      * @return  ModelAndView
687      */
688     @RequestMapping(params = "methodToCall=renewalItem")
689     public ModelAndView renewalItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
690                                     HttpServletRequest request, HttpServletResponse response) {
691         LOG.debug("Inside the renewal item method");
692         OleLoanForm oleLoanForm = (OleLoanForm) form;
693         oleLoanForm.setInformation("");
694         /*ModelAndView overrideModelView=this.overRide(form,result,request,response);
695         if(overrideModelView==null){*/
696         List<OleLoanDocument> existingItemList = new ArrayList<OleLoanDocument>();
697         existingItemList.addAll(oleLoanForm.getExistingLoanList());
698         if(oleLoanForm.getLoanList()!=null && !oleLoanForm.getLoanList().isEmpty())
699             existingItemList.addAll(oleLoanForm.getLoanList());
700         OleLoanDocument oleLoanDocument=null;
701         for(int i=0;i<existingItemList.size();i++)
702         {
703             OleLoanDocument loanDocument= existingItemList.get(i);
704             if(loanDocument.getItemId().equals(oleLoanForm.getItem())) {
705                 oleLoanDocument=loanDocument;
706                 oleLoanDocument.setRenewalItemFlag(true);
707                 break;
708             }
709         }
710         if(!getLoanProcessor().checkPendingRequestforItem(oleLoanDocument.getItemId())){
711                try{
712                     oleLoanDocument.setPatronId(oleLoanForm.getPatronId());
713                     oleLoanDocument.setBorrowerTypeId(oleLoanForm.getBorrowerTypeId());
714                     oleLoanDocument.setBorrowerTypeName(oleLoanForm.getBorrowerType());
715                     oleLoanDocument.setCirculationLocationId(oleLoanForm.getCirculationDesk());
716                     oleLoanDocument = getLoanProcessor().addLoan(oleLoanDocument.getPatronBarcode(),oleLoanDocument.getItemId(),oleLoanDocument);
717                     if(oleLoanDocument.getErrorMessage() == null){
718                         oleLoanForm.setRenewalFlag(false);
719                         oleLoanForm.setSuccess(true);
720                         oleLoanForm.setMessage("");
721                         oleLoanForm.setInformation(OLEConstants.RENEWAL_ITM_SUCCESS_INFO);
722                     }else
723                     {
724                         String errMsg=oleLoanDocument.getErrorMessage().substring(0,oleLoanDocument.getErrorMessage().lastIndexOf("(OR)"));
725                         oleLoanForm.setMessage("1. "+errMsg);
726                     }
727 
728                 }
729                 catch(Exception e)   {
730                     oleLoanForm.setInformation(e.getMessage());
731                 }
732         }
733         else
734             oleLoanForm.setMessage(oleLoanDocument.getItemId() +OLEConstants.PENDING_RQST_RENEWAL_ITM_INFO);
735         //}
736         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
737     }
738 
739     /**
740      *  This method not renewal the existing item
741      * @param form
742      * @param result
743      * @param request
744      * @param response
745      * @return  ModelAndView
746      */
747     @RequestMapping(params = "methodToCall=doNotRenewalItem")
748     public ModelAndView doNotRenewalItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
749                                          HttpServletRequest request, HttpServletResponse response) {
750         LOG.debug("Inside the do not renewal item method");
751         OleLoanForm oleLoanForm = (OleLoanForm) form;
752         oleLoanForm.setInformation("");
753         oleLoanForm.setReturnInformation("");
754         oleLoanForm.setRenewalFlag(false);
755         oleLoanForm.setSuccess(true);
756         oleLoanForm.setMessage("");
757         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
758     }
759 
760     /**
761      *  This method renewal the list of existing items
762      * @param form
763      * @param result
764      * @param request
765      * @param response
766      * @return  ModelAndView
767      */
768     @RequestMapping(params = "methodToCall=renewalItems")
769     public ModelAndView renewalItems(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
770                                      HttpServletRequest request, HttpServletResponse response) {
771         LOG.debug("Inside the renewal items method");
772         OleLoanForm oleLoanForm = (OleLoanForm) form;
773         oleLoanForm.setInformation("");
774         /* ModelAndView overrideModelView=this.overRide(form,result,request,response);
775         if(overrideModelView==null){*/
776         List<OleLoanDocument> existingItemList = new ArrayList<OleLoanDocument>();
777         existingItemList.addAll(oleLoanForm.getExistingLoanList());
778         boolean currentRenewalFlag=true;
779         for(int i=0;i<oleLoanForm.getLoanList().size();i++){
780             OleLoanDocument loanDocument= oleLoanForm.getLoanList().get(i);
781             if(loanDocument.isCheckNo())    {
782                 oleLoanForm.setInformation(OLEConstants.RENEWAL_ITM_ERR_INFO);
783                 currentRenewalFlag=false;
784                 break;
785             }
786         }
787         if(currentRenewalFlag)   {
788 
789             for(int i=0;i<existingItemList.size();i++)
790             {
791                 OleLoanDocument loanDocument= existingItemList.get(i);
792                 if(loanDocument.isCheckNo()){
793                     currentRenewalFlag=false;
794                     if(!getLoanProcessor().checkPendingRequestforItem(loanDocument.getItemId())){
795 
796                             try{
797                                 loanDocument.setPatronId(oleLoanForm.getPatronId());
798                                 loanDocument.setBorrowerTypeId(oleLoanForm.getBorrowerTypeId());
799                                 loanDocument.setBorrowerTypeName(oleLoanForm.getBorrowerType());
800                                 loanDocument.setRenewalItemFlag(true);
801                                 loanDocument = getLoanProcessor().addLoan(loanDocument.getPatronBarcode(),loanDocument.getItemId(),loanDocument);
802                                 if(loanDocument.getErrorMessage() == null){
803                                     //oleLoanForm.setRenewalFlag(false);
804                                     // oleLoanForm.setSuccess(true);
805                                     // oleLoanForm.setMessage("");
806                                     oleLoanForm.setInformation(oleLoanForm.getInformation()==null?"":oleLoanForm.getInformation()+"\n"+(i+1)+". "+OLEConstants.RENEWAL_ITM_SUCCESS_INFO+"  ("+loanDocument.getItemId()+")<br/>");
807                                 }else
808                                 {
809                                     String errMsg=loanDocument.getErrorMessage().substring(0,loanDocument.getErrorMessage().lastIndexOf("(OR)"));
810                                     oleLoanForm.setInformation(oleLoanForm.getInformation()==null?"":oleLoanForm.getInformation()+"\n"+(i+1)+". "+errMsg+"  ("+loanDocument.getItemId()+")<br/>");
811                                 }
812                             }
813                             catch(Exception e)   {
814                                 LOG.error("exception ------"+e);
815                             }
816                     }
817                     else
818                         oleLoanForm.setInformation(oleLoanForm.getInformation()==null?"":oleLoanForm.getInformation()+"\n"+(i+1)+". "+OLEConstants.PENDING_RQST_RENEWAL_ITM_INFO+"  ("+loanDocument.getItemId()+")<br/>");
819                 }
820             }
821         }
822         if(currentRenewalFlag)
823             oleLoanForm.setInformation(OLEConstants.RENEWAL_ITM_ERR_INFO);
824         //}
825         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
826     }
827 
828 
829 
830     /**
831      * This method initiate LoanProcessor.
832      * @return LoanProcessor
833      */
834     private LoanProcessor getLoanProcessor() {
835         return new LoanProcessor();
836     }
837     /**
838      * This method creates new loan for a patron..
839      * @param form
840      * @param result
841      * @param request
842      * @param response
843      * @return ModelAndView
844      */
845     @RequestMapping(params = "methodToCall=validateItem")
846     public ModelAndView validateItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
847                                      HttpServletRequest request, HttpServletResponse response) {
848         if(LOG.isDebugEnabled()){
849             LOG.info(" Inside Validate Item ");
850         }
851         LoanProcessor loanProcessor = getLoanProcessor();
852         OleLoanForm oleLoanForm = (OleLoanForm)form;
853         oleLoanForm.setOleFormKey(oleLoanForm.getFormKey());
854         oleLoanForm.setReturnInformation("");
855         OleLoanDocument oleLoanDocument = loanProcessor.getOleLoanDocumentUsingItemBarcode(oleLoanForm.getCheckInItem());
856         if(oleLoanDocument==null){
857             oleLoanDocument = new OleLoanDocument();
858         }
859         try{
860             if(oleLoanForm.getCirculationDesk() ==null){
861                 LOG.error(OLEConstants.CIR_LOC_NULL);
862                 throw new Exception(OLEConstants.CIR_LOC_NULL);
863             }
864             if(oleLoanDocument.isClaimsReturnedIndicator()){
865                oleLoanForm.setDummyLoan(oleLoanDocument);
866                oleLoanForm.setClaimsReturned(true);
867                oleLoanForm.setReturnSuccess(false);
868                oleLoanForm.setReturnMessage(LoanUtil.getLoanUtil().getProperty("CLAIMS_RETURNED_MESSAGE"));
869                return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
870             }
871             oleLoanDocument.setCheckInDate(oleLoanForm.getCheckInDate());
872             oleLoanDocument.setCirculationLocationId(oleLoanForm.getCirculationDesk());
873             oleLoanDocument.setDamagedCheckInOption(oleLoanForm.isDamagedCheckInOption());
874             LOG.info("Check-in Item Barcode Number --->"+oleLoanForm.getCheckInItem());
875             oleLoanDocument = loanProcessor.returnLoan(oleLoanForm.getCheckInItem(),oleLoanDocument);
876             String checkInNote = oleLoanDocument.getOleItem().getCheckinNote();
877             if( !oleLoanForm.isCheckInNoteExists() && checkInNote!=null && !checkInNote.isEmpty()){
878                 oleLoanForm.setDummyLoan(oleLoanDocument);
879                 oleLoanForm.setCheckInNoteExists(true);
880                 oleLoanForm.setReturnSuccess(false);
881                 oleLoanForm.setReturnMessage(checkInNote);
882                 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
883             }
884             oleLoanForm.setDummyLoan(oleLoanDocument);
885             if(oleLoanDocument.isCopyRequest()){
886                 oleLoanForm.setCopyRequest(true);
887                 oleLoanForm.setReturnSuccess(false);
888                 oleLoanForm.setReturnMessage(OLEConstants.COPY_REQUEST_FULFILL);
889                 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
890             }
891             if(oleLoanDocument.isNumberOfPieces()){
892                 oleLoanForm.setNumberOfPieces(true);
893                 oleLoanForm.setReturnSuccess(false);
894                 oleLoanForm.setReturnMessage(OLEConstants.VERIFY_PIECES+oleLoanDocument.getItemNumberOfPieces()+OLEConstants.PIECES_RETURNED);
895                 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
896             }
897         }catch(Exception e){
898             LOG.error("Error in validate Item "+e);
899             oleLoanForm.setReturnInformation(e.getMessage());
900             return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
901         }
902         if(oleLoanDocument.getErrorMessage()!=null){
903             if(oleLoanDocument.isCheckOut()){
904                 oleLoanForm.setSuccess(false);
905                 oleLoanForm.setMessage(oleLoanDocument.getErrorMessage());
906             } else{
907                 oleLoanForm.setReturnSuccess(false);
908                 oleLoanForm.setReturnMessage(oleLoanDocument.getErrorMessage());
909             }
910         } else{
911             List<OleLoanDocument> oleLoanDocuments  = new ArrayList<OleLoanDocument>();
912             oleLoanDocuments.add(oleLoanDocument);
913             if(oleLoanForm.getItemReturnList()!=null){
914                 oleLoanDocuments.addAll(oleLoanForm.getItemReturnList());
915             }
916             oleLoanForm.setItemReturnList(oleLoanDocuments);
917             oleLoanForm.setCheckInItem("");
918         }
919        if(oleLoanDocument.getOlePatron()!=null){
920            oleLoanForm.setBillAvailability(true);
921        }
922         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
923     }
924     /**
925      * This method  returns Item for a patron who is not able to return.
926      * @param form
927      * @param result
928      * @param request
929      * @param response
930      * @return  ModelAndView
931      */
932     @RequestMapping(params = "methodToCall=returnItem")
933     public ModelAndView returnItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
934                                    HttpServletRequest request, HttpServletResponse response) {
935         if(LOG.isDebugEnabled()){
936             LOG.info(" Inside Return Item ");
937         }
938         OleLoanForm oleLoanForm = (OleLoanForm)form;
939         OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
940         try {
941             oleLoanDocument = getLoanProcessor().returnLoan(oleLoanDocument);
942             if(oleLoanDocument.isNumberOfPieces()){
943                 oleLoanForm.setNumberOfPieces(true);
944                 oleLoanForm.setReturnSuccess(false);
945                 oleLoanForm.setReturnMessage(OLEConstants.VERIFY_PIECES+oleLoanDocument.getItemNumberOfPieces()+OLEConstants.PIECES_RETURNED);
946                 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
947             }
948             List<OleLoanDocument> oleLoanDocuments  = new ArrayList<OleLoanDocument>();
949             oleLoanDocuments.add(oleLoanDocument);
950             if(oleLoanForm.getItemReturnList()!=null){
951                 oleLoanDocuments.addAll(oleLoanForm.getItemReturnList());
952             }
953             oleLoanForm.setItemReturnList(oleLoanDocuments);
954         } catch (Exception e) {
955             LOG.error("Error in return Item "+e);
956             e.printStackTrace();
957         }
958         oleLoanForm.setReturnSuccess(true);
959         oleLoanForm.setReturnMessage(null);
960         oleLoanForm.setCheckInItem("");
961         oleLoanForm.setReturnInformation("");
962         if(oleLoanDocument.getOlePatron()!=null){
963            oleLoanForm.setBillAvailability(true);
964         }
965         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
966     }
967     /**
968      * This method  doesn't allow to return an item.
969      * @param form
970      * @param result
971      * @param request
972      * @param response
973      * @return  ModelAndView
974      */
975     @RequestMapping(params = "methodToCall=noReturnItem")
976     public ModelAndView doNotReturnItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
977                                         HttpServletRequest request, HttpServletResponse response) {
978         if(LOG.isDebugEnabled()){
979             LOG.info(" Inside Do Not Return Item ");
980         }
981         OleLoanForm oleLoanForm = (OleLoanForm)form;
982         oleLoanForm.setReturnInformation("");
983         oleLoanForm.setCheckInItem("");
984         oleLoanForm.setReturnMessage(null);
985         oleLoanForm.setReturnSuccess(true);
986        if(oleLoanForm.getDummyLoan()!=null && oleLoanForm.getDummyLoan().getOlePatron()!=null){
987            oleLoanForm.setBillAvailability(true);
988        }
989         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
990     }
991 
992     /**
993      * This method  allows to continue Check-in.
994      * @param form
995      * @param result
996      * @param request
997      * @param response
998      * @return  ModelAndView
999      */
1000     @RequestMapping(params = "methodToCall=continueCheckIn")
1001     public ModelAndView continueCheckIn(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1002                                         HttpServletRequest request, HttpServletResponse response) {
1003         if(LOG.isDebugEnabled()){
1004             LOG.info(" Inside Continue Check-in ");
1005         }
1006         OleLoanForm oleLoanForm = (OleLoanForm)form;
1007         String description = oleLoanForm.getDescription();
1008         String matchCheck = oleLoanForm.getMatchCheck();
1009         String copyCheck = oleLoanForm.getCopyCheck();
1010         OleLoanDocument oleLoanDocument = new OleLoanDocument();
1011         oleLoanDocument  = oleLoanForm.getDummyLoan();
1012         LoanProcessor loanProcessor = getLoanProcessor();
1013         try {
1014             if(copyCheck.equalsIgnoreCase("true")){
1015                 oleLoanForm.setCopyCheck("");
1016                 loanProcessor.deleteRequestRecord(oleLoanDocument.getOleDeliverRequestBo());
1017                 oleLoanDocument = loanProcessor.returnLoan(oleLoanDocument);
1018             }else if(copyCheck.equalsIgnoreCase("false")){
1019                 return endCheckInSession(form,result,request,response);
1020             }
1021             if(oleLoanForm.isCheckInNoteExists() && (oleLoanDocument.isCopyRequest() || oleLoanDocument.isNumberOfPieces())){
1022                 oleLoanForm.setCheckInNoteExists(false);
1023                 oleLoanForm.setCopyRequest(oleLoanDocument.isCopyRequest());
1024                 oleLoanForm.setNumberOfPieces(oleLoanDocument.isNumberOfPieces());
1025                 oleLoanForm.setReturnSuccess(false);
1026                 oleLoanForm.setReturnMessage(OLEConstants.COPY_REQUEST_FULFILL);
1027                 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1028             }
1029             if(oleLoanForm.isCopyRequest()  && oleLoanDocument.isNumberOfPieces()){
1030                 oleLoanForm.setCopyRequest(false);
1031                 oleLoanForm.setNumberOfPieces(true);
1032                 oleLoanForm.setReturnSuccess(false);
1033                 oleLoanForm.setReturnMessage(OLEConstants.VERIFY_PIECES+oleLoanDocument.getItemNumberOfPieces()+OLEConstants.PIECES_RETURNED);
1034                 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1035             }
1036             if(oleLoanDocument.isClaimsReturnedIndicator()){
1037                 oleLoanForm.setClaimsReturned(false);
1038                 oleLoanForm.setReturnSuccess(true);
1039                 oleLoanForm.setReturnMessage(null);
1040                 loanProcessor.updateClaimsReturnedInLoanDocument(oleLoanDocument,false);
1041                 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1042             }
1043             if(matchCheck.equalsIgnoreCase("true")){
1044                 oleLoanDocument.setContinueCheckIn(true);
1045                 oleLoanDocument = loanProcessor.returnLoan(oleLoanDocument);
1046             }else {
1047                 loanProcessor.updateItemStatusWithMissingItem(oleLoanDocument);
1048             }
1049             List<OleLoanDocument> oleLoanDocuments  = new ArrayList<OleLoanDocument>();
1050             oleLoanDocuments.add(oleLoanDocument);
1051             if(oleLoanForm.getItemReturnList()!=null){
1052                 oleLoanDocuments.addAll(oleLoanForm.getItemReturnList());
1053             }
1054             oleLoanForm.setItemReturnList(oleLoanDocuments);
1055         } catch (Exception e) {
1056             LOG.error("Error in Continue Check-in "+e);
1057             e.printStackTrace();
1058         }
1059         oleLoanForm.setNumberOfPieces(false);
1060         oleLoanForm.setReturnSuccess(true);
1061         oleLoanForm.setReturnMessage(null);
1062         oleLoanForm.setCheckInItem("");
1063         oleLoanForm.setReturnInformation("");
1064         if(oleLoanDocument.getOlePatron()!=null){
1065             oleLoanForm.setBillAvailability(true);
1066         }
1067         LOG.info("oleLoanForm.getFormKey()"+oleLoanForm.getFormKey());
1068         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1069     }
1070 
1071     /**
1072      * This method  ends Check-in session
1073      * @param form
1074      * @param result
1075      * @param request
1076      * @param response
1077      * @return  ModelAndView
1078      */
1079     @RequestMapping(params = "methodToCall=endCheckInSession")
1080     public ModelAndView endCheckInSession(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1081                                         HttpServletRequest request, HttpServletResponse response) {
1082         if(LOG.isDebugEnabled()){
1083             LOG.info(" Inside End Check-in session ");
1084         }
1085         OleLoanForm oleLoanForm = (OleLoanForm)form;
1086         oleLoanForm.setCopyRequest(false);
1087         oleLoanForm.setNumberOfPieces(false);
1088         oleLoanForm.setReturnInformation("");
1089         oleLoanForm.setCheckInItem("");
1090         oleLoanForm.setReturnMessage(null);
1091         oleLoanForm.setReturnSuccess(true);
1092         oleLoanForm.setItemReturnList(null);
1093         return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1094     }
1095 
1096     /**
1097      * This method will allow  library operator to print slips for user
1098      * @param form
1099      * @param result
1100      * @param request
1101      * @param response
1102      * @return  ModelAndView
1103      */
1104     @RequestMapping(params = "methodToCall=printBill")
1105     public ModelAndView printBill(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1106                                   HttpServletRequest request, HttpServletResponse response) {
1107         OlePrintSlip olePrintSlip = new OlePrintSlip();
1108         if(LOG.isDebugEnabled()){
1109             LOG.info(" Inside Print Bill ");
1110         }
1111         String formKey =request.getParameter("formKey");
1112         OleLoanForm oleLoanForm =(OleLoanForm) GlobalVariables.getUifFormManager().getForm(formKey);
1113         OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
1114         oleLoanDocument.setMatchCheck(oleLoanForm.getMatchCheck());
1115         olePrintSlip.createPdfForPrintingSlip(oleLoanDocument,response);
1116         return null;
1117     }
1118 
1119     /**
1120      * This method will allow library operator to print due date slips for user.
1121      * @param form
1122      * @param result
1123      * @param request
1124      * @param response
1125      * @return
1126      */
1127     @RequestMapping(params = "methodToCall=printLoanBill")
1128     public ModelAndView printLoanBill(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1129                                       HttpServletRequest request, HttpServletResponse response) {
1130         OlePrintSlip olePrintSlip = new OlePrintSlip();
1131         if(LOG.isDebugEnabled()){
1132             LOG.info(" Inside Print Loan Bill ");
1133         }
1134         String formKey =request.getParameter("formKey");
1135         OleLoanForm oleLoanForm =(OleLoanForm) GlobalVariables.getUifFormManager().getForm(formKey);
1136         // OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
1137         List<OleLoanDocument> oleLoanDocumentList = new ArrayList<OleLoanDocument>();
1138         if(LoanUtil.getLoanUtil().getProperty("PRINT_DUE_DATE_PER_TRANSACTION").equalsIgnoreCase("No")){
1139             oleLoanDocumentList = printDueDateSlipList;
1140         }else{
1141             if(oleLoanForm.getLoanList() != null && (oleLoanForm.getLoanList().size() > 0)){
1142                 oleLoanDocumentList.add(oleLoanForm.getLoanList().get(0));
1143             }
1144         }
1145         if(oleLoanDocumentList!=null && oleLoanDocumentList.size()>0){
1146             olePrintSlip.createDueDateSlipPdf(oleLoanDocumentList,response);
1147         }
1148         return null;
1149     }
1150 
1151 
1152     /**
1153      * This method will allow library operator to even if the check-in note exists
1154      * @param form
1155      * @param result
1156      * @param request
1157      * @param response
1158      * @return  ModelAndView
1159      */
1160     @RequestMapping(params = "methodToCall=checkInNote")
1161     public ModelAndView checkInNote(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1162                                   HttpServletRequest request, HttpServletResponse response) {
1163         if(LOG.isDebugEnabled()){
1164             LOG.info("Check in Note Exists ");
1165         }
1166         OleLoanForm oleLoanForm = (OleLoanForm)form  ;
1167         oleLoanForm.setReturnSuccess(true);
1168         oleLoanForm.setReturnMessage(null);
1169         return continueCheckIn(oleLoanForm,result,request,response);
1170     }
1171 
1172 }