1 package org.kuali.ole.deliver.controller;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.apache.log4j.Logger;
5 import org.kuali.ole.LoanUtil;
6 import org.kuali.ole.OLEConstants;
7 import org.kuali.ole.OLEParameterConstants;
8 import org.kuali.ole.deliver.batch.OleDeliverBatchServiceImpl;
9 import org.kuali.ole.deliver.batch.OleMailer;
10 import org.kuali.ole.deliver.batch.OleNoticeBo;
11 import org.kuali.ole.deliver.bo.*;
12 import org.kuali.ole.deliver.form.OleLoanForm;
13 import org.kuali.ole.deliver.printSlip.OlePrintSlip;
14 import org.kuali.ole.deliver.processor.LoanProcessor;
15 import org.kuali.ole.describe.bo.OleItemAvailableStatus;
16 import org.kuali.ole.describe.bo.OleLocation;
17 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
18 import org.kuali.ole.docstore.common.document.ItemOleml;
19 import org.kuali.ole.docstore.common.document.content.enums.DocType;
20 import org.kuali.ole.docstore.common.document.content.instance.Item;
21 import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.rice.core.api.config.property.ConfigContext;
24 import org.kuali.rice.core.api.mail.EmailBody;
25 import org.kuali.rice.core.api.mail.EmailFrom;
26 import org.kuali.rice.core.api.mail.EmailSubject;
27 import org.kuali.rice.core.api.mail.EmailTo;
28 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
29 import org.kuali.rice.kim.api.permission.PermissionService;
30 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
31 import org.kuali.rice.krad.uif.UifConstants;
32 import org.kuali.rice.krad.uif.UifParameters;
33 import org.kuali.rice.krad.util.GlobalVariables;
34 import org.kuali.rice.krad.util.ObjectUtils;
35 import org.kuali.rice.krad.web.controller.UifControllerBase;
36 import org.kuali.rice.krad.web.form.UifFormBase;
37 import org.springframework.stereotype.Controller;
38 import org.springframework.validation.BindingResult;
39 import org.springframework.web.bind.annotation.ModelAttribute;
40 import org.springframework.web.bind.annotation.RequestMapping;
41 import org.springframework.web.servlet.ModelAndView;
42
43 import javax.servlet.http.HttpServletRequest;
44 import javax.servlet.http.HttpServletResponse;
45 import java.io.IOException;
46 import java.sql.Timestamp;
47 import java.text.DateFormat;
48 import java.text.SimpleDateFormat;
49 import java.util.*;
50 import java.util.regex.Matcher;
51 import java.util.regex.Pattern;
52
53
54
55
56
57 @Controller
58 @RequestMapping(value = "/loancontroller")
59 public class LoanController extends UifControllerBase {
60
61 private static final Logger LOG = Logger.getLogger(LoanController.class);
62
63 private List<OleLoanDocument> printDueDateSlipList = new ArrayList<OleLoanDocument>();
64
65 private List<OleLoanDocument> printHoldSlipList = new ArrayList<OleLoanDocument>();
66
67 private LoanProcessor loanProcessor;
68
69 private OleDeliverBatchServiceImpl oleDeliverBatchService;
70
71 public static String fastAddBarcode = "";
72
73 private List<String> loginUserList;
74 private DocstoreClientLocator docstoreClientLocator;
75
76 public DocstoreClientLocator getDocstoreClientLocator() {
77
78 if (docstoreClientLocator == null) {
79 docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
80
81 }
82 return docstoreClientLocator;
83 }
84
85 public OleDeliverBatchServiceImpl getOleDeliverBatchService() {
86 if (oleDeliverBatchService == null) {
87 oleDeliverBatchService = SpringContext.getBean(OleDeliverBatchServiceImpl.class);
88 }
89 return oleDeliverBatchService;
90 }
91
92 public void setLoanProcessor(LoanProcessor loanProcessor) {
93 this.loanProcessor = loanProcessor;
94 }
95
96 public void setOleDeliverBatchService(OleDeliverBatchServiceImpl oleDeliverBatchService) {
97 this.oleDeliverBatchService = oleDeliverBatchService;
98 }
99
100 public void setDocstoreClientLocator(DocstoreClientLocator docstoreClientLocator) {
101 this.docstoreClientLocator = docstoreClientLocator;
102 }
103
104
105
106
107
108
109
110 @Override
111 protected OleLoanForm createInitialForm(HttpServletRequest request) {
112 return new OleLoanForm();
113 }
114
115
116
117
118
119
120
121
122
123
124 @Override
125 @RequestMapping(params = "methodToCall=start")
126 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
127 HttpServletRequest request, HttpServletResponse response) {
128 LOG.debug("Inside the loan start method");
129 fastAddBarcode = "";
130 OleLoanForm oleLoanForm = null;
131 if (form.getViewId().equalsIgnoreCase("PatronItemView")) {
132 String formKey = request.getParameter("formKey");
133 if (formKey == null) {
134 if (loginUserList != null) {
135 loginUserList.clear();
136 }
137 oleLoanForm = (OleLoanForm) form;
138 oleLoanForm.setReturnCheck(false);
139 if (oleLoanForm.getOldPrincipalId() == null || "".equals(oleLoanForm.getOldPrincipalId()))
140 oleLoanForm.setOldPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
141 Integer maxTimeForCheckInDate = 0;
142 String parameter = getLoanProcessor().getParameter(OLEConstants.MAX_TIME_CHECK_IN);
143 if (LOG.isInfoEnabled()) {
144 LOG.info("session timeout parameter:" + parameter);
145 }
146 String loanParameter = getLoanProcessor().getParameter(OLEConstants.MAX_TIME_LOAN);
147 String audioOption = getLoanProcessor().getParameter(OLEConstants.AUDIO_OPTION);
148 String maxSessionTime = loanParameter;
149 if (LOG.isInfoEnabled()) {
150 LOG.info("session timeout:" + maxSessionTime);
151 }
152 if (maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
153 oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
154
155 if (!getLoanProcessor().isValidCirculationDesk()) {
156 oleLoanForm.setLoanLoginUserInfo(GlobalVariables.getUserSession().getPrincipalName() + " " + OLEConstants.OleCirculationDesk.OLE_CIRCULATION_DESK_VALIDATIONS);
157 return super.start(oleLoanForm, result, request, response);
158 }
159
160 oleLoanForm.setCirculationDesk(getLoanProcessor().getCircDeskId());
161 oleLoanForm.setAudioForPastDate(audioOption != null && !audioOption.isEmpty() && audioOption.equalsIgnoreCase(OLEConstants.TRUE));
162 if (parameter != null) {
163 maxTimeForCheckInDate = Integer.parseInt(parameter);
164 }
165 oleLoanForm.setMaxTimeForCheckOutConstant(loanParameter);
166 LOG.info("session timeout maxTimeForCheckInDate:" + maxTimeForCheckInDate);
167 oleLoanForm.setMaxTimeForCheckInDate(maxTimeForCheckInDate);
168 oleLoanForm.setCheckInDateMaxTime(maxTimeForCheckInDate);
169 oleLoanForm.setDateAlertMessage(OLEConstants.CHECK_IN_DATE);
170 oleLoanForm.setCurrentDate(new Date());
171 oleLoanForm.setPatronFocus(true);
172 if (oleLoanForm.getCheckInDate() == null) {
173 oleLoanForm.setCheckInDate(new Date());
174 }
175 } else {
176 oleLoanForm = (OleLoanForm) GlobalVariables.getUifFormManager().getSessionForm(formKey);
177 if (oleLoanForm.getOldPrincipalId() == null || "".equals(oleLoanForm.getOldPrincipalId()))
178 oleLoanForm.setOldPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
179 oleLoanForm.setReturnCheck(false);
180 oleLoanForm.setAjaxRequest(false);
181 oleLoanForm.setAjaxReturnType("update-view");
182 oleLoanForm = (OleLoanForm) form;
183 oleLoanForm.setPageId(null);
184 Integer maxTimeForCheckInDate = 0;
185 String parameter = getLoanProcessor().getParameter(OLEConstants.MAX_TIME_CHECK_IN);
186 LOG.info("session timeout parameter:" + parameter);
187 String loanParameter = getLoanProcessor().getParameter(OLEConstants.MAX_TIME_LOAN);
188 String audioOption = getLoanProcessor().getParameter(OLEConstants.AUDIO_OPTION);
189
190 String maxSessionTime = loanParameter;
191 if (LOG.isInfoEnabled()) {
192 LOG.info("session timeout:" + maxSessionTime);
193 }
194 if (maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
195 oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
196
197 oleLoanForm.setRemoveMissingPieceFlag(false);
198 oleLoanForm.setRecordDamagedItemNote(false);
199 oleLoanForm.setRecordMissingPieceNote(false);
200 oleLoanForm.setRecordCheckoutMissingPieceNote(false);
201 oleLoanForm.setDisplayRecordNotePopup(false);
202 oleLoanForm.setCheckoutRecordFlag(false);
203 oleLoanForm.setSkipMissingPieceRecordPopup(false);
204 oleLoanForm.setSkipDamagedRecordPopup(false);
205 oleLoanForm.setDisplayMissingPieceNotePopup(false);
206 oleLoanForm.setCheckoutMissingPieceRecordFlag(false);
207 oleLoanForm.setDisplayDamagedRecordNotePopup(false);
208 oleLoanForm.setCheckoutDamagedRecordFlag(false);
209
210
211
212
213
214
215
216
217
218
219 if (!getLoanProcessor().isValidCirculationDesk()) {
220 oleLoanForm.setLoanLoginUserInfo(GlobalVariables.getUserSession().getPrincipalName() + " " + OLEConstants.OleCirculationDesk.OLE_CIRCULATION_DESK_VALIDATIONS);
221 return super.start(oleLoanForm, result, request, response);
222 }
223 oleLoanForm.setAudioForPastDate(audioOption != null && !audioOption.isEmpty() && audioOption.equalsIgnoreCase(OLEConstants.TRUE));
224 if (parameter != null) {
225 maxTimeForCheckInDate = Integer.parseInt(parameter);
226 }
227 oleLoanForm.setMaxTimeForCheckOutConstant(loanParameter);
228 LOG.info("session timeout maxTimeForCheckInDate:" + maxTimeForCheckInDate);
229 oleLoanForm.setMaxTimeForCheckInDate(maxTimeForCheckInDate);
230 oleLoanForm.setCheckInDateMaxTime(maxTimeForCheckInDate);
231 oleLoanForm.setDateAlertMessage(OLEConstants.CHECK_IN_DATE);
232 oleLoanForm.setCurrentDate(new Date());
233 oleLoanForm.setPatronFocus(true);
234 if (oleLoanForm.getCheckInDate() == null) {
235 oleLoanForm.setCheckInDate(new Date());
236 }
237 }
238
239
240 } else {
241 oleLoanForm = (OleLoanForm) form;
242
243 String formKey = request.getParameter("formKey");
244 if (formKey == null) {
245 oleLoanForm.setCirculationDesk(getLoanProcessor().getCircDesk());
246 }
247 if (oleLoanForm.getOldPrincipalId() == null || "".equals(oleLoanForm.getOldPrincipalId()))
248 oleLoanForm.setOldPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
249 oleLoanForm.setPageId(null);
250 oleLoanForm.setReturnCheck(true);
251 Integer maxTimeForCheckInDate = 0;
252 String parameter = getLoanProcessor().getParameter(OLEConstants.MAX_TIME_CHECK_IN);
253 LOG.info("session timeout parameter:" + parameter);
254 String loanParameter = getLoanProcessor().getParameter(OLEConstants.MAX_TIME_LOAN);
255 String audioOption = getLoanProcessor().getParameter(OLEConstants.AUDIO_OPTION);
256
257 String maxSessionTime = loanParameter;
258 if (LOG.isInfoEnabled()) {
259 LOG.info("session timeout:" + maxSessionTime);
260 }
261 if (maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
262 oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
263
264
265
266
267
268
269
270
271
272
273 if (!getLoanProcessor().isValidCirculationDesk()) {
274 oleLoanForm.setLoanLoginUserInfo(GlobalVariables.getUserSession().getPrincipalName() + " " + OLEConstants.OleCirculationDesk.OLE_CIRCULATION_DESK_VALIDATIONS);
275 return super.start(oleLoanForm, result, request, response);
276 }
277 oleLoanForm.setAudioForPastDate(audioOption != null && !audioOption.isEmpty() && audioOption.equalsIgnoreCase(OLEConstants.TRUE));
278 if (parameter != null) {
279 maxTimeForCheckInDate = Integer.parseInt(parameter);
280 }
281 oleLoanForm.setMaxTimeForCheckOutConstant(loanParameter);
282 LOG.info("session timeout maxTimeForCheckInDate:" + maxTimeForCheckInDate);
283 oleLoanForm.setMaxTimeForCheckInDate(maxTimeForCheckInDate);
284 oleLoanForm.setCheckInDateMaxTime(maxTimeForCheckInDate);
285 oleLoanForm.setDateAlertMessage(OLEConstants.CHECK_IN_DATE);
286 oleLoanForm.setCurrentDate(new Date());
287 oleLoanForm.setPatronFocus(true);
288 if (oleLoanForm.getCheckInDate() == null) {
289 oleLoanForm.setCheckInDate(new Date());
290 }
291
292
293
294
295
296
297
298
299
300
301 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
302 if (oleLoanDocument != null) {
303 List<OleLoanDocument> documentList = oleLoanForm.getItemReturnList();
304 if (documentList != null && documentList.size() > 0) {
305 OleCirculationDesk oleCirculationDesk = null;
306 OleLocation oleLocation = null;
307 if (oleLoanDocument.getCirculationLocationId() != null) {
308
309 try{
310 oleLocation = loanProcessor.getLocationByLocationCode(oleLoanDocument.getItemLocation());
311 }
312 catch (Exception e){
313 LOG.error("Exception while fetching OleLocation based on item location" +e);
314 }
315 String routeTo = oleLoanForm.getRouteToLocation() != null ? oleLoanForm.getRouteToLocation() :
316 (oleLoanDocument.getRouteToLocation() != null ? oleLoanDocument.getRouteToLocation() :
317 (oleLocation != null ? oleLocation.getLocationCode() : null));
318 documentList.get(0).setRouteToLocation(routeTo);
319 }
320 }
321 }
322 oleLoanForm.setBackGroundCheckIn(false);
323 }
324 return super.start(oleLoanForm, result, request, response);
325 }
326
327
328
329
330
331
332
333
334
335
336
337 @Override
338 @RequestMapping(params = "methodToCall=refresh")
339 public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
340 HttpServletRequest request, HttpServletResponse response) throws Exception {
341 OleLoanForm oleLoanForm = (OleLoanForm) form;
342 if (oleLoanForm.getPatronFirstName() != null) {
343 oleLoanForm.setReturnCheck(false);
344 oleLoanForm.setPatronFirstName(null);
345 super.refresh(oleLoanForm, result, request, response);
346 return searchPatron(oleLoanForm, result, request, response);
347 }
348 if (oleLoanForm.getItemUuid() != null && oleLoanForm.getInstanceUuid() != null) {
349 oleLoanForm.setReturnCheck(false);
350 super.refresh(oleLoanForm, result, request, response);
351 ModelAndView modelAndView = addItem(oleLoanForm, result, request, response);
352 oleLoanForm.setItemUuid(null);
353 oleLoanForm.setInstanceUuid(null);
354 return modelAndView;
355 }
356 if (oleLoanForm.getReturnItemUuid() != null && oleLoanForm.getReturnInstanceUuid() != null) {
357 oleLoanForm.setReturnCheck(true);
358 super.refresh(oleLoanForm, result, request, response);
359 ModelAndView modelAndView = validateItem(oleLoanForm, result, request, response);
360 oleLoanForm.setReturnItemUuid(null);
361 oleLoanForm.setReturnInstanceUuid(null);
362 return modelAndView;
363 }
364 return super.refresh(oleLoanForm, result, request, response);
365 }
366
367
368
369
370
371
372
373
374
375
376 @RequestMapping(params = "methodToCall=searchPatron")
377 public ModelAndView searchPatron(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
378 HttpServletRequest request, HttpServletResponse response) {
379 LOG.debug("Inside the search patron method");
380 fastAddBarcode = "";
381 OleLoanForm oleLoanForm = (OleLoanForm) form;
382 oleLoanForm.setLoanList(new ArrayList<OleLoanDocument>(0));
383 oleLoanForm.setBlockPatron(false);
384 oleLoanForm.setExistingLoanList(new ArrayList<OleLoanDocument>(0));
385 oleLoanForm.setInformation("");
386 oleLoanForm.setSuccessInfo("");
387 oleLoanForm.setReturnInformation("");
388 oleLoanForm.getErrorsAndPermission().clear();
389 oleLoanForm.setPatronbill(false);
390 try {
391 String maxSessionTime = oleLoanForm.getMaxTimeForCheckOutConstant();
392 if (LOG.isInfoEnabled()) {
393 LOG.info("session timeout:" + maxSessionTime);
394 }
395 if (maxSessionTime != null && !maxSessionTime.equalsIgnoreCase(""))
396 oleLoanForm.setMaxSessionTime(Integer.parseInt(maxSessionTime));
397
398
399 if (!getLoanProcessor().isValidCirculationDesk()) {
400 oleLoanForm.setLoanLoginUserInfo(GlobalVariables.getUserSession().getPrincipalName() + " " + OLEConstants.OleCirculationDesk.OLE_CIRCULATION_DESK_VALIDATIONS);
401 return super.start(oleLoanForm, result, request, response);
402 }
403 OleLoanDocument oleProxyLoanDocument = null;
404 List<OlePatronDocument> oleRealPatron = oleLoanForm.getRealPatronList();
405 List<OlePatronDocument> oleCurrentPatronDocumentList = oleLoanForm.getCurrentPatronList();
406 OlePatronDocument oleCurrentPatronDocument = new OlePatronDocument();
407 if (oleCurrentPatronDocumentList != null && oleCurrentPatronDocumentList.size() > 0) {
408 oleCurrentPatronDocument = oleCurrentPatronDocumentList.get(0);
409 String barcode = oleLoanForm.getPatronBarcode();
410 if (oleLoanForm.isProxyDisplay() && barcode != null && !barcode.equalsIgnoreCase("") && oleCurrentPatronDocument.getBarcode() != null && !barcode.equalsIgnoreCase(oleCurrentPatronDocument.getBarcode())) {
411 oleLoanForm.getCurrentPatronList().clear();
412 oleLoanForm.setRealPatronBarcode(null);
413 oleLoanForm.setPatronBarcode(barcode);
414 oleLoanForm.setRealPatronList(null);
415 oleLoanForm.setProxyDisplay(false);
416 oleLoanForm.setBackUpDummyLoan(null);
417 oleRealPatron.clear();
418
419 }
420 }
421 if (oleRealPatron != null && oleRealPatron.size() > 0 && !oleCurrentPatronDocument.isSelfCheckOut()) {
422 for (int realPatron = 0; realPatron < oleRealPatron.size(); realPatron++) {
423 OlePatronDocument olePatronDocument = oleRealPatron.get(realPatron);
424 if (olePatronDocument.isRealPatronCheck()) {
425 oleLoanForm.setRealPatronBarcode(olePatronDocument.getBarcode());
426 oleLoanForm.setRealPatronFlag(false);
427 oleProxyLoanDocument = getLoanProcessor().getLoanDocument(olePatronDocument.getBarcode(), null, oleLoanForm.isSelfCheckOut(), false);
428 break;
429 }
430 }
431 }
432 boolean isSelfCheckout = oleCurrentPatronDocument.isSelfCheckOut();
433 if (oleCurrentPatronDocument.isSelfCheckOut()) {
434 oleLoanForm.setSelfCheckOut(false);
435 oleLoanForm.setRealPatronFlag(false);
436 }
437
438 OleLoanDocument oleLoanDocument = getLoanProcessor().getLoanDocument(oleLoanForm.getPatronBarcode(), oleLoanForm.getRealPatronBarcode(), isSelfCheckout, false);
439 if (oleLoanDocument.isLostPatron()) {
440 oleLoanForm.setBlockUser(true);
441 }else {
442 oleLoanForm.setBlockUser(false);
443 }
444 if (oleLoanDocument.getPatronUserNotes() != null) {
445 oleLoanForm.setPatronNoteFlag(true);
446 oleLoanForm.setPatronUserNote(oleLoanDocument.getPatronUserNotes());
447 oleLoanForm.setPatronNoteTypeId(oleLoanDocument.getPatronNoteTypeId());
448 }
449 boolean activeProxyValue = true;
450 int proxyPatronCount = 0;
451 int proxyDisplayCount = 0;
452 if (oleLoanDocument.getRealPatron() != null && oleLoanDocument.getRealPatron().size() > 0) {
453 List<OlePatronDocument> realPatronActiveListOld = new ArrayList<OlePatronDocument>();
454 for (OlePatronDocument oleRealPatronDocument : oleLoanDocument.getRealPatron()) {
455 if (!realPatronActiveListOld.contains(oleRealPatronDocument)) {
456 realPatronActiveListOld.add(oleRealPatronDocument);
457 }
458 }
459
460 List<OlePatronDocument> realPatronActiveList = new ArrayList<OlePatronDocument>();
461 for (OlePatronDocument oleRealPatronDocument : realPatronActiveListOld) {
462 List<OleProxyPatronDocument> proxyPatronActiveList = new ArrayList<OleProxyPatronDocument>();
463 for (OleProxyPatronDocument oleProxyPatronDocument : oleRealPatronDocument.getOleProxyPatronDocuments()) {
464 if (oleProxyPatronDocument.getProxyPatronId().equalsIgnoreCase(oleLoanDocument.getPatronId())) {
465 proxyPatronCount++;
466 if (oleProxyPatronDocument.getProxyPatronExpirationDate() == null || !oleProxyPatronDocument.getProxyPatronExpirationDate().before(new Timestamp(System.currentTimeMillis()))) {
467 proxyPatronActiveList.add(oleProxyPatronDocument);
468 proxyDisplayCount++;
469 }
470 }
471 }
472 if (proxyPatronActiveList.size() > 0) {
473 oleLoanForm.setProxyDisplay(true);
474 oleRealPatronDocument.setOleProxyPatronDocuments(proxyPatronActiveList);
475 oleRealPatronDocument.setOleProxyPatronDocumentList(proxyPatronActiveList);
476 realPatronActiveList.add(oleRealPatronDocument);
477
478 } else {
479 activeProxyValue = false;
480 }
481 }
482 if (realPatronActiveList.size() > 0) {
483 oleLoanForm.setRealPatronList(realPatronActiveList);
484 List<OlePatronDocument> currentPatronList = new ArrayList<>();
485 currentPatronList.add(oleLoanDocument.getOlePatron());
486 oleLoanForm.setCurrentPatronList(currentPatronList);
487 oleLoanForm.setRealPatronFlag(true);
488
489 }
490 }
491 if (!activeProxyValue && proxyPatronCount != 0 && proxyDisplayCount != proxyPatronCount) {
492 oleLoanDocument = getLoanProcessor().getLoanDocument(oleLoanForm.getPatronBarcode(), oleLoanForm.getRealPatronBarcode(), false, true);
493 }
494 oleLoanForm.setBorrowerCode(oleLoanDocument.getBorrowerTypeCode());
495 oleLoanForm.setPatronId(oleLoanDocument.getPatronId());
496 String patronNameURL = getLoanProcessor().patronNameURL(oleLoanForm.getOldPrincipalId(), oleLoanForm.getPatronId());
497 oleLoanForm.setPatronNameURL(patronNameURL);
498 oleLoanForm.setProxyPatronId(oleLoanDocument.getProxyPatronId());
499
500 oleLoanForm.setRealPatronType(oleLoanDocument.getRealPatronType());
501 oleLoanForm.setAddressVerified(oleLoanDocument.isAddressVerified());
502 oleLoanForm.setBlockLoan(oleLoanDocument.isBlockLoan());
503 oleLoanForm.setBorrowerTypeId(oleLoanDocument.getBorrowerTypeId());
504 oleLoanForm.setInformation("");
505 if (oleLoanDocument.getRealPatronBarcode() != null) {
506 for (OlePatronDocument olePatronDocument : oleLoanForm.getRealPatronList()) {
507 if (olePatronDocument.isRealPatronCheck()) {
508 oleLoanForm.setRealPatronId(olePatronDocument.getOlePatronId());
509 }
510 }
511 if (oleLoanForm.getRealPatronId() != null && (oleLoanForm.getRealPatronId() != null && !oleLoanForm.getRealPatronId().equalsIgnoreCase(""))) {
512 oleLoanForm.setExistingLoanList(getLoanProcessor().getPatronLoanedItemBySolr(oleLoanForm.getRealPatronId()));
513 oleLoanDocument.setRealPatronName(oleLoanForm.getRealPatronName());
514 }
515
516 } else {
517 oleLoanForm.setExistingLoanList(getLoanProcessor().getPatronLoanedItemBySolr(oleLoanDocument.getPatronId()));
518 }
519 oleLoanForm.setDummyLoan(oleLoanDocument);
520 oleLoanForm.setBlockItem(false);
521 oleLoanForm.setBlockPatron(false);
522 oleLoanForm.setNonCirculatingFlag(false);
523 oleLoanForm.setItem(null);
524 oleLoanForm.setOleItem(null);
525 oleLoanForm.getErrorsAndPermission().putAll(oleLoanDocument.getErrorsAndPermission());
526 if (oleLoanDocument.getErrorMessage() != null) {
527 oleLoanForm.setSuccess(false);
528 oleLoanForm.setInformation("");
529 oleLoanForm.setMessage(oleLoanDocument.getErrorMessage());
530 getLoanProcessor().setErrorFlagForPatron(oleLoanDocument, oleLoanForm);
531 oleLoanForm.setPatronName(null);
532 String audioOption = getLoanProcessor().getParameter(OLEConstants.AUDIO_OPTION);
533 oleLoanForm.setAudioEnable(audioOption != null && !audioOption.isEmpty() && audioOption.equalsIgnoreCase(OLEConstants.TRUE));
534 }
535 if (oleProxyLoanDocument != null) {
536 oleLoanForm.setRealPatronName(oleLoanDocument.getPatronName());
537 oleLoanDocument = oleProxyLoanDocument;
538 patronNameURL = getLoanProcessor().patronNameURL(oleLoanForm.getOldPrincipalId(), oleLoanForm.getProxyPatronId());
539 oleLoanForm.setPatronNameURL(patronNameURL);
540 } else {
541 oleLoanForm.setRealPatronName(null);
542 }
543 oleLoanForm.setPatronName(oleLoanDocument.getPatronName());
544 oleLoanForm.setBorrowerType(oleLoanDocument.getBorrowerTypeName());
545 oleLoanForm.setPreferredAddress(oleLoanDocument.getPreferredAddress());
546 oleLoanForm.setEmail(oleLoanDocument.getEmail());
547 oleLoanForm.setPhoneNumber(oleLoanDocument.getPhoneNumber());
548 oleLoanForm.setItemFocus(true);
549 oleLoanForm.setPatronFocus(false);
550
551 } catch (Exception e) {
552 oleLoanForm.setInformation(e.getMessage());
553 LOG.error("Exception while search patron time", e);
554 }
555 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
556 }
557
558
559
560
561
562
563
564
565
566
567 @RequestMapping(params = "methodToCall=addItem")
568 public ModelAndView addItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
569 HttpServletRequest request, HttpServletResponse response) {
570 LOG.debug("Inside the add item method");
571 OleLoanForm oleLoanForm = (OleLoanForm) form;
572 oleLoanForm.setBlockItem(false);
573 try {
574 oleLoanForm.setOleFormKey(oleLoanForm.getFormKey());
575
576
577
578
579
580
581 oleLoanForm.setInformation("");
582 oleLoanForm.setSuccessInfo("");
583 oleLoanForm.setReturnInformation("");
584
585
586
587
588
589
590
591
592
593 if (!getLoanProcessor().isValidCirculationDesk()) {
594 oleLoanForm.setLoanLoginUserInfo(GlobalVariables.getUserSession().getPrincipalName() + " " + OLEConstants.OleCirculationDesk.OLE_CIRCULATION_DESK_VALIDATIONS);
595 return super.start(oleLoanForm, result, request, response);
596 }
597 boolean renewalFlag = false;
598 List<OleLoanDocument> existItemList = new ArrayList<OleLoanDocument>();
599 if (oleLoanForm.getExistingLoanList() != null && !oleLoanForm.getExistingLoanList().isEmpty())
600 existItemList.addAll(oleLoanForm.getExistingLoanList());
601 if (oleLoanForm.getLoanList() != null && !oleLoanForm.getLoanList().isEmpty())
602 existItemList.addAll(oleLoanForm.getLoanList());
603 String item = oleLoanForm.getItem();
604 for (int i = 0; i < existItemList.size(); i++) {
605 OleLoanDocument oleLoanDocument = existItemList.get(i);
606 if (oleLoanDocument.getItemId() != null && oleLoanDocument.getItemId().equals(item)) {
607 oleLoanForm.setRenewalFlag(true);
608 oleLoanForm.setBlockItem(true);
609 oleLoanForm.setBlockPatron(true);
610 oleLoanForm.setSuccess(false);
611 oleLoanForm.setMessage(OLEConstants.RENEWAL_ITM_POPUP);
612 renewalFlag = true;
613 break;
614 }
615 }
616
617 if (!renewalFlag) {
618 try {
619 OleLoanDocument oleLoanDocument = new OleLoanDocument();
620 oleLoanDocument.setItemUuid(oleLoanForm.getItemUuid());
621 oleLoanForm.setAddressVerified(false);
622 oleLoanForm.getErrorsAndPermission().clear();
623 if (!getLoanProcessor().isClaimsReturnedItem(oleLoanForm.getItem(), oleLoanDocument)) {
624 oleLoanForm = getLoanProcessor().processLoan(oleLoanForm, oleLoanDocument);
625 oleLoanForm.setClaimsFlag(false);
626 } else {
627 oleLoanForm.setMessage("claims Returned Item");
628 oleLoanForm.setSuccess(false);
629 oleLoanForm.setClaimsFlag(true);
630 oleLoanForm.setRecordNote(false);
631 }
632 } catch (Exception e) {
633 LOG.error("Exception", e);
634 oleLoanForm.setInformation(e.getMessage());
635 }
636 }
637 oleLoanForm.setPatronbill(false);
638 getLoanProcessor().checkPatronBill(oleLoanForm);
639 } catch (Exception e) {
640 LOG.error("Exception while adding an item", e);
641 }
642 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
643 }
644
645
646
647
648
649
650
651
652
653
654 @RequestMapping(params = "methodToCall=loan")
655 public ModelAndView loanPatron(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
656 HttpServletRequest request, HttpServletResponse response) {
657 DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
658 LOG.debug("Inside the loan patron method");
659 if (loginUserList == null) {
660 loginUserList = new ArrayList<>();
661 }
662 StringBuffer buffer = new StringBuffer();
663 int count;
664 OleLoanForm oleLoanForm = (OleLoanForm) form;
665 String newPrincipalId = oleLoanForm.getNewPrincipalId();
666 oleLoanForm.setInformation("");
667 oleLoanForm.setSuccessInfo("");
668 oleLoanForm.setReturnInformation("");
669
670
671
672
673
674
675 OleLoanDocument oleLoanDocumentChk = null;
676 ModelAndView overrideModelView = null;
677 if (oleLoanForm.getItem() == null) {
678 try {
679
680 String principalId = GlobalVariables.getUserSession().getPrincipalId();
681 Boolean overRideFlag = getLoanProcessor().checkOverRidePermission(principalId, oleLoanForm);
682 if (!overRideFlag) {
683 oleLoanDocumentChk = getLoanProcessor().getLoanDocument(oleLoanForm.getPatronBarcode(), oleLoanForm.getRealPatronBarcode(), oleLoanForm.isSelfCheckOut(), false);
684 if (oleLoanDocumentChk.getErrorMessage() != null) {
685 if (!oleLoanForm.getLoanLoginName().equalsIgnoreCase("") || !oleLoanForm.getLoanLoginName().isEmpty()) {
686 buffer.append(oleLoanForm.getLoanLoginName() + "," + oleLoanForm.getCirculationDesk());
687 getLoanProcessor().getLoanUserList(loginUserList, buffer);
688 } else {
689 if (!oleLoanForm.getOldPrincipalId().equalsIgnoreCase("") || !oleLoanForm.getOldPrincipalId().isEmpty()) {
690 buffer.append(oleLoanForm.getOldPrincipalId() + "," + oleLoanForm.getCirculationDesk());
691 getLoanProcessor().getLoanUserList(loginUserList, buffer);
692 }
693 }
694
695 overrideModelView = this.overRide(form, result, request, response);
696 }
697 }
698 } catch (Exception e) {
699 LOG.error("Check for Address Verified and Block Failed." + e.getMessage(), e);
700
701 }
702
703 } else {
704 if (!oleLoanForm.getLoanLoginName().equalsIgnoreCase("") || !oleLoanForm.getLoanLoginName().isEmpty()) {
705 buffer.append(oleLoanForm.getLoanLoginName() + "," + oleLoanForm.getCirculationDesk());
706 getLoanProcessor().getLoanUserList(loginUserList, buffer);
707 } else {
708 if (!oleLoanForm.getOldPrincipalId().equalsIgnoreCase("") || !oleLoanForm.getOldPrincipalId().isEmpty()) {
709 buffer.append(oleLoanForm.getOldPrincipalId() + "," + oleLoanForm.getCirculationDesk());
710 getLoanProcessor().getLoanUserList(loginUserList, buffer);
711 }
712 }
713
714 overrideModelView = this.overRide(form, result, request, response);
715 }
716
717
718 if (overrideModelView == null) {
719 try {
720 List<OleLoanDocument> existingItemList = new ArrayList<OleLoanDocument>();
721 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
722 Timestamp checkinDate = new Timestamp(System.currentTimeMillis());
723 if (oleLoanDocument != null) {
724 if (oleLoanDocument.getItemLoanStatus() != null && oleLoanDocument.getItemLoanStatus().equalsIgnoreCase(OLEConstants.ITEM_STATUS_CHECKEDOUT)) {
725 oleLoanForm.setCheckInItem(oleLoanForm.getItem());
726 oleLoanForm.setBackGroundCheckIn(true);
727
728 oleLoanForm.setBackUpDummyLoan(oleLoanDocument);
729 oleLoanDocument = getLoanProcessor().getOleLoanDocumentUsingItemBarcode(oleLoanForm.getCheckInItem());
730 oleLoanDocument.setCheckInDate(checkinDate);
731 oleLoanForm.getErrorsAndPermission().clear();
732 oleLoanDocument = getLoanProcessor().returnLoan(oleLoanForm.getCheckInItem(), oleLoanDocument);
733 oleLoanForm.setDummyLoan(oleLoanDocument);
734 if (oleLoanDocument.getErrorMessage() != null) {
735 oleLoanForm.setSuccess(true);
736 oleLoanForm.setMessage(null);
737 oleLoanForm.setReturnSuccess(false);
738 oleLoanForm.setReturnMessage(oleLoanDocument.getErrorMessage());
739 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
740 }
741 if (oleLoanDocument.isCopyRequest()) {
742 oleLoanForm.setSuccess(true);
743 oleLoanForm.setMessage(null);
744 oleLoanForm.setCopyRequest(true);
745 oleLoanForm.setReturnSuccess(false);
746 oleLoanForm.setReturnMessage(OLEConstants.COPY_REQUEST_FULFILL);
747 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
748 }
749 if (oleLoanDocument.isNumberOfPieces() || (oleLoanDocument.getOleItem() != null && oleLoanDocument.getOleItem().getNumberOfPieces() != null && !oleLoanDocument.getOleItem().getNumberOfPieces().equalsIgnoreCase(""))) {
750 oleLoanForm.setSuccess(true);
751 oleLoanForm.setMessage(null);
752 oleLoanForm.setNumberOfPieces(true);
753 oleLoanForm.setReturnSuccess(false);
754 oleLoanDocument.setContinueCheckIn(true);
755 oleLoanDocument.setBackgroundCheckInMissingPiece(true);
756 if (oleLoanDocument.getOleItem() != null && oleLoanDocument.getOleItem().getNumberOfPieces() != null) {
757 if (oleLoanDocument.getOleItem().getMissingPieceFlagNote() != null) {
758 oleLoanDocument.setDescription(oleLoanDocument.getOleItem().getMissingPieceFlagNote());
759 } else {
760 oleLoanDocument.setDescription("");
761 }
762 }
763 if (oleLoanDocument.getItemNumberOfPieces() != null) {
764 oleLoanForm.setReturnMessage(OLEConstants.VERIFY_PIECES + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.PIECES_RETURNED
765 + OLEConstants.BREAK + "Total No of Pieces : " + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.BREAK + "No of missing Pieces : " + (oleLoanDocument.getOleItem().getMissingPiecesCount() != null ? oleLoanDocument.getOleItem().getMissingPiecesCount() : "0"));
766 } else if (oleLoanDocument.getOleItem() != null && oleLoanDocument.getOleItem().getNumberOfPieces() != null) {
767 oleLoanForm.setReturnMessage(OLEConstants.VERIFY_PIECES + oleLoanDocument.getOleItem().getNumberOfPieces() + OLEConstants.PIECES_RETURNED
768 + OLEConstants.BREAK + "Total No of Pieces : " + oleLoanDocument.getOleItem().getNumberOfPieces() + OLEConstants.BREAK + "No of missing Pieces : " + (oleLoanDocument.getOleItem().getMissingPiecesCount() != null ? oleLoanDocument.getOleItem().getMissingPiecesCount() : "0"));
769 }
770
771 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
772 }
773 OleLoanForm oleReturnLoanForm = (OleLoanForm) oleLoanForm;
774
775 if (oleReturnLoanForm.getDummyLoan() != null) {
776 oleLoanDocument.setItemLoanStatus(oleReturnLoanForm.getDummyLoan().getItemStatus());
777 oleLoanForm.getDummyLoan().setItemLoanStatus(oleReturnLoanForm.getDummyLoan().getItemStatus());
778 }
779
780
781 } else if (oleLoanForm.getBackUpDummyLoan() != null) {
782 oleLoanDocument = oleLoanForm.getBackUpDummyLoan();
783 oleLoanDocument.setBackgroundCheckInMissingPiece(oleLoanForm.getDummyLoan().isBackgroundCheckInMissingPiece());
784 if (oleLoanForm.getDummyLoan() != null) {
785 oleLoanDocument.setItemLoanStatus(oleLoanForm.getDummyLoan().getItemStatus());
786 oleLoanDocument.setItemDamagedStatus(oleLoanForm.getDummyLoan().isItemDamagedStatus());
787 oleLoanDocument.setItemDamagedNote(oleLoanForm.getDummyLoan().getItemDamagedNote());
788 oleLoanDocument.getOleItem().setMissingPieceFlagNote(oleLoanForm.getMissingPieceMessage());
789 if (oleLoanDocument.getOleItem() != null) {
790 oleLoanDocument.getOleItem().setMissingPiecesCount(oleLoanForm.getDummyLoan().getMissingPiecesCount());
791 oleLoanDocument.getOleItem().setMissingPieceFlag(oleLoanForm.getDummyLoan().isMissingPieceFlag());
792 }
793 }
794 oleLoanForm.setBackUpDummyLoan(null);
795 }
796 boolean indefinite = false;
797 if (oleLoanForm.getItem() != null && !oleLoanForm.getItem().isEmpty() && oleLoanForm.getDueDateMap() == null && oleLoanDocument.getExpirationDate() == null) {
798 indefinite = true;
799 }
800 if ((oleLoanForm.getItem() != null && !oleLoanForm.getItem().isEmpty()) || (oleLoanForm.getOleItem() != null && !oleLoanForm.getOleItem().getItemIdentifier().isEmpty()) || indefinite) {
801 if (oleLoanForm.getDueDateMap() != null) {
802 Timestamp timestamp;
803 Pattern pattern;
804 Matcher matcher;
805 SimpleDateFormat fmt = new SimpleDateFormat(OLEConstants.OlePatron.PATRON_MAINTENANCE_DATE_FORMAT);
806 boolean timeFlag = false;
807 if (oleLoanForm.getPopDateTime() != null && !oleLoanForm.getPopDateTime().isEmpty()) {
808 String[] str = oleLoanForm.getPopDateTime().split(":");
809 pattern = Pattern.compile(OLEConstants.TIME_24_HR_PATTERN);
810 matcher = pattern.matcher(oleLoanForm.getPopDateTime());
811 timeFlag = matcher.matches();
812 if (timeFlag) {
813 if (str != null && str.length <= 2) {
814 oleLoanForm.setPopDateTime(oleLoanForm.getPopDateTime() + OLEConstants.CHECK_IN_TIME_MS);
815 }
816 timestamp = Timestamp.valueOf(new SimpleDateFormat(OLEConstants.CHECK_IN_DATE_TIME_FORMAT).format(oleLoanForm.getDueDateMap()).concat(" ").concat(oleLoanForm.getPopDateTime()));
817 } else {
818 oleLoanForm.setPopDateTimeInfo(OLEConstants.DUE_DATE_TIME_FORMAT_MESSAGE);
819
820 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
821 }
822 } else if (fmt.format(oleLoanForm.getDueDateMap()).compareTo(fmt.format(new Date())) == 0) {
823 timestamp = new Timestamp(new Date().getTime());
824 } else {
825 timestamp = Timestamp.valueOf(new SimpleDateFormat(OLEConstants.CHECK_IN_DATE_TIME_FORMAT).format(oleLoanForm.getDueDateMap()).concat(" ").concat(new SimpleDateFormat("HH:mm:ss").format(new Date())));
826 }
827 oleLoanDocument.setLoanDueDate(timestamp);
828 }
829 if (oleLoanDocument.getItemLoanStatus() != null && !oleLoanDocument.getItemLoanStatus().equalsIgnoreCase(OLEConstants.ITEM_STATUS_CHECKEDOUT) || oleLoanDocument.isBackgroundCheckInMissingPiece()) {
830 getLoanProcessor().saveLoan(oleLoanForm.getBackUpDummyLoan() != null ? oleLoanForm.getBackUpDummyLoan() : oleLoanDocument);
831 if (oleLoanForm.getBackUpDummyLoan() != null) {
832 oleLoanDocument = oleLoanForm.getBackUpDummyLoan();
833 oleLoanDocument.setBackgroundCheckInMissingPiece(oleLoanForm.getDummyLoan().isBackgroundCheckInMissingPiece());
834 if (oleLoanForm.getDummyLoan() != null) {
835 oleLoanDocument.setItemLoanStatus(oleLoanForm.getDummyLoan().getItemStatus());
836 oleLoanDocument.setItemDamagedStatus(oleLoanForm.getDummyLoan().isItemDamagedStatus());
837 oleLoanDocument.setItemDamagedNote(oleLoanForm.getDummyLoan().getItemDamagedNote());
838 oleLoanDocument.getOleItem().setMissingPieceFlagNote(oleLoanForm.getMissingPieceMessage());
839 if (oleLoanDocument.getOleItem() != null) {
840 oleLoanDocument.getOleItem().setMissingPiecesCount(oleLoanForm.getDummyLoan().getMissingPiecesCount());
841 oleLoanDocument.getOleItem().setMissingPieceFlag(oleLoanForm.getDummyLoan().isMissingPieceFlag());
842 }
843 }
844 oleLoanForm.setBackUpDummyLoan(null);
845 }
846 oleLoanForm.setSuccessMessage(oleLoanDocument.getSuccessMessage());
847 if (!oleLoanForm.isCheckOut())
848 existingItemList.add(oleLoanDocument);
849 oleLoanDocument.setBackgroundCheckInMissingPiece(false);
850 }
851
852 if (oleLoanForm.getLoanList() != null && !oleLoanForm.getLoanList().isEmpty()) {
853 existingItemList.addAll(oleLoanForm.getLoanList());
854 }
855 oleLoanForm.setLoanList(existingItemList);
856 }
857 if (StringUtils.isNotEmpty(oleLoanDocument.getItemUuid())) {
858 org.kuali.ole.docstore.common.document.Item item = getDocstoreClientLocator().getDocstoreClient().retrieveItem(oleLoanDocument.getItemUuid());
859 String itemXmlContent = item.getContent();
860
861 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
862 getLoanProcessor().getLocation(oleItem, oleLoanDocument, item);
863 if (oleLoanDocument.getLocation() == null || oleLoanDocument.getLocation().isEmpty()) {
864 getLoanProcessor().getDefaultHoldingLocation(oleLoanDocument);
865 }
866 if (oleLoanDocument.getCheckInDate() == null) {
867 oleLoanDocument.setCheckInDate(checkinDate);
868 }
869 if (oleLoanDocument.getOleCirculationDesk() == null) {
870 oleLoanDocument.setCirculationLocationId(oleLoanForm.getCirculationDesk());
871 }
872 if (oleItem.isMissingPieceFlag()) {
873 oleLoanDocument.setMissingPieceNote(oleItem.getMissingPieceFlagNote());
874 oleLoanDocument.setMissingPieceFlag(oleItem.isMissingPieceFlag());
875 }
876 if (oleItem.isItemDamagedStatus()) {
877 oleLoanDocument.setItemDamagedNote(oleItem.getDamagedItemNote());
878 }
879 if (oleLoanForm.getPatronName() == null) {
880 oleLoanForm.setPatronName(oleLoanDocument.getPatronName());
881 }
882 if (oleItem.isClaimsReturnedFlag()) {
883 if (oleItem.getClaimsReturnedFlagCreateDate() != null)
884 oleLoanDocument.setClaimsReturnedDate(new Timestamp(df.parse(oleItem.getClaimsReturnedFlagCreateDate()).getTime()));
885 oleLoanDocument.setClaimsReturnedIndicator(true);
886 oleLoanDocument.setClaimsReturnNote(oleItem.getClaimsReturnedNote());
887 }
888 if (oleLoanForm.getPatronName() == null) {
889 oleLoanForm.setPatronName(oleLoanDocument.getPatronName());
890 }
891 if (oleLoanForm.isCheckOut()) {
892 if (!oleLoanDocument.getItemLoanStatus().equalsIgnoreCase(OLEConstants.ITEM_STATUS_CHECKEDOUT))
893 getLoanProcessor().saveLoan(oleLoanForm.getBackUpDummyLoan() != null ? oleLoanForm.getBackUpDummyLoan() : oleLoanDocument);
894 oleLoanForm.setSuccessMessage(oleLoanDocument.getSuccessMessage());
895 List<OleLoanDocument> oleLoanDocuments = new ArrayList<OleLoanDocument>();
896 if (oleLoanDocument.getOleItem().getItemStatus() != null) {
897 oleLoanDocument.setItemStatusCode(oleLoanDocument.getOleItem().getItemStatus().getCodeValue());
898 } else {
899 oleLoanDocument.setItemStatusCode(oleLoanDocument.getItemLoanStatus());
900 }
901 OleItemAvailableStatus oleItemAvailableStatus = getLoanProcessor().validateAndGetItemStatus(oleLoanDocument.getItemStatusCode());
902 oleLoanDocument.setItemStatus(oleItemAvailableStatus != null ? oleItemAvailableStatus.getItemAvailableStatusName() : null);
903 oleLoanDocument.setDescription(oleLoanForm.getDescription());
904 oleLoanDocuments.add(oleLoanDocument);
905 if (oleLoanForm.getItemReturnList() != null) {
906 oleLoanDocuments.addAll(oleLoanForm.getItemReturnList());
907 }
908 oleLoanForm.setItemReturnList(oleLoanDocuments);
909 if (oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
910 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
911 OleNoticeBo oleNoticeBo = getLoanProcessor().getNotice(oleLoanDocument);
912
913 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
914 Date date = new Date(oleLoanDocument.getCheckInDate().getTime());
915 if (oleNoticeBo != null) {
916 oleNoticeBo.setCheckInDate(dateFormat.format(date));
917 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
918 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) {
919 fromAddress = OLEConstants.KUALI_MAIL;
920 }
921 String missingNoticeDetails = getOleDeliverBatchService().sendMissingNotice(oleNoticeBo);
922 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer");
923 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(missingNoticeDetails), true);
924 if (LOG.isInfoEnabled()) {
925 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress());
926 }
927 }
928 } else {
929 if (oleLoanDocument.getItemStatusCode() != null && oleLoanDocument.getItemStatusCode().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isHoldQueue()) {
930 oleLoanForm.setBillAvailability(false);
931 } else {
932 oleLoanForm.setBillAvailability(true);
933 }
934 }
935 }
936 if (oleLoanDocument.isCheckOut()) {
937 oleLoanForm.setDueDateSlip(true);
938 oleLoanForm.setBillAvailability(false);
939 }
940 oleLoanForm.setReturnSuccess(true);
941 oleLoanForm.setCheckOut(false);
942 }
943 oleLoanForm.setSuccess(true);
944 oleLoanForm.setMessage(null);
945 oleLoanForm.setItem("");
946 oleLoanForm.setInformation("");
947 oleLoanForm.setPopDateTimeInfo("");
948 oleLoanForm.setAddressVerified(false);
949 if (oleLoanDocument.isClaimsReturnedIndicator()) {
950 saveGeneralNoteForFlaggedItem(OLEConstants.CLAIMS_CHECKED_OUT_FLAG, true, oleLoanDocument, true, false, oleLoanForm.isBackGroundCheckIn(), oleLoanForm.getPatronBarcode());
951 }
952 }
953 if (oleLoanDocument.isMissingPieceFlag() || oleLoanDocument.isItemDamagedStatus()) {
954 flaggedNoteSave(form, result, request, response);
955 }
956 }
957 } catch (Exception e) {
958 oleLoanForm.setInformation(e.getMessage());
959 LOG.error("Exception", e);
960 }
961 }
962 if (StringUtils.isNotEmpty(newPrincipalId)) {
963 if (getLoanProcessor().isValidCirculationDesk()) {
964 if (getLoanProcessor().getCircDeskId() != null) {
965 oleLoanForm.setCirculationDesk(getLoanProcessor().getCircDeskId());
966 }
967 }
968 }
969
970 oleLoanForm.setOleFormKey(oleLoanForm.getFormKey());
971 String audioOption = getLoanProcessor().getParameter(OLEConstants.AUDIO_OPTION);
972 oleLoanForm.setAudioEnable(audioOption != null && !audioOption.isEmpty() && audioOption.equalsIgnoreCase(OLEConstants.TRUE));
973 oleLoanForm.setItemUuid(null);
974 oleLoanForm.setInstanceUuid(null);
975 if (oleLoanForm.getDummyLoan() != null && oleLoanForm.getDummyLoan().getOlePatron() != null && oleLoanForm.getDummyLoan().getErrorMessage() != null) {
976 oleLoanForm.setMessage(null);
977 oleLoanForm.setBlockPatron(false);
978 oleLoanForm.setBlockItem(false);
979 oleLoanForm.setSuccess(true);
980 }
981 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
982 }
983
984
985
986
987
988
989
990
991
992
993 @RequestMapping(params = "methodToCall=noLoan")
994 public ModelAndView doNotLoanPatron(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
995 HttpServletRequest request, HttpServletResponse response) {
996 LOG.debug("Inside the do not loan patron method");
997 OleLoanForm oleLoanForm = (OleLoanForm) form;
998
999
1000
1001
1002
1003
1004 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
1005 if (oleLoanForm.isCheckOut()) {
1006 List<OleLoanDocument> oleLoanDocuments = new ArrayList<OleLoanDocument>();
1007 if (oleLoanDocument.getOleItem().getItemStatus() != null) {
1008 oleLoanDocument.setItemStatusCode(oleLoanDocument.getOleItem().getItemStatus().getCodeValue());
1009 } else {
1010 oleLoanDocument.setItemStatusCode(oleLoanDocument.getItemLoanStatus());
1011 }
1012 OleItemAvailableStatus oleItemAvailableStatus = getLoanProcessor().validateAndGetItemStatus(oleLoanDocument.getItemStatusCode());
1013 oleLoanDocument.setItemStatus(oleItemAvailableStatus != null ? oleItemAvailableStatus.getItemAvailableStatusName() : null);
1014 oleLoanDocuments.add(oleLoanDocument);
1015 if (oleLoanForm.getItemReturnList() != null) {
1016 oleLoanDocuments.addAll(oleLoanForm.getItemReturnList());
1017 }
1018 if (oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
1019 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
1020 OleNoticeBo oleNoticeBo = getLoanProcessor().getNotice(oleLoanDocument);
1021
1022 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
1023 Date date = new Date(oleLoanDocument.getCheckInDate().getTime());
1024 if (oleNoticeBo != null) {
1025 oleNoticeBo.setCheckInDate(dateFormat.format(date));
1026 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
1027 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) {
1028 fromAddress = OLEConstants.KUALI_MAIL;
1029 }
1030 String missingNoticeDetails = getOleDeliverBatchService().sendMissingNotice(oleNoticeBo);
1031 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer");
1032 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(missingNoticeDetails), true);
1033 if (LOG.isInfoEnabled()) {
1034 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress());
1035 }
1036 }
1037 } else {
1038 if (oleLoanDocument.getItemStatusCode() != null && oleLoanDocument.getItemStatusCode().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isHoldQueue()) {
1039 oleLoanForm.setBillAvailability(false);
1040 } else {
1041 oleLoanForm.setBillAvailability(true);
1042 }
1043 }
1044 }
1045 oleLoanForm.setItemReturnList(oleLoanDocuments);
1046 oleLoanForm.setReturnSuccess(true);
1047 oleLoanForm.setCheckOut(false);
1048 String audioOption = getLoanProcessor().getParameter(OLEConstants.AUDIO_OPTION);
1049 oleLoanForm.setAudioEnable(audioOption != null && !audioOption.isEmpty() && audioOption.equalsIgnoreCase(OLEConstants.TRUE));
1050 }
1051 if (oleLoanForm.getItem() == null || "".equals(oleLoanForm.getItem())) {
1052 clearPatronScreen(oleLoanForm, result, request, response);
1053 }
1054 oleLoanForm.setAddressVerified(false);
1055 oleLoanForm.setItem("");
1056 oleLoanForm.setInformation("");
1057 oleLoanForm.setReturnInformation("");
1058 oleLoanForm.setDueDateSlip(false);
1059 oleLoanForm.setMessage(null);
1060 oleLoanForm.setSuccess(true);
1061 oleLoanForm.setItemUuid(null);
1062 oleLoanForm.setInstanceUuid(null);
1063 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
1064 }
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075 @RequestMapping(params = "methodToCall=openFastAdd")
1076 public ModelAndView openFastAdd(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1077 HttpServletRequest request, HttpServletResponse response) {
1078 LOG.debug("Inside the openFastAdd method");
1079 OleLoanForm oleLoanForm = (OleLoanForm) form;
1080
1081
1082
1083
1084
1085
1086
1087
1088 oleLoanForm.setFastAddItemIndicator(true);
1089 String url = ConfigContext.getCurrentContextConfig().getProperty("ole.rice2.url.base") + "/ole-kr-krad/fastAddController?viewId=FastAddItemView&methodToCall=start";
1090 oleLoanForm.setFastAddUrl(url);
1091 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1092 }
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104 @RequestMapping(params = "methodToCall=deletePatronUserNote")
1105 public ModelAndView deletePatronUserNote(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1106 HttpServletRequest request, HttpServletResponse response) {
1107 LOG.debug("Inside the delete patron user note method");
1108 OleLoanForm oleLoanForm = (OleLoanForm) form;
1109
1110
1111
1112
1113
1114
1115 oleLoanForm.setPatronNoteFlag(false);
1116
1117 try {
1118 getLoanProcessor().deletePatronUserNote(oleLoanForm.getPatronId(), oleLoanForm.getPatronNoteTypeId());
1119 } catch (Exception e) {
1120 oleLoanForm.setInformation(e.getMessage());
1121 LOG.error("Exception while deleting patron user note", e);
1122 }
1123 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1124 }
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135 @RequestMapping(params = "methodToCall=editDueDate")
1136 public ModelAndView editDueDate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1137 HttpServletRequest request, HttpServletResponse response) {
1138 LOG.debug("Inside the edit due date method");
1139 if (loginUserList == null) {
1140 loginUserList = new ArrayList<>();
1141 }
1142 StringBuffer buffer = new StringBuffer();
1143 OleLoanForm oleLoanForm = (OleLoanForm) form;
1144
1145
1146
1147
1148
1149
1150 oleLoanForm.setInformation("");
1151 oleLoanForm.setSuccessInfo("");
1152 oleLoanForm.setReturnInformation("");
1153 List<OleLoanDocument> alterDueDateList = new ArrayList<OleLoanDocument>();
1154 alterDueDateList = getLoanProcessor().setListValues(oleLoanForm.getLoanList(), oleLoanForm.getExistingLoanList(), false, null, false);
1155
1156 if (alterDueDateList.size() != 0) {
1157 oleLoanForm.setAlterDueDateList(alterDueDateList);
1158 oleLoanForm.setInformation("");
1159 if (!oleLoanForm.getLoanLoginName().equalsIgnoreCase("") || !oleLoanForm.getLoanLoginName().isEmpty()) {
1160 buffer.append(oleLoanForm.getLoanLoginName() + "," + oleLoanForm.getCirculationDesk());
1161 getLoanProcessor().getLoanUserList(loginUserList, buffer);
1162 } else {
1163 if (!oleLoanForm.getOldPrincipalId().equalsIgnoreCase("") || !oleLoanForm.getOldPrincipalId().isEmpty()) {
1164 buffer.append(oleLoanForm.getOldPrincipalId() + "," + oleLoanForm.getCirculationDesk());
1165 getLoanProcessor().getLoanUserList(loginUserList, buffer);
1166 }
1167 }
1168 ModelAndView overrideModelView = this.overRide(form, result, request, response);
1169 if (getLoanProcessor().isValidCirculationDesk()) {
1170
1171
1172
1173 }
1174 if (overrideModelView == null)
1175 oleLoanForm.setAlterDueDateFlag(true);
1176 } else
1177 oleLoanForm.setInformation(OLEConstants.ALTER_DUE_DATE_ERR_INFO);
1178
1179 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1180 }
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191 @RequestMapping(params = "methodToCall=updateDueDate")
1192 public ModelAndView updateDueDate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1193 HttpServletRequest request, HttpServletResponse response) {
1194 LOG.debug("Inside the update due date method");
1195 OleLoanForm oleLoanForm = (OleLoanForm) form;
1196
1197
1198
1199
1200
1201
1202 oleLoanForm.setInformation("");
1203 oleLoanForm.setSuccessInfo("");
1204 oleLoanForm.setReturnInformation("");
1205 boolean timeFlag = true;
1206 try {
1207 oleLoanForm.setAlterDueDateTimeInfo("");
1208 timeFlag = getLoanProcessor().updateLoan(oleLoanForm.getAlterDueDateList());
1209 if (!timeFlag) {
1210 oleLoanForm.setAlterDueDateTimeInfo(OLEConstants.ALTER_DUE_DATE_TIME_FORMAT_MESSAGE);
1211 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1212 }
1213 getLoanProcessor().updateItem(oleLoanForm.getAlterDueDateList(), false, false);
1214 } catch (Exception e) {
1215 oleLoanForm.setInformation(e.getMessage());
1216 LOG.error("Exception while updating due date", e);
1217 }
1218 oleLoanForm.setAlterDueDateFlag(false);
1219 List<OleLoanDocument> sortedExistingLoanList = oleLoanForm.getExistingLoanList();
1220 List<OleLoanDocument> LoanDocumentList = new ArrayList<>();
1221 List<OleLoanDocument> indefiniteLoanDocumentList = new ArrayList<>();
1222 for (OleLoanDocument loanDoc : sortedExistingLoanList) {
1223 if (loanDoc.getLoanDueDate() != null && !(loanDoc.getLoanDueDate().toString().isEmpty())) {
1224 LoanDocumentList.add(loanDoc);
1225 } else {
1226 indefiniteLoanDocumentList.add(loanDoc);
1227 }
1228
1229 }
1230 Collections.sort(LoanDocumentList, new Comparator<OleLoanDocument>() {
1231 public int compare(OleLoanDocument o1, OleLoanDocument o2) {
1232 return o1.getLoanDueDate().compareTo(o2.getLoanDueDate());
1233 }
1234 });
1235 LoanDocumentList.addAll(indefiniteLoanDocumentList);
1236 oleLoanForm.setExistingLoanList(LoanDocumentList);
1237 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1238 }
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249 @RequestMapping(params = "methodToCall=closeAlterDueDate")
1250 public ModelAndView closeAlterDueDate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1251 HttpServletRequest request, HttpServletResponse response) {
1252 LOG.debug("Inside the close Alter due date method");
1253 OleLoanForm oleLoanForm = (OleLoanForm) form;
1254
1255
1256
1257
1258
1259
1260 List<OleLoanDocument> resetAlterDueDate = oleLoanForm.getAlterDueDateList();
1261 if (resetAlterDueDate != null) {
1262 for (int restDueDate = 0; restDueDate < resetAlterDueDate.size(); restDueDate++) {
1263 OleLoanDocument oleLoanDocument = (OleLoanDocument) resetAlterDueDate.get(restDueDate);
1264 oleLoanDocument.setLoanDueDate(new Timestamp(oleLoanDocument.getPastDueDate().getTime()));
1265 oleLoanDocument.setPastDueDate(null);
1266 }
1267 }
1268
1269 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1270 }
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281 @RequestMapping(params = "methodToCall=claimsReturn")
1282 public ModelAndView claimsReturn(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1283 HttpServletRequest request, HttpServletResponse response) {
1284 LOG.debug("Inside the claims return method");
1285 if (loginUserList == null) {
1286 loginUserList = new ArrayList<>();
1287 }
1288 StringBuffer buffer = new StringBuffer();
1289 OleLoanForm oleLoanForm = (OleLoanForm) form;
1290
1291
1292
1293
1294
1295
1296 oleLoanForm.setInformation("");
1297 oleLoanForm.setSuccessInfo("");
1298 oleLoanForm.setReturnInformation("");
1299 oleLoanForm.setRemoveClaimsReturnFlag(false);
1300 boolean checkedItemsFlag = false;
1301 if (oleLoanForm.getLoanList().size() > 0) {
1302 for (int curremtLoan = 0; curremtLoan < oleLoanForm.getLoanList().size(); curremtLoan++) {
1303 OleLoanDocument oleLoanDocument = (OleLoanDocument) oleLoanForm.getLoanList().get(curremtLoan);
1304 if (oleLoanDocument.isCheckNo()) {
1305 try {
1306 String itemXmlContent = getLoanProcessor().getItemXML(oleLoanDocument.getItemUuid());
1307 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
1308 oleLoanForm.setClaimsReturnNote(oleItem.getClaimsReturnedNote());
1309 oleLoanForm.setItemClaimsReturnFlag(oleItem.isClaimsReturnedFlag());
1310 } catch (Exception e) {
1311 throw new RuntimeException();
1312 }
1313 checkedItemsFlag = true;
1314 break;
1315 }
1316 }
1317 }
1318 if (oleLoanForm.getExistingLoanList().size() > 0) {
1319 for (int curremtLoan = 0; curremtLoan < oleLoanForm.getExistingLoanList().size(); curremtLoan++) {
1320 OleLoanDocument oleLoanDocument = (OleLoanDocument) oleLoanForm.getExistingLoanList().get(curremtLoan);
1321 if (oleLoanDocument.isCheckNo()) {
1322 try {
1323 String itemXmlContent = getLoanProcessor().getItemXML(oleLoanDocument.getItemUuid());
1324 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
1325 oleLoanForm.setItemClaimsReturnFlag(oleItem.isClaimsReturnedFlag());
1326 oleLoanForm.setClaimsReturnNote(oleItem.getClaimsReturnedNote());
1327 } catch (Exception e) {
1328 throw new RuntimeException();
1329 }
1330 checkedItemsFlag = true;
1331 break;
1332 }
1333 }
1334 }
1335 if (checkedItemsFlag) {
1336 oleLoanForm.setInformation("");
1337 if (!oleLoanForm.getLoanLoginName().equalsIgnoreCase("") || !oleLoanForm.getLoanLoginName().isEmpty()) {
1338 buffer.append(oleLoanForm.getLoanLoginName() + "," + oleLoanForm.getCirculationDesk());
1339 getLoanProcessor().getLoanUserList(loginUserList, buffer);
1340 } else {
1341 if (!oleLoanForm.getOldPrincipalId().equalsIgnoreCase("") || !oleLoanForm.getOldPrincipalId().isEmpty()) {
1342 buffer.append(oleLoanForm.getOldPrincipalId() + "," + oleLoanForm.getCirculationDesk());
1343 getLoanProcessor().getLoanUserList(loginUserList, buffer);
1344 }
1345 }
1346 ModelAndView overrideModelView = this.overRide(form, result, request, response);
1347 if (getLoanProcessor().isValidCirculationDesk()) {
1348
1349
1350
1351 }
1352 if (overrideModelView == null)
1353 oleLoanForm.setClaimsReturnFlag(true);
1354 } else
1355 oleLoanForm.setInformation(OLEConstants.CLAIMS_ITM_ERR_INFO);
1356 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1357 }
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368 @RequestMapping(params = "methodToCall=applyClaimsReturn")
1369 public ModelAndView applyClaimsReturn(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1370 HttpServletRequest request, HttpServletResponse response) {
1371 LOG.debug("Inside the apply claims return method");
1372 OleLoanForm oleLoanForm = (OleLoanForm) form;
1373
1374
1375
1376
1377
1378
1379 oleLoanForm.setInformation("");
1380 oleLoanForm.setSuccessInfo("");
1381 oleLoanForm.setReturnInformation("");
1382 List<OleLoanDocument> claimsList = new ArrayList<OleLoanDocument>();
1383 claimsList = getLoanProcessor().setListValues(oleLoanForm.getLoanList(), oleLoanForm.getExistingLoanList(), oleLoanForm.isClaimsReturnFlag(), oleLoanForm.getClaimsReturnNote(), oleLoanForm.isRemoveClaimsReturnFlag());
1384 try {
1385 getLoanProcessor().updateLoan(claimsList);
1386 getLoanProcessor().updateItem(claimsList, true, oleLoanForm.isRemoveClaimsReturnFlag());
1387 } catch (Exception e) {
1388 LOG.error("Exception while setting claims return", e);
1389 oleLoanForm.setInformation(e.getMessage());
1390 }
1391 oleLoanForm.setClaimsReturnFlag(false);
1392 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1393 }
1394
1395
1396 @RequestMapping(params = "methodToCall=showMissingPieceDialogBox")
1397 public ModelAndView showMissingPieceDialogBox(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1398 HttpServletRequest request, HttpServletResponse response) {
1399 OleLoanForm oleLoanForm = (OleLoanForm) form;
1400
1401
1402
1403
1404
1405
1406 int count = 0;
1407 oleLoanForm.setDialogFlag(false);
1408 oleLoanForm.setDialogItemNoOfPieces(null);
1409 oleLoanForm.setDialogMissingPieceCount(null);
1410 oleLoanForm.setDialogText(null);
1411 oleLoanForm.setDialogItemNoOfPiecesReadOnly(false);
1412 oleLoanForm.setDialogMissingPieceCountReadOnly(false);
1413 oleLoanForm.setDialogErrorMessage(null);
1414 oleLoanForm.setInformation("");
1415 oleLoanForm.setSuccessInfo("");
1416 OleLoanDocument loanDocument = new OleLoanDocument();
1417 if (oleLoanForm.getLoanList().size() > 0) {
1418 for (OleLoanDocument oleLoanDocument : oleLoanForm.getLoanList()) {
1419 if (oleLoanDocument.isCheckNo()) {
1420 loanDocument = oleLoanDocument;
1421 count++;
1422 }
1423 }
1424 }
1425 if (oleLoanForm.getExistingLoanList().size() > 0) {
1426 for (OleLoanDocument oleLoanDocument : oleLoanForm.getExistingLoanList()) {
1427 if (oleLoanDocument.isCheckNo()) {
1428 loanDocument = oleLoanDocument;
1429 count++;
1430 }
1431 }
1432 }
1433 if (count == 1) {
1434 try {
1435 String itemXmlContent = getLoanProcessor().getItemXML(loanDocument.getItemUuid());
1436 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
1437 oleLoanForm.setDialogText(oleItem.getMissingPieceFlagNote());
1438 if (!oleItem.isMissingPieceFlag()) {
1439 oleLoanForm.setDialogFlag(true);
1440 } else {
1441 oleLoanForm.setRemoveMissingPieceButton(true);
1442 }
1443 oleLoanForm.setDialogMissingPieceCount(oleItem.getMissingPiecesCount());
1444 oleLoanForm.setDialogItemNoOfPieces(oleItem.getNumberOfPieces());
1445 if (oleItem.getNumberOfPieces() != null && !oleItem.getNumberOfPieces().equalsIgnoreCase("")) {
1446 oleLoanForm.setDialogItemNoOfPiecesReadOnly(true);
1447 }
1448 if (oleItem.isMissingPieceFlag()) {
1449 if (oleItem.getMissingPiecesCount() != null && !oleItem.getMissingPiecesCount().equalsIgnoreCase("")) {
1450 oleLoanForm.setDialogMissingPieceCountReadOnly(true);
1451 }
1452
1453 }
1454 } catch (Exception e) {
1455 throw new RuntimeException();
1456 }
1457 oleLoanForm.setMissingPieceDialog(true);
1458 oleLoanForm.setMissingPieceLoanDocument(loanDocument);
1459 } else
1460 oleLoanForm.setInformation(OLEConstants.SELECT_SINGLE_ITEM);
1461
1462 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1463 }
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474 @RequestMapping(params = "methodToCall=updateMissingPieceItem")
1475 public ModelAndView updateMissingPieceItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1476 HttpServletRequest request, HttpServletResponse response) {
1477 LOG.debug("Inside the claims return method");
1478 if (loginUserList == null) {
1479 loginUserList = new ArrayList<>();
1480 }
1481 StringBuffer buffer = new StringBuffer();
1482 OleLoanForm oleLoanForm = (OleLoanForm) form;
1483
1484
1485
1486
1487
1488
1489 OleLoanDocument loanDocument = oleLoanForm.getMissingPieceLoanDocument();
1490 if (oleLoanForm.getDialogItemNoOfPieces() == null || oleLoanForm.getDialogItemNoOfPieces() != null && oleLoanForm.getDialogItemNoOfPieces().equalsIgnoreCase("")) {
1491 oleLoanForm.setDialogErrorMessage("Provide information for no of pieces");
1492 oleLoanForm.setDialogItemNoOfPiecesReadOnly(false);
1493 oleLoanForm.setMissingPieceDialog(true);
1494 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1495 }
1496 if (oleLoanForm.getDialogMissingPieceCount() != null && oleLoanForm.getDialogItemNoOfPieces().equalsIgnoreCase("")) {
1497 int noOfPiece = Integer.parseInt(oleLoanForm.getDialogItemNoOfPieces());
1498 if (noOfPiece < 1) {
1499 oleLoanForm.setMissingPieceDialog(true);
1500 oleLoanForm.setDialogItemNoOfPiecesReadOnly(false);
1501 oleLoanForm.setDialogErrorMessage(OLEConstants.ERROR_MISSING_ITEM_NO_GREATER);
1502 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1503 }
1504 }
1505 oleLoanForm.setDialogItemNoOfPiecesReadOnly(true);
1506 if (oleLoanForm.getDialogMissingPieceCount() == null || (oleLoanForm.getDialogMissingPieceCount() != null && oleLoanForm.getDialogMissingPieceCount().equalsIgnoreCase(""))) {
1507 oleLoanForm.setMissingPieceDialog(true);
1508 oleLoanForm.setDialogMissingPieceCountReadOnly(false);
1509 oleLoanForm.setDialogErrorMessage(OLEConstants.ERROR_MISSING_ITEM_COUNT_REQUIRED);
1510 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1511 }
1512 if (oleLoanForm.getDialogMissingPieceCount() != null && !oleLoanForm.getDialogMissingPieceCount().equalsIgnoreCase("")) {
1513 int count = Integer.parseInt(oleLoanForm.getDialogMissingPieceCount());
1514 int noOfPiece = Integer.parseInt(oleLoanForm.getDialogItemNoOfPieces());
1515 if (count < 1) {
1516 oleLoanForm.setMissingPieceDialog(true);
1517 oleLoanForm.setDialogErrorMessage(OLEConstants.ERROR_MISSING_COUNT_NO_LESS);
1518 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1519 }
1520 if (count > noOfPiece) {
1521 oleLoanForm.setMissingPieceDialog(true);
1522 oleLoanForm.setDialogMissingPieceCountReadOnly(false);
1523 oleLoanForm.setDialogErrorMessage(OLEConstants.ERROR_MISSING_ITEM_GREATER_COUNT);
1524 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1525 }
1526 }
1527
1528 if (oleLoanForm.getMissingPieceLoanDocument() != null && oleLoanForm.getMissingPieceLoanDocument().getItemUuid() != null) {
1529 try {
1530 boolean isMissingPieceFlag = false;
1531 String itemXmlContent = getLoanProcessor().getItemXML(oleLoanForm.getMissingPieceLoanDocument().getItemUuid());
1532 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
1533 if (oleLoanForm.isRemoveMissingPieceFlag()) {
1534 oleItem.setMissingPieceFlag(false);
1535 isMissingPieceFlag = false;
1536 } else {
1537 oleItem.setMissingPieceFlag(true);
1538 isMissingPieceFlag = true;
1539 }
1540 oleItem.setMissingPiecesCount(oleLoanForm.getDialogMissingPieceCount());
1541 oleItem.setNumberOfPieces(oleLoanForm.getDialogItemNoOfPieces());
1542 oleItem.setMissingPieceFlagNote(oleLoanForm.getDialogText());
1543 itemXmlContent = new ItemOlemlRecordProcessor().toXML(oleItem);
1544 if (LOG.isDebugEnabled()) {
1545 LOG.debug("itemXmlContent" + itemXmlContent);
1546 }
1547 org.kuali.ole.docstore.common.document.Item item = new ItemOleml();
1548 item.setContent(itemXmlContent);
1549 item.setCategory(OLEConstants.WORK_CATEGORY);
1550 item.setType(DocType.ITEM.getCode());
1551 item.setFormat(OLEConstants.OLEML_FORMAT);
1552 item.setId(oleLoanForm.getMissingPieceLoanDocument().getItemUuid());
1553 getDocstoreClientLocator().getDocstoreClient().updateItem(item);
1554 if (isMissingPieceFlag) {
1555 oleLoanForm.getMissingPieceLoanDocument().setMissingPieceNote(oleLoanForm.getDialogText());
1556 } else {
1557 oleLoanForm.getMissingPieceLoanDocument().setMissingPieceNote("");
1558 }
1559 oleLoanForm.getMissingPieceLoanDocument().setCheckNo(false);
1560 oleLoanForm.setRemoveMissingPieceFlag(false);
1561 } catch (Exception e) {
1562 LOG.error("Exception occured when updating item" + e);
1563 }
1564 } else {
1565 oleLoanForm.setMissingPieceDialog(true);
1566 oleLoanForm.setErrorMessage("Not updated successfully");
1567
1568 }
1569 oleLoanForm.setMissingPieceDialog(false);
1570 oleLoanForm.setRemoveMissingPieceButton(false);
1571 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1572 }
1573
1574 @RequestMapping(params = "methodToCall=removeMissingPieceFromItem")
1575 public ModelAndView removeMissingPieceFromItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1576 HttpServletRequest request, HttpServletResponse response) {
1577 LOG.debug("Inside the claims return method");
1578 if (loginUserList == null) {
1579 loginUserList = new ArrayList<>();
1580 }
1581 StringBuffer buffer = new StringBuffer();
1582 OleLoanForm oleLoanForm = (OleLoanForm) form;
1583
1584
1585
1586
1587
1588
1589 oleLoanForm.setRemoveMissingPieceFlag(true);
1590 updateMissingPieceItem(form, result, request, response);
1591
1592 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1593 }
1594
1595 @RequestMapping(params = "methodToCall=removeDamagedFlagFromItem")
1596 public ModelAndView removeDamagedFlagFromItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1597 HttpServletRequest request, HttpServletResponse response) {
1598 LOG.debug("Inside the claims return method");
1599 if (loginUserList == null) {
1600 loginUserList = new ArrayList<>();
1601 }
1602 StringBuffer buffer = new StringBuffer();
1603 OleLoanForm oleLoanForm = (OleLoanForm) form;
1604
1605
1606
1607
1608
1609
1610 oleLoanForm.setDialogFlag(false);
1611 updateDamagedItem(form, result, request, response);
1612 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1613 }
1614
1615 @RequestMapping(params = "methodToCall=updateDamagedItem")
1616 public ModelAndView updateDamagedItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1617 HttpServletRequest request, HttpServletResponse response) {
1618 LOG.debug("Inside the claims return method");
1619 if (loginUserList == null) {
1620 loginUserList = new ArrayList<>();
1621 }
1622 StringBuffer buffer = new StringBuffer();
1623 OleLoanForm oleLoanForm = (OleLoanForm) form;
1624
1625
1626
1627
1628
1629
1630 if (oleLoanForm.getLoanList().size() > 0) {
1631 if (oleLoanForm.getLoanList().size() > 0) {
1632 for (OleLoanDocument oleLoanDocument : oleLoanForm.getLoanList()) {
1633 if (oleLoanDocument.isCheckNo()) {
1634 try {
1635 String itemXmlContent = getLoanProcessor().getItemXML(oleLoanDocument.getItemUuid());
1636 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
1637 oleItem.setItemDamagedStatus(oleLoanForm.isDialogFlag());
1638 oleItem.setDamagedItemNote(oleLoanForm.getDialogText());
1639 itemXmlContent = new ItemOlemlRecordProcessor().toXML(oleItem);
1640 if (LOG.isDebugEnabled()) {
1641 LOG.debug("itemXmlContent" + itemXmlContent);
1642 }
1643 org.kuali.ole.docstore.common.document.Item item = new ItemOleml();
1644 item.setContent(itemXmlContent);
1645 item.setCategory(OLEConstants.WORK_CATEGORY);
1646 item.setType(DocType.ITEM.getCode());
1647 item.setFormat(OLEConstants.OLEML_FORMAT);
1648 item.setId(oleLoanDocument.getItemUuid());
1649 getDocstoreClientLocator().getDocstoreClient().updateItem(item);
1650 if (oleLoanForm.isDialogFlag()) {
1651 oleLoanDocument.setItemDamagedNote(oleLoanForm.getDialogText());
1652 } else {
1653 oleLoanDocument.setItemDamagedNote("");
1654 }
1655 oleLoanDocument.setCheckNo(false);
1656 } catch (Exception e) {
1657 throw new RuntimeException();
1658 }
1659 }
1660 }
1661 }
1662 }
1663 if (oleLoanForm.getExistingLoanList().size() > 0) {
1664 for (OleLoanDocument oleLoanDocument : oleLoanForm.getExistingLoanList()) {
1665 if (oleLoanDocument.isCheckNo()) {
1666 try {
1667 String itemXmlContent = getLoanProcessor().getItemXML(oleLoanDocument.getItemUuid());
1668 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
1669 oleItem.setItemDamagedStatus(oleLoanForm.isDialogFlag());
1670 oleItem.setDamagedItemNote(oleLoanForm.getDialogText());
1671 itemXmlContent = new ItemOlemlRecordProcessor().toXML(oleItem);
1672 if (LOG.isDebugEnabled()) {
1673 LOG.debug("itemXmlContent" + itemXmlContent);
1674 }
1675 org.kuali.ole.docstore.common.document.Item item = new ItemOleml();
1676 item.setContent(itemXmlContent);
1677 item.setCategory(OLEConstants.WORK_CATEGORY);
1678 item.setType(DocType.ITEM.getCode());
1679 item.setFormat(OLEConstants.OLEML_FORMAT);
1680 item.setId(oleLoanDocument.getItemUuid());
1681 getDocstoreClientLocator().getDocstoreClient().updateItem(item);
1682 if (oleLoanForm.isDialogFlag()) {
1683 oleLoanDocument.setItemDamagedNote(oleLoanForm.getDialogText());
1684 } else {
1685 oleLoanDocument.setItemDamagedNote("");
1686 }
1687 oleLoanDocument.setCheckNo(false);
1688 } catch (Exception e) {
1689 throw new RuntimeException();
1690 }
1691 }
1692 }
1693
1694 }
1695 oleLoanForm.setRemoveItemDamagedButton(false);
1696 oleLoanForm.setMissingPieceDialog(false);
1697 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1698 }
1699
1700
1701 @RequestMapping(params = "methodToCall=showDamagedDialogBox")
1702 public ModelAndView showDamagedDialogBox(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1703 HttpServletRequest request, HttpServletResponse response) {
1704
1705 LOG.debug("Inside the apply claims return method");
1706 OleLoanForm oleLoanForm = (OleLoanForm) form;
1707
1708
1709
1710
1711
1712
1713 int count = 0;
1714 oleLoanForm.setDialogFlag(false);
1715 oleLoanForm.setDialogItemNoOfPieces(null);
1716 oleLoanForm.setDialogMissingPieceCount(null);
1717 oleLoanForm.setDialogText(null);
1718 oleLoanForm.setDialogItemNoOfPiecesReadOnly(false);
1719 oleLoanForm.setDialogMissingPieceCountReadOnly(false);
1720 oleLoanForm.setDialogErrorMessage(null);
1721 oleLoanForm.setInformation("");
1722 oleLoanForm.setSuccessInfo("");
1723 oleLoanForm.setRemoveItemDamagedButton(false);
1724 OleLoanDocument loanDocument = null;
1725 int damagedItemCount=0;
1726 if (oleLoanForm.getLoanList().size() > 0) {
1727 for (OleLoanDocument oleLoanDocument : oleLoanForm.getLoanList()) {
1728 if (oleLoanDocument.isCheckNo()) {
1729 loanDocument = oleLoanDocument;
1730 count++;
1731 if(StringUtils.isNotEmpty(loanDocument.getItemDamagedNote())){
1732 damagedItemCount++;
1733 }
1734 }
1735 }
1736 }
1737 if (oleLoanForm.getExistingLoanList().size() > 0) {
1738 for (OleLoanDocument oleLoanDocument : oleLoanForm.getExistingLoanList()) {
1739 if (oleLoanDocument.isCheckNo()) {
1740 loanDocument = oleLoanDocument;
1741 count++;
1742 if(StringUtils.isNotEmpty(loanDocument.getItemDamagedNote())){
1743 damagedItemCount++;
1744 }
1745 }
1746 }
1747 }
1748 if (count > 0) {
1749 oleLoanForm.setDamagedItemDialog(true);
1750 oleLoanForm.setDialogFlag(true);
1751 if(damagedItemCount>0){
1752 oleLoanForm.setRemoveItemDamagedButton(true);
1753 }
1754 if (count == 1 && loanDocument != null && loanDocument.getItemUuid() != null) {
1755 try {
1756 String itemXmlContent = getLoanProcessor().getItemXML(loanDocument.getItemUuid());
1757 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
1758 if (oleItem != null) {
1759 oleLoanForm.setDialogText(oleItem.getDamagedItemNote());
1760 }
1761 } catch (Exception e) {
1762 if (LOG.isDebugEnabled()) {
1763 LOG.error("while retrieving item damaged status info error" + e);
1764 }
1765 }
1766 }
1767 } else {
1768 oleLoanForm.setDamagedItemDialog(false);
1769 oleLoanForm.setInformation(OLEConstants.CLAIMS_ITM_ERR_INFO);
1770 }
1771 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1772 }
1773
1774 @RequestMapping(params = "methodToCall=deactivateAllDialogs")
1775 public ModelAndView deactivateAllDialogs(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1776 HttpServletRequest request, HttpServletResponse response) {
1777
1778 LOG.debug("Inside the apply claims return method");
1779 OleLoanForm oleLoanForm = (OleLoanForm) form;
1780
1781
1782
1783
1784
1785
1786
1787 oleLoanForm.setDialogFlag(false);
1788 oleLoanForm.setDialogItemNoOfPieces(null);
1789 oleLoanForm.setDialogMissingPieceCount(null);
1790 oleLoanForm.setDialogText(null);
1791 oleLoanForm.setDialogItemNoOfPiecesReadOnly(false);
1792 oleLoanForm.setDialogMissingPieceCountReadOnly(false);
1793 oleLoanForm.setDialogErrorMessage(null);
1794 oleLoanForm.setMissingPieceDialog(false);
1795 oleLoanForm.setDamagedItemDialog(false);
1796 oleLoanForm.setRemoveItemDamagedButton(false);
1797 for(OleLoanDocument loanDocument:oleLoanForm.getLoanList()){
1798 loanDocument.setCheckNo(false);
1799 }
1800 for (OleLoanDocument loanDocument : oleLoanForm.getExistingLoanList()) {
1801 loanDocument.setCheckNo(false);
1802 }
1803 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1804
1805 }
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816 @RequestMapping(params = "methodToCall=changeCirculationDeskLocation")
1817 public ModelAndView changeCirculationDeskLocation(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1818 HttpServletRequest request, HttpServletResponse response) {
1819 LOG.debug("Inside the change circulation desk location method");
1820 OleLoanForm oleLoanForm = (OleLoanForm) form;
1821 oleLoanForm.setConfirmMessage(OLEConstants.CHANGE_LOC_MESS);
1822 oleLoanForm.setChangeLocationFlag(true);
1823
1824
1825
1826
1827
1828
1829
1830
1831 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1832 }
1833
1834 @RequestMapping(params = "methodToCall=changeReturnCirculationDeskLocation")
1835 public ModelAndView changeReturnCirculationDeskLocation(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1836 HttpServletRequest request, HttpServletResponse response) {
1837 LOG.debug("Inside the change circulation desk location method");
1838 OleLoanForm oleLoanForm = (OleLoanForm) form;
1839 oleLoanForm.setConfirmMessage(OLEConstants.CHANGE_LOC_MESS);
1840 oleLoanForm.setChangeLocationFlag(true);
1841 return getUIFModelAndView(oleLoanForm, "ReturnItemViewPage");
1842 }
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853 @RequestMapping(params = "methodToCall=resetLocation")
1854 public ModelAndView resetLocation(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1855 HttpServletRequest request, HttpServletResponse response) {
1856 LOG.debug("Inside the reset location method");
1857 OleLoanForm oleLoanForm = (OleLoanForm) form;
1858 oleLoanForm.setCirculationDesk(oleLoanForm.getPreviousCirculationDesk());
1859 oleLoanForm.setChangeLocationFlag(false);
1860 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
1861 }
1862
1863 @RequestMapping(params = "methodToCall=resetReturnLocation")
1864 public ModelAndView resetReturnLocation(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1865 HttpServletRequest request, HttpServletResponse response) {
1866 LOG.debug("Inside the reset location method");
1867 OleLoanForm oleLoanForm = (OleLoanForm) form;
1868 oleLoanForm.setCirculationDesk(oleLoanForm.getPreviousCirculationDesk());
1869 oleLoanForm.setChangeLocationFlag(false);
1870 return getUIFModelAndView(oleLoanForm, "ReturnItemViewPage");
1871 }
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882 @RequestMapping(params = "methodToCall=saveAndClear")
1883 public ModelAndView clearPatron(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1884 HttpServletRequest request, HttpServletResponse response) {
1885 LOG.debug("Inside the clear patron method");
1886 fastAddBarcode = "";
1887 OleLoanForm oleLoanForm = (OleLoanForm) form;
1888 String currentLocation = oleLoanForm.getCirculationDesk();
1889 oleLoanForm.setPreviousCirculationDesk(currentLocation);
1890 oleLoanForm.setNewPrincipalId("");
1891 oleLoanForm.setAddressVerified(false);
1892 oleLoanForm.setInformation("");
1893 oleLoanForm.setSuccessInfo("");
1894 oleLoanForm.setReturnInformation("");
1895 oleLoanForm.setBorrowerType(null);
1896 oleLoanForm.setPatronBarcode(null);
1897 oleLoanForm.setPatronName(null);
1898 oleLoanForm.setProxyPatronId(null);
1899 oleLoanForm.setRealPatronBarcode(null);
1900 oleLoanForm.setPatronId(null);
1901 oleLoanForm.setRealPatronList(null);
1902 oleLoanForm.setLoanList(null);
1903 oleLoanForm.setDueDateMap(null);
1904 oleLoanForm.setExistingLoanList(null);
1905 oleLoanForm.setDueDateMap(null);
1906 oleLoanForm.setMessage(null);
1907 oleLoanForm.setSuccess(true);
1908 oleLoanForm.setChangeLocationFlag(false);
1909 oleLoanForm.setBlockLoan(false);
1910 oleLoanForm.setItemFocus(false);
1911 oleLoanForm.setSelfCheckOut(false);
1912 oleLoanForm.setCurrentPatronList(null);
1913 oleLoanForm.setPatronFocus(true);
1914 oleLoanForm.setBackGroundCheckIn(false);
1915 oleLoanForm.setRemoveMissingPieceFlag(false);
1916 oleLoanForm.setRecordDamagedItemNote(false);
1917 oleLoanForm.setRecordMissingPieceNote(false);
1918 oleLoanForm.setRecordCheckoutMissingPieceNote(false);
1919 oleLoanForm.setDisplayRecordNotePopup(false);
1920 oleLoanForm.setCheckoutRecordFlag(false);
1921 oleLoanForm.setSkipMissingPieceRecordPopup(false);
1922 oleLoanForm.setSkipDamagedRecordPopup(false);
1923 oleLoanForm.setDisplayMissingPieceNotePopup(false);
1924 oleLoanForm.setCheckoutMissingPieceRecordFlag(false);
1925 oleLoanForm.setDisplayDamagedRecordNotePopup(false);
1926 oleLoanForm.setCheckoutDamagedRecordFlag(false);
1927 oleLoanForm.setPatronbill(false);
1928 GlobalVariables.getUserSession().clearBackdoorUser();
1929 GlobalVariables.getUserSession().setBackdoorUser(oleLoanForm.getOldPrincipalId());
1930 oleLoanForm.setNewPrincipalId(null);
1931
1932 if (!oleLoanForm.isClearUI()) {
1933 String principalId = GlobalVariables.getUserSession().getPrincipalId();
1934 OleCirculationDeskDetail oleCirculationDeskDetail = getLoanProcessor().getDefaultCirculationDesk(principalId);
1935 if (oleCirculationDeskDetail != null) {
1936 oleLoanForm.setCirculationDesk(oleCirculationDeskDetail.getCirculationDeskId());
1937 oleLoanForm.setPreviousCirculationDesk(oleLoanForm.getCirculationDesk());
1938 }
1939 }
1940 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
1941
1942 }
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953 @RequestMapping(params = "methodToCall=clearPatron")
1954 public ModelAndView clearPatronScreen(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
1955 HttpServletRequest request, HttpServletResponse response) {
1956 LOG.debug("Inside the clear patron Screen method");
1957 fastAddBarcode = "";
1958 OleLoanForm oleLoanForm = (OleLoanForm) form;
1959 String currentLocation = oleLoanForm.getCirculationDesk();
1960 oleLoanForm.setPreviousCirculationDesk(currentLocation);
1961 if (oleLoanForm.getLoanList() != null && oleLoanForm.getLoanList().size() > 0 && !oleLoanForm.isChangeLocationFlag() && getLoanProcessor().getParameter(OLEConstants.PRINT_DUE_DATE_PER_TRANSACTION).equalsIgnoreCase("No")) {
1962 oleLoanForm.setDueDateSlip(true);
1963 printDueDateSlipList = oleLoanForm.getLoanList();
1964 }
1965
1966 oleLoanForm.setAddressVerified(false);
1967 oleLoanForm.setInformation("");
1968 oleLoanForm.setSuccessInfo("");
1969 oleLoanForm.setReturnInformation("");
1970 oleLoanForm.setBorrowerType(null);
1971 oleLoanForm.setPatronBarcode(null);
1972 oleLoanForm.setPatronName(null);
1973 oleLoanForm.setProxyPatronId(null);
1974 oleLoanForm.setRealPatronBarcode(null);
1975 oleLoanForm.setPatronId(null);
1976 oleLoanForm.setRealPatronList(null);
1977 oleLoanForm.setLoanList(null);
1978 oleLoanForm.setDueDateMap(null);
1979 oleLoanForm.setExistingLoanList(null);
1980 oleLoanForm.setDueDateMap(null);
1981 oleLoanForm.setMessage(null);
1982 oleLoanForm.setSuccess(true);
1983 oleLoanForm.setChangeLocationFlag(false);
1984
1985 oleLoanForm.setBlockLoan(false);
1986 oleLoanForm.setItemFocus(false);
1987 oleLoanForm.setSelfCheckOut(false);
1988 oleLoanForm.setCurrentPatronList(null);
1989 oleLoanForm.setPatronFocus(true);
1990 oleLoanForm.setBackGroundCheckIn(false);
1991 oleLoanForm.setRemoveMissingPieceFlag(false);
1992 oleLoanForm.setRecordDamagedItemNote(false);
1993 oleLoanForm.setRecordMissingPieceNote(false);
1994 oleLoanForm.setRecordCheckoutMissingPieceNote(false);
1995 oleLoanForm.setDisplayRecordNotePopup(false);
1996 oleLoanForm.setCheckoutRecordFlag(false);
1997 oleLoanForm.setSkipMissingPieceRecordPopup(false);
1998 oleLoanForm.setSkipDamagedRecordPopup(false);
1999 oleLoanForm.setDisplayMissingPieceNotePopup(false);
2000 oleLoanForm.setCheckoutMissingPieceRecordFlag(false);
2001 oleLoanForm.setDisplayDamagedRecordNotePopup(false);
2002 oleLoanForm.setCheckoutDamagedRecordFlag(false);
2003 oleLoanForm.setPatronbill(false);
2004 oleLoanForm.setSuccessMessage(null);
2005
2006
2007
2008
2009 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2010
2011 }
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022 @RequestMapping(params = "methodToCall=overRide")
2023 public ModelAndView overRide(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2024 HttpServletRequest request, HttpServletResponse response) {
2025 LOG.debug("Inside the override method");
2026 OleLoanForm oleLoanForm = (OleLoanForm) form;
2027
2028
2029
2030
2031
2032
2033 oleLoanForm.setInformation("");
2034 oleLoanForm.setSuccessInfo("");
2035 oleLoanForm.setReturnInformation("");
2036 oleLoanForm.setOverideMethodCall(oleLoanForm.getMethodToCall());
2037 oleLoanForm.setOverrideFlag(true);
2038 String principalId = GlobalVariables.getUserSession().getPrincipalId();
2039 boolean newPrincipalFlag = false;
2040 if (oleLoanForm.getNewPrincipalId() != null && !oleLoanForm.getNewPrincipalId().trim().isEmpty()) {
2041 principalId = oleLoanForm.getNewPrincipalId();
2042 newPrincipalFlag = true;
2043 }
2044 Boolean overRideFlag = getLoanProcessor().checkOverRidePermission(principalId, oleLoanForm);
2045 if (overRideFlag) {
2046 if ((!"".equals(oleLoanForm.getNewPrincipalId()) && oleLoanForm.getNewPrincipalId() != null)) {
2047 oleLoanForm.setLoanLoginName(oleLoanForm.getNewPrincipalId());
2048 GlobalVariables.getUserSession().setBackdoorUser(oleLoanForm.getNewPrincipalId());
2049 oleLoanForm.getDummyLoan().setLoanApproverId(GlobalVariables.getUserSession().getPerson().getEntityId());
2050 }
2051 if (!newPrincipalFlag) {
2052 oleLoanForm.setLoanLoginName(principalId);
2053 GlobalVariables.getUserSession().setBackdoorUser(principalId);
2054 oleLoanForm.getDummyLoan().setLoanApproverId(GlobalVariables.getUserSession().getPerson().getEntityId());
2055 }
2056 oleLoanForm.setNewPrincipalId("");
2057 oleLoanForm.setOverrideFlag(false);
2058 oleLoanForm.setOverideMethodCall("");
2059 return null;
2060 }
2061 oleLoanForm.setNewPrincipalId(null);
2062 GlobalVariables.getUserSession().clearBackdoorUser();
2063 if (!"".equals(oleLoanForm.getNewPrincipalId())) {
2064 oleLoanForm.setOverrideLoginMessage(principalId + " " + OLEConstants.OVERRIDE_LOGIN_ERR_INFO + OLEConstants.BREAK + oleLoanForm.getOverrideErrorMessage());
2065 oleLoanForm.setOverrideErrorMessage(null);
2066 }
2067
2068 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2069 }
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080 @RequestMapping(params = "methodToCall=loanLogin")
2081 public ModelAndView loanLogin(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2082 HttpServletRequest request, HttpServletResponse response) {
2083 LOG.debug("Inside the loanLogin method");
2084 OleLoanForm oleLoanForm = (OleLoanForm) form;
2085 if (loginUserList == null) {
2086 loginUserList = new ArrayList<>();
2087 }
2088 oleLoanForm.setValidLogin(getLoanProcessor().isAuthorized(oleLoanForm.getLoanLoginName()));
2089 String patronNameURL = getLoanProcessor().patronNameURL(oleLoanForm.getLoanLoginName(), oleLoanForm.getPatronId());
2090 oleLoanForm.setPatronNameURL(patronNameURL);
2091 if (oleLoanForm.getLoanLoginName() != null && !oleLoanForm.getLoanLoginName().trim().isEmpty() && oleLoanForm.isValidLogin()) {
2092 oleLoanForm.setLoanLoginUserInfo("");
2093 oleLoanForm.setLoanLoginMessage(false);
2094 String loginUser = GlobalVariables.getUserSession().getPrincipalName();
2095 String circulationDesk = oleLoanForm.getCirculationDesk();
2096 GlobalVariables.getUserSession().setBackdoorUser(oleLoanForm.getLoanLoginName());
2097 start(form, result, request, response);
2098 if (getLoanProcessor().getCircDeskId() != null) {
2099 oleLoanForm.setCirculationDesk(getLoanProcessor().getCircDeskId());
2100 }
2101 StringBuffer users = new StringBuffer();
2102 users.append(loginUser + "," + circulationDesk);
2103 loginUserList.add(users.toString());
2104 }
2105 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2106 }
2107
2108 @RequestMapping(params = "methodToCall=loanLogout")
2109 public ModelAndView loanLogout(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2110 HttpServletRequest request, HttpServletResponse response) {
2111 LOG.debug("Inside the loanLogout method");
2112 int count;
2113 OleLoanForm oleLoanForm = (OleLoanForm) form;
2114 if (oleLoanForm.getOldPrincipalId() != null && !oleLoanForm.getOldPrincipalId().trim().isEmpty()) {
2115 oleLoanForm.setLoanLoginUserInfo("");
2116 oleLoanForm.setLoanLoginMessage(false);
2117 if (loginUserList == null) {
2118 GlobalVariables.getUserSession().setBackdoorUser(null);
2119 return cancel(form, result, request, response);
2120 }
2121 if (loginUserList.size() > 0) {
2122 count = loginUserList.size() - 1;
2123 String usersList = loginUserList.get(count);
2124 loginUserList.remove(count);
2125 String user = GlobalVariables.getUserSession().getPrincipalName();
2126 String circulationId = oleLoanForm.getCirculationDesk();
2127 StringBuffer currentUser = new StringBuffer();
2128 currentUser.append(user + "," + circulationId);
2129 if (usersList.equalsIgnoreCase(currentUser.toString())) {
2130 if (loginUserList.size() > 0) {
2131 int size = loginUserList.size() - 1;
2132 usersList = loginUserList.get(size);
2133 loginUserList.remove(size);
2134 } else {
2135 GlobalVariables.getUserSession().setBackdoorUser(null);
2136 return cancel(form, result, request, response);
2137 }
2138 }
2139 if (usersList == "" || usersList.isEmpty()) {
2140 GlobalVariables.getUserSession().setBackdoorUser(null);
2141 return cancel(form, result, request, response);
2142 }
2143 String[] usersAndCirculationId = usersList.split(",");
2144 oleLoanForm.setLoginUser(usersAndCirculationId[0]);
2145 String patronNameURL = getLoanProcessor().patronNameURL(oleLoanForm.getLoginUser(), oleLoanForm.getPatronId());
2146 oleLoanForm.setPatronNameURL(patronNameURL);
2147 if (oleLoanForm.getLoginUser().equalsIgnoreCase(OLEConstants.ADMIN_USER)) {
2148 GlobalVariables.getUserSession().setBackdoorUser(null);
2149 return cancel(form, result, request, response);
2150 }
2151 GlobalVariables.getUserSession().setBackdoorUser(oleLoanForm.getLoginUser());
2152 start(form, result, request, response);
2153 oleLoanForm.setCirculationDesk(usersAndCirculationId[1]);
2154 } else {
2155 GlobalVariables.getUserSession().setBackdoorUser(null);
2156 return cancel(form, result, request, response);
2157 }
2158 }
2159 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2160 }
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171 @RequestMapping(params = "methodToCall=noOverRide")
2172 public ModelAndView noOverRide(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2173 HttpServletRequest request, HttpServletResponse response) {
2174 LOG.debug("Inside the no override method");
2175 OleLoanForm oleLoanForm = (OleLoanForm) form;
2176
2177
2178
2179
2180
2181
2182 oleLoanForm.setOverrideFlag(false);
2183 oleLoanForm.setOverideMethodCall("");
2184 oleLoanForm.setOverrideLoginMessage("");
2185 oleLoanForm.setInformation("");
2186 oleLoanForm.setSuccessInfo("");
2187 oleLoanForm.setReturnInformation("");
2188 oleLoanForm.setNewPrincipalId(null);
2189
2190 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2191 }
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202 @RequestMapping(params = "methodToCall=renewalItem")
2203 public ModelAndView renewalItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2204 HttpServletRequest request, HttpServletResponse response) {
2205 LOG.debug("Inside the renewal item method");
2206 OleLoanForm oleLoanForm = (OleLoanForm) form;
2207 int renewCurrentCount = 0;
2208 oleLoanForm.setInformation("");
2209 oleLoanForm.setSuccessInfo("");
2210 oleLoanForm.setMessage("");
2211 oleLoanForm.setRenewalFlag(false);
2212 List<OleLoanDocument> existingItemList = new ArrayList<OleLoanDocument>();
2213 existingItemList.addAll(oleLoanForm.getExistingLoanList());
2214 if (oleLoanForm.getLoanList() != null && !oleLoanForm.getLoanList().isEmpty())
2215 existingItemList.addAll(oleLoanForm.getLoanList());
2216 OleLoanDocument oleLoanDocument = null;
2217 for (int i = 0; i < existingItemList.size(); i++) {
2218 OleLoanDocument loanDocument = existingItemList.get(i);
2219 if (loanDocument.getItemId().equals(oleLoanForm.getItem())) {
2220 oleLoanDocument = loanDocument;
2221 oleLoanDocument.setRenewalItemFlag(true);
2222 oleLoanDocument.setErrorMessage(null);
2223 renewCurrentCount = i;
2224 break;
2225 }
2226 }
2227 if (!oleLoanForm.isOverrideRenewal()) {
2228
2229
2230 try {
2231 oleLoanDocument.setPatronId(oleLoanForm.getPatronId());
2232 oleLoanDocument.setBorrowerTypeId(oleLoanForm.getBorrowerTypeId());
2233 oleLoanDocument.setBorrowerTypeName(oleLoanForm.getBorrowerType());
2234 oleLoanDocument.setBorrowerTypeCode(oleLoanForm.getBorrowerCode());
2235 oleLoanDocument.setCirculationLocationId(oleLoanForm.getCirculationDesk());
2236 oleLoanDocument = getLoanProcessor().addLoan(oleLoanDocument.getPatronBarcode(), oleLoanDocument.getItemId(), oleLoanDocument, oleLoanForm.getExistingLoanList(), null);
2237 if (oleLoanDocument.getErrorMessage() == null) {
2238 oleLoanForm.setRenewalFlag(false);
2239 oleLoanForm.setOverrideRenewItemFlag(false);
2240 oleLoanForm.setSuccess(true);
2241 oleLoanForm.setMessage("");
2242
2243 if (oleLoanForm.getExistingLoanList() != null && oleLoanForm.getExistingLoanList().size() > 0) {
2244
2245 for (int i = 0; i < oleLoanForm.getExistingLoanList().size(); i++) {
2246 if ((oleLoanForm.getExistingLoanList().get(i).getItemId()).equalsIgnoreCase(oleLoanDocument.getItemId())) {
2247 oleLoanForm.getExistingLoanList().remove(i);
2248 break;
2249 }
2250 }
2251 }
2252 if (oleLoanForm.getLoanList() != null && oleLoanForm.getLoanList().size() > 0) {
2253 for (int i = 0; i < oleLoanForm.getLoanList().size(); i++) {
2254 if ((oleLoanForm.getLoanList().get(i).getItemId()).equalsIgnoreCase(oleLoanDocument.getItemId())) {
2255 oleLoanForm.getLoanList().remove(i);
2256 break;
2257 }
2258 }
2259 }
2260 oleLoanForm.setOleLoanDocumentToLoanList(oleLoanDocument);
2261 oleLoanForm.setRenewPermission(oleLoanDocument.isRenewPermission());
2262 oleLoanForm.setSuccessInfo(OLEConstants.RENEWAL_ITM_SUCCESS_INFO);
2263 } else {
2264 if (!oleLoanForm.isOverrideRenewal())
2265 oleLoanForm.setOverrideRenewal(true);
2266 oleLoanForm.setOverrideRenewItemFlag(true);
2267
2268
2269
2270 oleLoanForm.setRenewPermission(oleLoanDocument.isRenewPermission());
2271 String errMsg = oleLoanDocument.getErrorMessage().substring(0, oleLoanDocument.getErrorMessage().lastIndexOf("(OR)"));
2272 if(getLoanProcessor().checkPendingRequestforItem(oleLoanDocument.getItemUuid())){
2273 PermissionService service = KimApiServiceLocator.getPermissionService();
2274 boolean hasPermission = service.hasPermission(GlobalVariables.getUserSession().getPrincipalId(),OLEConstants.DLVR_NMSPC,OLEConstants.PENDING_RQST_RENEWAL_ITM_INFO);
2275 oleLoanForm.setOverrideRenewItemFlag(true);
2276 oleLoanForm.setRenewalFlag(true);
2277 if (hasPermission) {
2278 oleLoanForm.setRenewalFlag(false);
2279 oleLoanForm.setRenewPermission(true);
2280 }
2281 }
2282 oleLoanForm.setMessage(errMsg);
2283 }
2284
2285 } catch (Exception e) {
2286 oleLoanForm.setInformation(e.getMessage());
2287 LOG.error("Exception", e);
2288 }
2289 } else {
2290 try {
2291 ModelAndView overrideModelView = this.overRide(form, result, request, response);
2292
2293
2294 if (overrideModelView == null) {
2295 getLoanProcessor().overrideSaveLoanForRenewal(oleLoanDocument);
2296
2297 if (oleLoanForm.getExistingLoanList() != null && oleLoanForm.getExistingLoanList().size() > 0) {
2298
2299 for (int i = 0; i < oleLoanForm.getExistingLoanList().size(); i++) {
2300 if ((oleLoanForm.getExistingLoanList().get(i).getItemId()).equalsIgnoreCase(oleLoanDocument.getItemId())) {
2301 oleLoanForm.getExistingLoanList().remove(i);
2302 break;
2303 }
2304 }
2305 }
2306 if (oleLoanForm.getLoanList() != null && oleLoanForm.getLoanList().size() > 0) {
2307 for (int i = 0; i < oleLoanForm.getLoanList().size(); i++) {
2308 if ((oleLoanForm.getLoanList().get(i).getItemId()).equalsIgnoreCase(oleLoanDocument.getItemId())) {
2309 oleLoanForm.getLoanList().remove(i);
2310 break;
2311 }
2312 }
2313 }
2314 oleLoanForm.setOleLoanDocumentToLoanList(oleLoanDocument);
2315 oleLoanForm.setMessage("");
2316 oleLoanForm.setSuccess(true);
2317 oleLoanForm.setOverrideRenewal(false);
2318 oleLoanForm.setRenewalFlag(false);
2319 oleLoanForm.setOverrideRenewItemFlag(false);
2320 oleLoanForm.setSuccessInfo(OLEConstants.RENEWAL_ITM_SUCCESS_INFO);
2321 }
2322
2323
2324 } catch (Exception e) {
2325 LOG.error("Exception", e);
2326 oleLoanForm.setInformation(e.getMessage());
2327 }
2328
2329 }
2330
2331 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
2332 }
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343 @RequestMapping(params = "methodToCall=doNotRenewalItem")
2344 public ModelAndView doNotRenewalItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2345 HttpServletRequest request, HttpServletResponse response) {
2346 LOG.debug("Inside the do not renewal item method");
2347 OleLoanForm oleLoanForm = (OleLoanForm) form;
2348 oleLoanForm.setInformation("");
2349 oleLoanForm.setSuccessInfo("");
2350 oleLoanForm.setReturnInformation("");
2351 oleLoanForm.setRenewalFlag(false);
2352 oleLoanForm.setSuccess(true);
2353 oleLoanForm.setMessage("");
2354 oleLoanForm.setOverrideRenewal(false);
2355 oleLoanForm.setRenewDueDateFlag(false);
2356 oleLoanForm.setOverrideRenewItemFlag(false);
2357 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
2358 }
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369 @RequestMapping(params = "methodToCall=renewalItems")
2370 public ModelAndView renewalItems(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2371 HttpServletRequest request, HttpServletResponse response) {
2372 LOG.debug("Inside the renewal items method");
2373 OleLoanForm oleLoanForm = (OleLoanForm) form;
2374 oleLoanForm.setInformation("");
2375 oleLoanForm.setSuccessInfo("");
2376 oleLoanForm.setMessage("");
2377
2378 List<OleLoanDocument> existingItemList = new ArrayList<OleLoanDocument>(0);
2379 List<OleLoanDocument> renewalItemList = new ArrayList<OleLoanDocument>(0);
2380 existingItemList.addAll(oleLoanForm.getExistingLoanList());
2381 existingItemList.addAll(oleLoanForm.getLoanList());
2382 boolean renewSelectFlag = true;
2383 for (int i = 0; i < existingItemList.size(); i++) {
2384 OleLoanDocument loanDocument = existingItemList.get(i);
2385 if (loanDocument.isCheckNo()) {
2386 renewSelectFlag = false;
2387 break;
2388 }
2389 }
2390 if (!renewSelectFlag) {
2391 String errMsg = "";
2392 for (int i = 0; i < existingItemList.size(); i++) {
2393 OleLoanDocument loanDocument = existingItemList.get(i);
2394 loanDocument.setErrorMessage(null);
2395 if (loanDocument.isCheckNo()) {
2396 renewSelectFlag = false;
2397 loanDocument.setCheckNo(false);
2398
2399 try {
2400 loanDocument.setPatronId(oleLoanForm.getPatronId());
2401 loanDocument.setBorrowerTypeId(oleLoanForm.getBorrowerTypeId());
2402 loanDocument.setBorrowerTypeName(oleLoanForm.getBorrowerType());
2403 loanDocument.setBorrowerTypeCode(oleLoanForm.getBorrowerCode());
2404 loanDocument.setRenewalItemFlag(true);
2405 loanDocument.setCirculationLocationId(oleLoanForm.getCirculationDesk());
2406 loanDocument = getLoanProcessor().addLoan(loanDocument.getPatronBarcode(), loanDocument.getItemId(), loanDocument, oleLoanForm.getExistingLoanList(), null);
2407
2408
2409
2410
2411
2412
2413 if (loanDocument.getErrorMessage() == null) {
2414 errMsg = errMsg + (i + 1) + ". " + OLEConstants.RENEWAL_ITM_SUCCESS_INFO + " (" + loanDocument.getItemId() + ")<br/>";
2415
2416 if (oleLoanForm.getExistingLoanList() != null && oleLoanForm.getExistingLoanList().size() > 0) {
2417
2418 for (int existingList = 0; existingList < oleLoanForm.getExistingLoanList().size(); existingList++) {
2419 if ((oleLoanForm.getExistingLoanList().get(existingList).getItemId()).equalsIgnoreCase(loanDocument.getItemId())) {
2420 oleLoanForm.getExistingLoanList().remove(existingList);
2421 break;
2422 }
2423 }
2424 }
2425 if (oleLoanForm.getLoanList()!=null && oleLoanForm.getLoanList().size()>0){
2426 for (int loanList = 0; loanList < oleLoanForm.getLoanList().size(); loanList++) {
2427 if ((oleLoanForm.getLoanList().get(loanList).getItemId()).equalsIgnoreCase(loanDocument.getItemId())) {
2428 oleLoanForm.getLoanList().remove(loanList);
2429 break;
2430 }
2431 }
2432 }
2433 oleLoanForm.setOleLoanDocumentToLoanList(loanDocument);
2434 } else {
2435 if (getLoanProcessor().checkPendingRequestforItem(loanDocument.getItemUuid())){
2436 PermissionService service = KimApiServiceLocator.getPermissionService();
2437 boolean hasPermission = service.hasPermission(GlobalVariables.getUserSession().getPrincipalId(),OLEConstants.DLVR_NMSPC,OLEConstants.PENDING_RQST_RENEWAL_ITM_INFO);
2438 if (!hasPermission){
2439 loanDocument.setRenewPermissionForRequestedItem(true);
2440 }
2441 }
2442 loanDocument.setErrorMessage(loanDocument.getErrorMessage().substring(0, loanDocument.getErrorMessage().lastIndexOf("(OR)")));
2443 oleLoanForm.setRenewDueDateFlag(true);
2444 renewalItemList.add(loanDocument);
2445 oleLoanForm.setRenewDueDateList(renewalItemList);
2446 }
2447 } catch (Exception e) {
2448 LOG.error("Exception", e);
2449 }
2450
2451 }
2452 }
2453 if (errMsg!="")
2454 oleLoanForm.setSuccessInfo(errMsg);
2455 }
2456 if (renewSelectFlag)
2457 oleLoanForm.setInformation(OLEConstants.RENEWAL_ITM_ERR_INFO);
2458
2459 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
2460 }
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472 @RequestMapping(params = "methodToCall=overrideRenewItems")
2473 public ModelAndView overrideRenewItems(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2474 HttpServletRequest request, HttpServletResponse response) {
2475 LOG.debug("Inside the renewal items method");
2476 OleLoanForm oleLoanForm = (OleLoanForm) form;
2477 oleLoanForm.setMessage("");
2478 String info = oleLoanForm.getSuccessInfo()!=null ? oleLoanForm.getSuccessInfo() : "";
2479 List<OleLoanDocument> renewItemList = new ArrayList<OleLoanDocument>(0);
2480 renewItemList.addAll(oleLoanForm.getRenewDueDateList());
2481 try {
2482 boolean renewSelectFlag = true;
2483 for (int i = 0; i < renewItemList.size(); i++) {
2484 OleLoanDocument loanDocument = renewItemList.get(i);
2485 if (loanDocument.isRenewCheckNo()) {
2486 renewSelectFlag = false;
2487 break;
2488 }
2489 }
2490 if (!renewSelectFlag) {
2491 ModelAndView overrideModelView = this.overRide(form, result, request, response);
2492 if (overrideModelView == null) {
2493
2494 for (int i = 0; i < renewItemList.size(); i++) {
2495 OleLoanDocument loanDocument = renewItemList.get(i);
2496
2497 loanDocument.setErrorMessage(null);
2498 Timestamp currentDate = new Timestamp(System.currentTimeMillis());
2499 if (loanDocument.isRenewCheckNo()) {
2500 loanDocument.setRenewCheckNo(false);
2501
2502 getLoanProcessor().overrideSaveLoanForRenewal(loanDocument);
2503 loanDocument.setErrorMessage(OLEConstants.RENEWAL_ITM_SUCCESS_INFO);
2504 for (int j = 0; j < oleLoanForm.getExistingLoanList().size(); j++) {
2505 if (loanDocument.getLoanId().equals(oleLoanForm.getExistingLoanList().get(j).getLoanId())) {
2506 oleLoanForm.getExistingLoanList().remove(j);
2507 oleLoanForm.setOleLoanDocumentToLoanList(loanDocument);
2508 }
2509 }
2510 oleLoanForm.setMessage("");
2511 oleLoanForm.setSuccess(true);
2512 oleLoanForm.setOverrideRenewal(false);
2513 info = info + (i + 1) + ". " + OLEConstants.RENEWAL_ITM_SUCCESS_INFO + " (" + loanDocument.getItemId() + ")<br/>";
2514
2515
2516
2517 }
2518
2519 oleLoanForm.setOverrideRenewItemFlag(false);
2520 }
2521
2522 }
2523 }
2524 if (info!=""){
2525 oleLoanForm.setSuccessInfo(info);
2526 }
2527 } catch (Exception e) {
2528 LOG.error("Exception ---> " + e, e);
2529 }
2530 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
2531 }
2532
2533
2534
2535
2536
2537
2538
2539 private LoanProcessor getLoanProcessor() {
2540 if (loanProcessor == null) {
2541 loanProcessor = SpringContext.getBean(LoanProcessor.class);
2542 }
2543 return loanProcessor;
2544 }
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555 @RequestMapping(params = "methodToCall=validateItem")
2556 public ModelAndView validateItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2557 HttpServletRequest request, HttpServletResponse response) {
2558 if (LOG.isDebugEnabled()) {
2559 LOG.debug(" Inside Validate Item ");
2560 }
2561 OleLoanForm oleLoanForm = (OleLoanForm) form;
2562 oleLoanForm.setRouteToLocation(null);
2563 oleLoanForm.setSuccessMessage(null);
2564
2565
2566
2567 String audioOption = getLoanProcessor().getParameter(OLEConstants.AUDIO_OPTION);
2568 oleLoanForm.setAudioEnable(audioOption != null && !audioOption.isEmpty() && audioOption.equalsIgnoreCase(OLEConstants.TRUE));
2569 oleLoanForm.setOleFormKey(oleLoanForm.getFormKey());
2570 oleLoanForm.setReturnInformation("");
2571 oleLoanForm.setErrorMessage("");
2572 OleLoanDocument oleLoanDocument = null;
2573 if (oleLoanForm.getCheckInItem() != null) {
2574 oleLoanDocument = getLoanProcessor().getOleLoanDocumentUsingItemBarcode(oleLoanForm.getCheckInItem());
2575 } else {
2576 oleLoanDocument = getLoanProcessor().getOleLoanDocumentUsingItemUUID(oleLoanForm.getReturnItemUuid());
2577 }
2578 if (oleLoanDocument == null) {
2579 oleLoanDocument = new OleLoanDocument();
2580 }
2581 Timestamp timestamp;
2582 Pattern pattern;
2583 Matcher matcher;
2584 boolean timeFlag = false;
2585 SimpleDateFormat fmt = new SimpleDateFormat(OLEConstants.OlePatron.PATRON_MAINTENANCE_DATE_FORMAT);
2586 if (oleLoanForm.getCheckInTime() != null && !oleLoanForm.getCheckInTime().isEmpty()) {
2587 String[] str = oleLoanForm.getCheckInTime().split(":");
2588 pattern = Pattern.compile(OLEConstants.TIME_24_HR_PATTERN);
2589 matcher = pattern.matcher(oleLoanForm.getCheckInTime());
2590 timeFlag = matcher.matches();
2591 if (timeFlag) {
2592 if (str != null && str.length <= 2) {
2593 oleLoanForm.setCheckInTime(oleLoanForm.getCheckInTime() + OLEConstants.CHECK_IN_TIME_MS);
2594 }
2595 timestamp = Timestamp.valueOf(new SimpleDateFormat(OLEConstants.CHECK_IN_DATE_TIME_FORMAT).format(oleLoanForm.getCheckInDate()).concat(" ").concat(oleLoanForm.getCheckInTime()));
2596 } else {
2597
2598 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2599 }
2600 } else if (fmt.format(oleLoanForm.getCheckInDate()).compareTo(fmt.format(new Date())) == 0) {
2601 timestamp = new Timestamp(new Date().getTime());
2602 } else {
2603 timestamp = Timestamp.valueOf(new SimpleDateFormat(OLEConstants.CHECK_IN_DATE_TIME_FORMAT).format(oleLoanForm.getCheckInDate()).concat(" ").concat(new SimpleDateFormat("HH:mm:ss").format(new Date())));
2604 }
2605 oleLoanDocument.setCheckInDate(timestamp);
2606 try {
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616 if (!getLoanProcessor().isValidCirculationDesk()) {
2617 oleLoanForm.setLoanLoginUserInfo(GlobalVariables.getUserSession().getPrincipalName() + " " + OLEConstants.OleCirculationDesk.OLE_CIRCULATION_DESK_VALIDATIONS);
2618 return super.start(oleLoanForm, result, request, response);
2619 }
2620 oleLoanDocument.setCirculationLocationId(oleLoanForm.getCirculationDesk());
2621
2622 if (LOG.isDebugEnabled()) {
2623 LOG.debug("Check-in Item Barcode Number --->" + oleLoanForm.getCheckInItem());
2624 }
2625 oleLoanDocument.setItemUuid(oleLoanForm.getReturnItemUuid());
2626 oleLoanForm.getErrorsAndPermission().clear();
2627 oleLoanDocument.setSkipDamagedCheckIn(oleLoanForm.isSkipDamagedCheckIn());
2628 oleLoanDocument = getLoanProcessor().returnLoan(oleLoanForm.getCheckInItem(), oleLoanDocument);
2629 oleLoanForm.setItemDamagedStatus(oleLoanDocument.isItemDamagedStatus());
2630 if (oleLoanDocument.isItemDamagedStatus() && (!oleLoanDocument.isSkipDamagedCheckIn())) {
2631 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2632 } else {
2633 if (oleLoanForm.isRecordDamagedItemNote()) {
2634 saveGeneralNoteForFlaggedItem(OLEConstants.DAMAGED_ITEM_CHECKED_IN_FLAG, true, oleLoanDocument, false, true, false, oleLoanForm.getPatronBarcode());
2635 oleLoanForm.setRecordDamagedItemNote(false);
2636 }
2637 oleLoanForm.setSkipDamagedCheckIn(false);
2638 oleLoanForm.setItemDamagedStatus(false);
2639 }
2640 org.kuali.ole.docstore.common.document.Item item = getDocstoreClientLocator().getDocstoreClient().retrieveItem(oleLoanDocument.getItemUuid());
2641 String itemXmlContent = item.getContent();
2642 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
2643 getLoanProcessor().getLocation(oleItem, oleLoanDocument, item);
2644 if (oleLoanDocument.getLocation() == null || oleLoanDocument.getLocation().isEmpty()) {
2645 getLoanProcessor().getDefaultHoldingLocation(oleLoanDocument);
2646 }
2647 if (oleItem.isClaimsReturnedFlag()) {
2648 oleLoanForm.setDummyLoan(oleLoanDocument);
2649 oleLoanForm.setClaimsReturned(true);
2650 oleLoanForm.setRecordNote(false);
2651 oleLoanForm.setReturnSuccess(false);
2652 oleLoanForm.setReturnMessage(OLEConstants.CLAIMS_RETURNED_MESSAGE);
2653 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2654 }
2655 String requestCheck = oleLoanDocument.getOleDeliverRequestBo() != null ? OLEConstants.REQUEST_EXISTS : "";
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667 oleLoanForm.setDummyLoan(oleLoanDocument);
2668 if (oleLoanDocument.isCopyRequest()) {
2669 oleLoanForm.setCopyRequest(true);
2670 oleLoanForm.setReturnSuccess(false);
2671 oleLoanForm.setReturnMessage(OLEConstants.COPY_REQUEST_FULFILL);
2672 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2673 }
2674 if (oleLoanDocument.isNumberOfPieces()) {
2675 oleLoanForm.setNumberOfPieces(true);
2676 oleLoanForm.setReturnSuccess(false);
2677 if (oleLoanDocument.getOleItem() != null && oleLoanDocument.getOleItem().isMissingPieceFlag()) {
2678 oleLoanForm.setReturnMessage(OLEConstants.VERIFY_PIECES + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.PIECES_RETURNED
2679 + OLEConstants.BREAK + "Total No of Pieces : " + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.BREAK + "No of missing Pieces : " + (oleLoanDocument.getOleItem().getMissingPiecesCount() != null ? oleLoanDocument.getOleItem().getMissingPiecesCount() : "0"));
2680 } else {
2681 oleLoanForm.setReturnMessage(OLEConstants.VERIFY_PIECES + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.PIECES_RETURNED
2682 + OLEConstants.BREAK + "Total No of Pieces : " + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.BREAK + "No of missing Pieces : " + (oleLoanDocument.getOleItem().getMissingPiecesCount() != null ? oleLoanDocument.getOleItem().getMissingPiecesCount() : "0"));
2683 }
2684 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2685 }
2686 String checkInNote = oleLoanDocument.getOleItem().getCheckinNote();
2687 if (checkInNote != null && !checkInNote.isEmpty() && oleLoanForm.getReturnMessage() == null) {
2688 oleLoanForm.setCheckInNote(OLEConstants.CHECK_IN_NOTE_HEADER + checkInNote);
2689 oleLoanForm.setRouteToLocation(oleLoanDocument.getRouteToLocation());
2690 String principalId = GlobalVariables.getUserSession().getPrincipalId();
2691 oleLoanForm.setOkOrRemoveNote(getLoanProcessor().checkPermissionForRemoveNote(principalId));
2692 }
2693 if (!oleLoanDocument.isBackGroundCheckOut() && oleLoanDocument.getErrorMessage() != null) {
2694 oleLoanForm.setReturnSuccess(false);
2695 oleLoanForm.setReturnMessage(oleLoanDocument.getErrorMessage());
2696 } else {
2697 List<OleLoanDocument> oleLoanDocuments = new ArrayList<OleLoanDocument>();
2698 if (!oleLoanDocument.isCheckOut() || oleLoanDocument.getErrorMessage() == null)
2699 oleLoanDocuments.add(oleLoanDocument);
2700 if (oleLoanForm.getItemReturnList() != null) {
2701 oleLoanDocuments.addAll(oleLoanForm.getItemReturnList());
2702 }
2703 oleLoanForm.setItemReturnList(oleLoanDocuments);
2704
2705 oleLoanForm.setExistingLoanList(getLoanProcessor().getPatronLoanedItemBySolr(oleLoanDocument.getPatronId()));
2706 OleLoanDocument tempOleLoanDocumentObj = null;
2707 List<OleLoanDocument> currentSessionList = oleLoanForm.getLoanList() != null ? oleLoanForm.getLoanList() : new ArrayList<OleLoanDocument>();
2708 for (OleLoanDocument currentOleLoanDocument : currentSessionList) {
2709 if (currentOleLoanDocument.getItemId().equals(oleLoanForm.getCheckInItem())) {
2710 tempOleLoanDocumentObj = currentOleLoanDocument;
2711 break;
2712 }
2713 }
2714 currentSessionList.remove(tempOleLoanDocumentObj);
2715 oleLoanForm.setLoanList(currentSessionList);
2716
2717 oleLoanForm.setCheckInItem("");
2718 }
2719 } catch (Exception e) {
2720 LOG.error("Exception in validate Item " + e);
2721 oleLoanForm.setReturnInformation(e.getMessage());
2722 oleLoanForm.setBillAvailability(false);
2723 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2724 }
2725 if (!oleLoanForm.isCheckInNoteExists() && oleLoanForm.getCheckInNote() != null && oleLoanForm.getReturnMessage() == null) {
2726 oleLoanForm.setDummyLoan(oleLoanDocument);
2727 oleLoanForm.setCheckInNoteExists(true);
2728 oleLoanForm.setReturnSuccess(false);
2729 oleLoanForm.setReturnMessage(oleLoanForm.getCheckInNote());
2730 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2731 }
2732 if (oleLoanDocument.isCheckOut() && oleLoanDocument.getErrorMessage() != null && oleLoanForm.getReturnMessage() == null) {
2733 oleLoanForm.setDueDateEmpty(oleLoanDocument.isDueDateEmpty());
2734 oleLoanForm.setDummyLoan(oleLoanDocument);
2735 oleLoanForm.setReturnSuccess(false);
2736 oleLoanForm.setMessage(oleLoanDocument.getErrorMessage());
2737 oleLoanForm.setCheckOut(true);
2738 oleLoanForm.setItem(oleLoanForm.getCheckInItem());
2739 oleLoanForm.setOleItem(oleLoanDocument.getOleItem());
2740 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2741 }
2742 if ((oleLoanForm.getReturnMessage() == null) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
2743 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
2744 OleNoticeBo oleNoticeBo = getLoanProcessor().getNotice(oleLoanDocument);
2745
2746 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
2747
2748 Date date = new Date(oleLoanDocument.getCheckInDate().getTime());
2749 if (oleNoticeBo != null) {
2750 oleNoticeBo.setCheckInDate(dateFormat.format(date));
2751 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
2752 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) {
2753 fromAddress = OLEConstants.KUALI_MAIL;
2754 }
2755 String missingNoticeDetails = getOleDeliverBatchService().sendMissingNotice(oleNoticeBo);
2756 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer");
2757 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(missingNoticeDetails), true);
2758 if (LOG.isInfoEnabled()) {
2759 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress());
2760 }
2761 }
2762 } else {
2763 if (oleLoanDocument.getItemStatusCode() != null && oleLoanDocument.getItemStatusCode().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isHoldQueue()) {
2764 oleLoanForm.setBillAvailability(false);
2765 } else {
2766 oleLoanForm.setBillAvailability(true);
2767 }
2768 }
2769 }
2770 if (oleLoanDocument.isCheckOut()) {
2771 oleLoanForm.setDueDateSlip(true);
2772 oleLoanForm.setBillAvailability(false);
2773 }
2774 if (request != null && !"".equalsIgnoreCase(request.toString())) {
2775 oleLoanForm.setDueDateSlip(false);
2776 }
2777 if (oleLoanDocument.getItemStatus() != null && oleLoanDocument.getItemStatus().equalsIgnoreCase(OLEConstants.ITEM_STATUS_RECENTLY_RETURNED)) {
2778 oleLoanForm.setBillAvailability(false);
2779 oleLoanForm.setDueDateSlip(false);
2780 }
2781 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2782 }
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793 @RequestMapping(params = "methodToCall=returnItem")
2794 public ModelAndView returnItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2795 HttpServletRequest request, HttpServletResponse response) {
2796 if (LOG.isDebugEnabled()) {
2797 LOG.debug(" Inside Return Item ");
2798 }
2799 OleLoanForm oleLoanForm = (OleLoanForm) form;
2800
2801
2802
2803
2804
2805
2806 String audioOption = getLoanProcessor().getParameter(OLEConstants.AUDIO_OPTION);
2807 oleLoanForm.setAudioEnable(audioOption != null && !audioOption.isEmpty() && audioOption.equalsIgnoreCase(OLEConstants.TRUE));
2808 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
2809 String principalId = GlobalVariables.getUserSession().getPrincipalId();
2810 Boolean overRideFlag = getLoanProcessor().checkOverRidePermission(principalId, oleLoanForm);
2811 if (oleLoanForm.getMissingPieceCount() != null) {
2812 oleLoanDocument.setMissingPiecesCount(oleLoanForm.getMissingPieceCount());
2813 }
2814 if (!overRideFlag) {
2815 ModelAndView modelAndView = this.overRide(form, result, request, response);
2816 if (modelAndView != null) {
2817 return modelAndView;
2818 }
2819 }
2820 try {
2821 oleLoanForm.getErrorsAndPermission().clear();
2822 oleLoanDocument = getLoanProcessor().returnLoan(oleLoanDocument);
2823
2824 if (oleLoanDocument.isNumberOfPieces()) {
2825 oleLoanForm.setNumberOfPieces(true);
2826 oleLoanForm.setReturnSuccess(false);
2827
2828 oleLoanForm.setReturnMessage(OLEConstants.VERIFY_PIECES + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.PIECES_RETURNED
2829 + OLEConstants.BREAK + "Total No of Pieces : " + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.BREAK + "No of missing Pieces : " + (oleLoanDocument.getOleItem().getMissingPiecesCount() != null ? oleLoanDocument.getOleItem().getMissingPiecesCount() : "0"));
2830 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2831 }
2832 String checkInNote = oleLoanDocument.getOleItem().getCheckinNote();
2833 if (!oleLoanForm.isBackGroundCheckIn() && checkInNote != null && !checkInNote.isEmpty()) {
2834 oleLoanForm.setNumberOfPieces(false);
2835 oleLoanForm.setCheckInNote(OLEConstants.CHECK_IN_NOTE_HEADER + checkInNote);
2836 oleLoanForm.setRouteToLocation(oleLoanDocument.getRouteToLocation());
2837 oleLoanForm.setOkOrRemoveNote(getLoanProcessor().checkPermissionForRemoveNote(principalId));
2838 }
2839 List<OleLoanDocument> oleLoanDocuments = new ArrayList<OleLoanDocument>();
2840 if (!oleLoanDocument.isCheckOut() || oleLoanDocument.getErrorMessage() == null)
2841 oleLoanDocuments.add(oleLoanDocument);
2842 if (oleLoanForm.getItemReturnList() != null) {
2843 oleLoanDocuments.addAll(oleLoanForm.getItemReturnList());
2844 }
2845 if (!oleLoanForm.isTempClaimsFlag()) {
2846 oleLoanForm.setItemReturnList(oleLoanDocuments);
2847 } else {
2848 oleLoanForm.setTempClaimsFlag(false);
2849 }
2850
2851 } catch (Exception e) {
2852 LOG.error("Exception in return Item " + e, e);
2853 }
2854 oleLoanForm.setReturnSuccess(true);
2855 oleLoanForm.setReturnMessage(null);
2856 oleLoanForm.setCheckInItem("");
2857 oleLoanForm.setReturnInformation("");
2858 if (!oleLoanForm.isCheckInNoteExists() && oleLoanForm.getCheckInNote() != null) {
2859 oleLoanForm.setDummyLoan(oleLoanDocument);
2860 oleLoanForm.setCheckInNoteExists(true);
2861 oleLoanForm.setReturnSuccess(false);
2862 oleLoanForm.setReturnMessage(oleLoanForm.getCheckInNote());
2863 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2864 }
2865 if (oleLoanDocument.isCheckOut() && oleLoanDocument.getErrorMessage() != null) {
2866 oleLoanForm.setDueDateEmpty(oleLoanDocument.isDueDateEmpty());
2867 oleLoanForm.setDummyLoan(oleLoanDocument);
2868 oleLoanForm.setReturnSuccess(false);
2869 oleLoanForm.setMessage(oleLoanDocument.getErrorMessage());
2870 oleLoanForm.setCheckOut(true);
2871 oleLoanForm.setItem(oleLoanForm.getCheckInItem());
2872 oleLoanForm.setOleItem(oleLoanDocument.getOleItem());
2873 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2874 }
2875 if (oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
2876 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
2877 OleNoticeBo oleNoticeBo = getLoanProcessor().getNotice(oleLoanDocument);
2878
2879 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
2880
2881 Date date = new Date(oleLoanDocument.getCheckInDate().getTime());
2882 if (oleNoticeBo != null) {
2883 oleNoticeBo.setCheckInDate(dateFormat.format(date));
2884 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
2885 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) {
2886 fromAddress = OLEConstants.KUALI_MAIL;
2887 }
2888 String missingNoticeDetails = getOleDeliverBatchService().sendMissingNotice(oleNoticeBo);
2889 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer");
2890 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(missingNoticeDetails), true);
2891 if (LOG.isInfoEnabled()) {
2892 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress());
2893 }
2894 }
2895 } else {
2896 if (oleLoanDocument.getItemStatusCode() != null && oleLoanDocument.getItemStatusCode().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isHoldQueue()) {
2897 oleLoanForm.setBillAvailability(false);
2898 } else {
2899 oleLoanForm.setBillAvailability(true);
2900 }
2901 }
2902 }
2903 if (oleLoanDocument.isCheckOut()) {
2904 oleLoanForm.setDueDateSlip(true);
2905 oleLoanForm.setBillAvailability(false);
2906 }
2907 if (oleLoanForm.isBackGroundCheckIn()) {
2908 oleLoanForm.setItem(oleLoanForm.getCheckInItem());
2909 oleLoanForm.setOleItem(oleLoanDocument.getOleItem());
2910 oleLoanDocument.setItemLoanStatus(oleLoanDocument.getItemStatusCode());
2911 loanPatron(oleLoanForm, result, request, response);
2912 }
2913 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2914 }
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925 @RequestMapping(params = "methodToCall=noReturnItem")
2926 public ModelAndView doNotReturnItem(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2927 HttpServletRequest request, HttpServletResponse response) {
2928 if (LOG.isDebugEnabled()) {
2929 LOG.debug(" Inside Do Not Return Item ");
2930 }
2931 OleLoanForm oleLoanForm = (OleLoanForm) form;
2932
2933
2934
2935
2936 oleLoanForm.setReturnInformation("");
2937 oleLoanForm.setCheckInItem("");
2938 oleLoanForm.setReturnMessage(null);
2939 oleLoanForm.setReturnSuccess(true);
2940 oleLoanForm.setCheckInNote(null);
2941 oleLoanForm.setNumberOfPieces(false);
2942 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
2943 if (oleLoanForm.getDummyLoan().isCheckOut() && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
2944 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
2945 OleNoticeBo oleNoticeBo = getLoanProcessor().getNotice(oleLoanDocument);
2946
2947 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
2948 Date date = new Date(oleLoanDocument.getCheckInDate().getTime());
2949 if (oleNoticeBo != null) {
2950 oleNoticeBo.setCheckInDate(dateFormat.format(date));
2951 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
2952 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) {
2953 fromAddress = OLEConstants.KUALI_MAIL;
2954 }
2955 String missingNoticeDetails = getOleDeliverBatchService().sendMissingNotice(oleNoticeBo);
2956 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer");
2957 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(missingNoticeDetails), true);
2958 if (LOG.isInfoEnabled()) {
2959 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress());
2960 }
2961 }
2962 } else {
2963 if (oleLoanDocument.getItemStatusCode() != null && oleLoanDocument.getItemStatusCode().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isHoldQueue()) {
2964 oleLoanForm.setBillAvailability(false);
2965 } else {
2966 oleLoanForm.setBillAvailability(true);
2967 }
2968 }
2969 }
2970 if (oleLoanForm.getDummyLoan() != null && oleLoanForm.getDummyLoan().isCheckOut()) {
2971 oleLoanForm.setDueDateSlip(true);
2972 oleLoanForm.setBillAvailability(false);
2973 }
2974 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
2975 }
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986 @RequestMapping(params = "methodToCall=continueCheckIn")
2987 public ModelAndView continueCheckIn(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
2988 HttpServletRequest request, HttpServletResponse response) {
2989 if (LOG.isDebugEnabled()) {
2990 LOG.debug(" Inside Continue Check-in ");
2991 }
2992 OleLoanForm oleLoanForm = (OleLoanForm) form;
2993
2994
2995
2996
2997
2998 String audioOption = getLoanProcessor().getParameter(OLEConstants.AUDIO_OPTION);
2999 oleLoanForm.setAudioEnable(audioOption != null && !audioOption.isEmpty() && audioOption.equalsIgnoreCase(OLEConstants.TRUE));
3000 String description = oleLoanForm.getDescription();
3001 String matchCheck = oleLoanForm.getMatchCheck();
3002 String copyCheck = oleLoanForm.getCopyCheck();
3003 oleLoanForm.getErrorsAndPermission().clear();
3004 OleLoanDocument oleLoanDocument = new OleLoanDocument();
3005 oleLoanDocument = oleLoanForm.getDummyLoan();
3006 oleLoanDocument.setDescription(oleLoanForm.getDescription());
3007 oleLoanDocument.setMissingPieceNote(oleLoanForm.getMissingPieceNote());
3008 if (oleLoanForm.getMissingPieceCount() != null) {
3009 oleLoanDocument.setMissingPiecesCount(oleLoanForm.getMissingPieceCount());
3010 }
3011 try {
3012 if (copyCheck != null && copyCheck.equalsIgnoreCase(OLEConstants.TRUE)) {
3013 oleLoanForm.setCopyCheck("");
3014 getLoanProcessor().deleteRequestRecord(oleLoanDocument.getOleDeliverRequestBo());
3015 oleLoanDocument = getLoanProcessor().returnLoan(oleLoanDocument);
3016
3017 } else if (copyCheck != null && copyCheck.equalsIgnoreCase(OLEConstants.FALSE)) {
3018 return endCheckInSession(form, result, request, response);
3019 }
3020
3021
3022
3023
3024
3025
3026
3027 String itemUUid = oleLoanDocument.getItemUuid();
3028 org.kuali.ole.docstore.common.document.Item item = new ItemOleml();
3029 item = getDocstoreClientLocator().getDocstoreClient().retrieveItem(itemUUid);
3030 String itemXmlContent = item.getContent();
3031 Item oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
3032 getLoanProcessor().getLocation(oleItem, oleLoanDocument, item);
3033 if (oleLoanDocument.getLocation() == null || oleLoanDocument.getLocation().isEmpty()) {
3034 getLoanProcessor().getDefaultHoldingLocation(oleLoanDocument);
3035 }
3036 org.kuali.ole.docstore.common.document.Item itemXml = new ItemOleml();
3037 boolean claimsFlag = false;
3038 if (oleItem.isClaimsReturnedFlag()) {
3039 oleLoanForm.setTempClaimsFlag(true);
3040 claimsFlag = true;
3041 oleLoanForm.setClaimsReturned(false);
3042 oleLoanForm.setReturnSuccess(true);
3043 oleLoanForm.setReturnMessage(null);
3044 oleItem.setClaimsReturnedFlag(false);
3045 oleItem.setClaimsReturnedFlagCreateDate(null);
3046 oleItem.setClaimsReturnedNote(null);
3047 oleLoanDocument.getOleItem().setClaimsReturnedFlag(false);
3048 oleLoanDocument.getOleItem().setClaimsReturnedNote(null);
3049 oleLoanDocument.getOleItem().setClaimsReturnedFlagCreateDate(null);
3050 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
3051 itemXml.setContent(itemOlemlRecordProcessor.toXML(oleItem));
3052 itemXml.setCategory(OLEConstants.WORK_CATEGORY);
3053 itemXml.setType(DocType.ITEM.getCode());
3054 itemXml.setFormat(OLEConstants.OLEML_FORMAT);
3055 itemXml.setId(oleLoanDocument.getItemUuid());
3056 getDocstoreClientLocator().getDocstoreClient().updateItem(itemXml);
3057 if (oleLoanForm.isRecordNote()) {
3058 saveGeneralNoteForFlaggedItem(OLEConstants.CLAIMS_CHECKED_IN_FLAG, true, oleLoanDocument, false, true, false, oleLoanForm.getPatronBarcode());
3059 }
3060 }
3061 if (oleLoanDocument.isCopyRequest()) {
3062 oleLoanForm.setCopyRequest(true);
3063 oleLoanForm.setReturnSuccess(false);
3064 oleLoanForm.setNumberOfPieces(true);
3065 oleLoanForm.setReturnMessage(OLEConstants.COPY_REQUEST_FULFILL);
3066 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
3067 }
3068 if ((oleLoanDocument.isNumberOfPieces() && (matchCheck == null)) || (oleItem != null && StringUtils.isNotEmpty(oleItem.getNumberOfPieces())) && (matchCheck == null)) {
3069 int noOfPiece = 0;
3070 if (oleItem.getNumberOfPieces() != null && !oleItem.getNumberOfPieces().equalsIgnoreCase("")) {
3071 noOfPiece = Integer.parseInt(oleItem.getNumberOfPieces());
3072 }
3073 if (noOfPiece > 1) {
3074 oleLoanForm.setNumberOfPieces(true);
3075 oleLoanForm.setReturnSuccess(false);
3076 oleLoanForm.setReturnMessage(OLEConstants.VERIFY_PIECES + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.PIECES_RETURNED
3077 + OLEConstants.BREAK + "Total No of Pieces : " + oleLoanDocument.getItemNumberOfPieces() + OLEConstants.BREAK + "No of missing Pieces : " + (oleLoanDocument.getOleItem().getMissingPiecesCount() != null ? oleLoanDocument.getOleItem().getMissingPiecesCount() : "0"));
3078
3079 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
3080 }
3081 }
3082
3083 if (matchCheck != null && matchCheck.equalsIgnoreCase(OLEConstants.TRUE)) {
3084 oleLoanDocument.setContinueCheckIn(true);
3085 oleLoanDocument = getLoanProcessor().returnLoan(oleLoanDocument);
3086 oleLoanForm.setMatchCheck(null);
3087 oleLoanForm.setErrorMessage("");
3088 oleLoanForm.setMissingPieceCount("");
3089 oleLoanForm.setDescription("");
3090 oleLoanForm.setMissingPieceNote("");
3091 oleLoanForm.setSendMissingPieceMail(false);
3092 } else if (matchCheck != null && matchCheck.equalsIgnoreCase(OLEConstants.FALSE)) {
3093 Integer numberOfPieces = Integer.parseInt(oleItem != null && oleItem.getNumberOfPieces() != null && !oleItem.getNumberOfPieces().isEmpty() ? oleItem.getNumberOfPieces() : "0");
3094 if (numberOfPieces > 1) {
3095 if (oleLoanForm.getMissingPieceCount() != null && !oleLoanForm.getMissingPieceCount().equalsIgnoreCase("")) {
3096 if (oleLoanDocument.getOleItem() != null && oleLoanDocument.getOleItem().getNumberOfPieces() != null && (!oleLoanDocument.getOleItem().getNumberOfPieces().equalsIgnoreCase(""))) {
3097 int noOfPieces = Integer.parseInt(oleLoanDocument.getOleItem().getNumberOfPieces());
3098 int missingPieceCount = Integer.parseInt(oleLoanDocument.getMissingPiecesCount());
3099 int userMissingPieceCount = Integer.parseInt((oleLoanDocument.getOleItem().getMissingPiecesCount() != null ? oleLoanDocument.getOleItem().getMissingPiecesCount() : "0"));
3100 if (missingPieceCount < 0) {
3101 oleLoanForm.setCheckOut(true);
3102 oleLoanForm.setMissingPieceValidationSuccess(true);
3103 oleLoanForm.setErrorMessage("Missing piece should not less than 0");
3104 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
3105 }
3106 if (missingPieceCount + userMissingPieceCount > noOfPieces) {
3107 oleLoanForm.setCheckOut(true);
3108 oleLoanForm.setMissingPieceValidationSuccess(true);
3109 oleLoanForm.setErrorMessage("Missing piece should not be greater than sum of no of pieces and missing pieces ");
3110 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
3111 }
3112 }
3113 }
3114 }
3115 oleLoanForm.setSendMissingPieceMail(true);
3116 oleLoanDocument.setDescription(description);
3117 oleLoanForm.setMissingPieceMessage(oleLoanDocument.getDescription());
3118
3119 getLoanProcessor().updateMissingPiecesItemInfo(oleLoanDocument);
3120 if (oleLoanForm.isRecordMissingPieceNote() || oleLoanForm.isRecordCheckoutMissingPieceNote()) {
3121 if (!oleLoanForm.isRecordCheckoutMissingPieceNote()) {
3122 if (oleLoanForm.isRecordMissingPieceNote()) {
3123 saveGeneralNoteForFlaggedItem(OLEConstants.MISSING_PIECE_ITEM_CHECKED_IN_FLAG, true, oleLoanDocument, false, true, false, oleLoanForm.getPatronBarcode());
3124 }
3125 } else {
3126 saveGeneralNoteForFlaggedItem(OLEConstants.MISSING_PIECE_ITEM_CHECKED_IN_FLAG, true, oleLoanDocument, false, true, true, oleLoanForm.getPatronBarcode());
3127 }
3128 oleLoanForm.setRecordMissingPieceNote(false);
3129 oleLoanForm.setRecordCheckoutMissingPieceNote(false);
3130 }
3131
3132 oleLoanDocument.setContinueCheckIn(true);
3133 oleLoanDocument = getLoanProcessor().returnLoan(oleLoanDocument);
3134 oleLoanForm.setMatchCheck(null);
3135 oleLoanForm.setErrorMessage("");
3136 oleLoanForm.setMissingPieceCount("");
3137 oleLoanForm.setDescription("");
3138 oleLoanForm.setMissingPieceNote("");
3139 if (itemUUid != null) {
3140 itemXmlContent = getLoanProcessor().getItemXML(oleLoanDocument.getItemUuid());
3141 oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
3142 oleLoanDocument.setOleItem(oleItem);
3143 oleLoanDocument.setMissingPiecesCount(oleItem.getMissingPiecesCount());
3144 oleLoanDocument.setMissingPieceFlag(oleItem.isMissingPieceFlag());
3145 if (oleItem != null) {
3146 OleItemAvailableStatus oleItemAvailableStatus = getLoanProcessor().validateAndGetItemStatus(oleLoanDocument.getItemStatusCode());
3147 oleLoanDocument.setItemStatus(oleItemAvailableStatus != null ? oleItemAvailableStatus.getItemAvailableStatusName() : null);
3148 }
3149 }
3150 } else if ((copyCheck == null || copyCheck.isEmpty()) && !oleLoanForm.isNumberOfPieces() && oleItem.isClaimsReturnedFlag()) {
3151 oleLoanDocument = getLoanProcessor().returnLoan(oleLoanDocument);
3152 }
3153 String checkInNote = oleLoanDocument.getOleItem().getCheckinNote();
3154 if (!oleLoanForm.isBackGroundCheckIn() && (oleLoanForm.isCopyRequest() || oleLoanForm.isNumberOfPieces() || claimsFlag) && checkInNote != null && !checkInNote.isEmpty()) {
3155 oleLoanForm.setNumberOfPieces(false);
3156 oleLoanForm.setCopyRequest(false);
3157 oleLoanForm.setCheckInNote(OLEConstants.CHECK_IN_NOTE_HEADER + checkInNote);
3158 oleLoanForm.setRouteToLocation(oleLoanDocument.getRouteToLocation());
3159 String principalId = GlobalVariables.getUserSession().getPrincipalId();
3160 oleLoanForm.setOkOrRemoveNote(getLoanProcessor().checkPermissionForRemoveNote(principalId));
3161 }
3162 List<OleLoanDocument> oleLoanDocuments = new ArrayList<OleLoanDocument>();
3163 if (!oleLoanDocument.isCheckOut() || oleLoanDocument.getErrorMessage() == null)
3164 oleLoanDocuments.add(oleLoanDocument);
3165 if (oleLoanForm.getItemReturnList() != null) {
3166 oleLoanDocuments.addAll(oleLoanForm.getItemReturnList());
3167 }
3168 if (!oleLoanForm.isBackGroundCheckIn()) {
3169 oleLoanForm.setItemReturnList(oleLoanDocuments);
3170
3171
3172 oleLoanForm.setExistingLoanList(getLoanProcessor().getPatronLoanedItemBySolr(oleLoanDocument.getPatronId()));
3173 OleLoanDocument tempOleLoanDocumentObj = null;
3174 List<OleLoanDocument> currentSessionList = oleLoanForm.getLoanList() != null ? oleLoanForm.getLoanList() : new ArrayList<OleLoanDocument>();
3175 for (OleLoanDocument currentOleLoanDocument : currentSessionList) {
3176 if (currentOleLoanDocument != null && currentOleLoanDocument.getItemId() != null && currentOleLoanDocument.getItemId().equals(oleLoanForm.getCheckInItem())) {
3177 tempOleLoanDocumentObj = currentOleLoanDocument;
3178 break;
3179 }
3180 }
3181 currentSessionList.remove(tempOleLoanDocumentObj);
3182 oleLoanForm.setLoanList(currentSessionList);
3183
3184 }
3185
3186 } catch (Exception e) {
3187 LOG.error("Exception in Continue Check-in " + e);
3188 }
3189
3190 oleLoanForm.setNumberOfPieces(false);
3191 oleLoanForm.setReturnSuccess(true);
3192 oleLoanForm.setReturnMessage(null);
3193 oleLoanForm.setCheckInItem("");
3194 oleLoanForm.setReturnInformation("");
3195 if (LOG.isDebugEnabled()) {
3196 LOG.debug("oleLoanForm.getFormKey()" + oleLoanForm.getFormKey());
3197 }
3198 if (oleLoanForm.isBackGroundCheckIn()) {
3199 oleLoanForm.setItem(oleLoanForm.getCheckInItem());
3200 oleLoanForm.setOleItem(oleLoanDocument.getOleItem());
3201 oleLoanDocument.setItemLoanStatus(oleLoanDocument.getItemStatusCode());
3202 loanPatron(oleLoanForm, result, request, response);
3203 }
3204 if (oleLoanForm.isTempClaimsFlag()) {
3205
3206 if (!oleLoanDocument.isBackGroundCheckOut() && oleLoanDocument.getErrorMessage() != null) {
3207 oleLoanForm.setReturnSuccess(false);
3208 oleLoanForm.setReturnMessage(oleLoanDocument.getErrorMessage());
3209 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
3210 }
3211 }
3212 if (!oleLoanForm.isCheckInNoteExists() && oleLoanForm.getCheckInNote() != null) {
3213 oleLoanForm.setDummyLoan(oleLoanDocument);
3214 oleLoanForm.setCheckInNoteExists(true);
3215 oleLoanForm.setReturnSuccess(false);
3216 oleLoanForm.setReturnMessage(oleLoanForm.getCheckInNote());
3217 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
3218 }
3219 if (oleLoanDocument.isCheckOut() && oleLoanDocument.getErrorMessage() != null) {
3220 oleLoanForm.setDueDateEmpty(oleLoanDocument.isDueDateEmpty());
3221 oleLoanForm.setDummyLoan(oleLoanDocument);
3222 oleLoanForm.setReturnSuccess(false);
3223 oleLoanForm.setMessage(oleLoanDocument.getErrorMessage());
3224 oleLoanForm.setCheckOut(true);
3225 oleLoanForm.setItem(oleLoanForm.getCheckInItem());
3226 oleLoanForm.setOleItem(oleLoanDocument.getOleItem());
3227 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
3228 }
3229 if (oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
3230 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
3231 OleNoticeBo oleNoticeBo = getLoanProcessor().getNotice(oleLoanDocument);
3232
3233 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
3234 Date date = new Date(oleLoanDocument.getCheckInDate().getTime());
3235 if (oleNoticeBo != null && (!oleLoanDocument.isBackgroundCheckInMissingPiece()) && oleLoanForm.isSendMissingPieceMail()) {
3236 oleNoticeBo.setCheckInDate(dateFormat.format(date));
3237 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
3238 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) {
3239 fromAddress = OLEConstants.KUALI_MAIL;
3240 }
3241 String missingNoticeDetails = getOleDeliverBatchService().sendMissingNotice(oleNoticeBo);
3242 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer");
3243 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(missingNoticeDetails), true);
3244 if (LOG.isInfoEnabled()) {
3245 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress());
3246 }
3247 }
3248 } else {
3249 if (oleLoanDocument.getItemStatusCode() != null && oleLoanDocument.getItemStatusCode().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isHoldQueue()) {
3250 oleLoanForm.setBillAvailability(false);
3251 } else {
3252 oleLoanForm.setBillAvailability(true);
3253 }
3254 }
3255 }
3256 if (oleLoanDocument.isCheckOut()) {
3257 oleLoanForm.setDueDateSlip(true);
3258 oleLoanForm.setBillAvailability(false);
3259 }
3260 return getUIFModelAndView(oleLoanForm, oleLoanForm.getPageId());
3261 }
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272 @RequestMapping(params = "methodToCall=endCheckInSession")
3273 public ModelAndView endCheckInSession(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3274 HttpServletRequest request, HttpServletResponse response) {
3275 if (LOG.isDebugEnabled()) {
3276 LOG.debug(" Inside End Check-in session ");
3277 }
3278 OleLoanForm oleLoanForm = (OleLoanForm) form;
3279
3280 String parameter = getLoanProcessor().getParameter(OLEConstants.MAX_TIME_CHECK_IN);
3281 if (parameter != null) {
3282 oleLoanForm.setMaxTimeForCheckInDate(Integer.parseInt(parameter));
3283 }
3284
3285 oleLoanForm.setCopyRequest(false);
3286 oleLoanForm.setNumberOfPieces(false);
3287 oleLoanForm.setReturnInformation("");
3288 oleLoanForm.setCheckInItem("");
3289 oleLoanForm.setReturnMessage(null);
3290 oleLoanForm.setReturnSuccess(true);
3291 oleLoanForm.setItemReturnList(null);
3292 oleLoanForm.setCheckInNote(null);
3293 oleLoanForm.setBillAvailability(false);
3294 oleLoanForm.setCheckInDate(new Timestamp(new Date().getTime()));
3295 oleLoanForm.setCheckInTime(null);
3296 if (!oleLoanForm.isClearUI()) {
3297 String principalId = GlobalVariables.getUserSession().getPrincipalId();
3298 OleCirculationDeskDetail oleCirculationDeskDetail = getLoanProcessor().getDefaultCirculationDesk(principalId);
3299 if (oleCirculationDeskDetail != null) {
3300 oleLoanForm.setCirculationDesk(oleCirculationDeskDetail.getCirculationDeskId());
3301 oleLoanForm.setPreviousCirculationDesk(oleLoanForm.getCirculationDesk());
3302 }
3303 }
3304 oleLoanForm.setSuccessMessage(null);
3305
3306 return getUIFModelAndView(oleLoanForm, "ReturnItemViewPage");
3307 }
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318 @RequestMapping(params = "methodToCall=printBill")
3319 public ModelAndView printBill(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3320 HttpServletRequest request, HttpServletResponse response) {
3321 OlePrintSlip olePrintSlip = new OlePrintSlip();
3322 if (LOG.isDebugEnabled()) {
3323 LOG.debug(" Inside Print Bill ");
3324 }
3325 String formKey = request.getParameter("formKey");
3326 OleLoanForm oleLoanForm = (OleLoanForm) GlobalVariables.getUifFormManager().getSessionForm(formKey);
3327 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
3328 if (oleLoanForm.getRouteToLocation() != null) {
3329 oleLoanDocument.setRouteToLocation(oleLoanForm.getRouteToLocation());
3330 }
3331 olePrintSlip.createPdfForPrintingSlip(oleLoanDocument, response);
3332 oleLoanForm.setBackGroundCheckIn(false);
3333 return null;
3334 }
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345 @RequestMapping(params = "methodToCall=printLoanBill")
3346 public ModelAndView printLoanBill(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3347 HttpServletRequest request, HttpServletResponse response) {
3348 OlePrintSlip olePrintSlip = new OlePrintSlip();
3349 if (LOG.isDebugEnabled()) {
3350 LOG.debug(" Inside Print Loan Bill ");
3351 }
3352 String formKey = request.getParameter("formKey");
3353 OleLoanForm oleLoanForm = (OleLoanForm) GlobalVariables.getUifFormManager().getSessionForm(formKey);
3354 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
3355 List<OleLoanDocument> oleLoanDocumentList = new ArrayList<OleLoanDocument>();
3356 if (getLoanProcessor().getParameter(OLEConstants.PRINT_DUE_DATE_PER_TRANSACTION).equalsIgnoreCase("No")) {
3357 oleLoanDocumentList = printDueDateSlipList;
3358 } else {
3359 if (oleLoanForm.getLoanList() != null && (oleLoanForm.getLoanList().size() > 0)) {
3360 oleLoanDocumentList.add(oleLoanForm.getLoanList().get(0));
3361 }
3362 }
3363 if (oleLoanDocument.isCheckOut()) {
3364 olePrintSlip.createPdfForBackGroundCheckOut(oleLoanDocument, response);
3365 } else if (oleLoanDocumentList != null && oleLoanDocumentList.size() > 0) {
3366 olePrintSlip.createDueDateSlipPdf(oleLoanDocumentList, response);
3367 }
3368 return null;
3369 }
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381 @RequestMapping(params = "methodToCall=checkInNote")
3382 public ModelAndView checkInNote(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3383 HttpServletRequest request, HttpServletResponse response) {
3384 if (LOG.isDebugEnabled()) {
3385 LOG.debug("Check in Note Exists ");
3386 }
3387 OleLoanForm oleLoanForm = (OleLoanForm) form;
3388
3389
3390
3391
3392 OleCirculationDesk oleCirculationDesk = loanProcessor.getCirculationDeskByLocationCode(oleLoanForm.getRouteToLocation());
3393 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
3394 if ((oleLoanForm.getRouteToLocation() == null || oleLoanForm.getRouteToLocation().isEmpty()) && oleLoanDocument.getItemStatusCode().contains(OLEConstants.ITEM_STATUS_IN_TRANSIT)) {
3395 oleLoanForm.setInformation(OLEConstants.CIRC_DESK_REQUIRED);
3396 return getUIFModelAndView(form, "ReturnItemViewPage");
3397 } else if (oleCirculationDesk == null) {
3398 oleLoanForm.setInformation(OLEConstants.CIRC_DESK_INVALID);
3399 return getUIFModelAndView(form, "ReturnItemViewPage");
3400 } else {
3401 oleLoanDocument.setRouteToLocationName(oleCirculationDesk.getCirculationDeskPublicName());
3402 }
3403 oleLoanForm.setCheckInNoteExists(false);
3404 oleLoanForm.setReturnSuccess(true);
3405 oleLoanForm.setReturnMessage(null);
3406 oleLoanForm.setCheckInNote(null);
3407 oleLoanForm.setInformation("");
3408 oleLoanForm.setSuccessInfo("");
3409 Item oleItem = oleLoanDocument.getOleItem();
3410 if (oleItem != null) {
3411 try {
3412 getLoanProcessor().removeCheckInNote(oleItem);
3413 } catch (Exception e) {
3414 LOG.error("Exception while removing check-in note", e);
3415 }
3416 }
3417 if (oleLoanDocument.isCheckOut() && oleLoanDocument.getErrorMessage() != null) {
3418 oleLoanForm.setDueDateEmpty(oleLoanDocument.isDueDateEmpty());
3419 oleLoanForm.setDummyLoan(oleLoanDocument);
3420 oleLoanForm.setReturnSuccess(false);
3421 oleLoanForm.setMessage(oleLoanDocument.getErrorMessage());
3422 oleLoanForm.setCheckOut(true);
3423 oleLoanForm.setItem(oleLoanForm.getCheckInItem());
3424 oleLoanForm.setOleItem(oleLoanDocument.getOleItem());
3425 return getUIFModelAndView(form, "ReturnItemViewPage");
3426 }
3427 if (oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
3428 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
3429 OleNoticeBo oleNoticeBo = getLoanProcessor().getNotice(oleLoanDocument);
3430
3431 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
3432 Date date = new Date(oleLoanDocument.getCheckInDate().getTime());
3433 if (oleNoticeBo != null) {
3434 oleNoticeBo.setCheckInDate(dateFormat.format(date));
3435 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
3436 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) {
3437 fromAddress = OLEConstants.KUALI_MAIL;
3438 }
3439 String missingNoticeDetails = getOleDeliverBatchService().sendMissingNotice(oleNoticeBo);
3440 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer");
3441 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(missingNoticeDetails), true);
3442 if (LOG.isInfoEnabled()) {
3443 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress());
3444 }
3445 }
3446 } else {
3447 if (oleLoanDocument.getItemStatusCode() != null && oleLoanDocument.getItemStatusCode().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isHoldQueue()) {
3448 oleLoanForm.setBillAvailability(false);
3449 } else {
3450 oleLoanForm.setBillAvailability(true);
3451 }
3452
3453 }
3454 }
3455 if (oleLoanDocument.isCheckOut() && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
3456 oleLoanForm.setDueDateSlip(true);
3457 oleLoanForm.setBillAvailability(false);
3458 }
3459 return getUIFModelAndView(form, "ReturnItemViewPage");
3460 }
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471 @RequestMapping(params = "methodToCall=okCheckInNote")
3472 public ModelAndView okCheckInNote(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3473 HttpServletRequest request, HttpServletResponse response) {
3474 if (LOG.isDebugEnabled()) {
3475 LOG.debug("Check in Note Exists ");
3476 }
3477 OleLoanForm oleLoanForm = (OleLoanForm) form;
3478
3479
3480
3481
3482 OleCirculationDesk oleCirculationDesk = loanProcessor.getCirculationDeskByLocationCode(oleLoanForm.getRouteToLocation());
3483 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
3484 if ((oleLoanForm.getRouteToLocation() == null || oleLoanForm.getRouteToLocation().isEmpty()) && oleLoanDocument.getItemStatusCode().contains(OLEConstants.ITEM_STATUS_IN_TRANSIT)) {
3485 oleLoanForm.setInformation(OLEConstants.CIRC_DESK_REQUIRED);
3486 return getUIFModelAndView(form, "ReturnItemViewPage");
3487 } else if (oleCirculationDesk == null) {
3488 oleLoanForm.setInformation(OLEConstants.CIRC_DESK_INVALID);
3489 return getUIFModelAndView(form, "ReturnItemViewPage");
3490 } else {
3491 oleLoanDocument.setRouteToLocationName(oleCirculationDesk.getCirculationDeskPublicName());
3492 }
3493 oleLoanForm.setCheckInNoteExists(false);
3494 oleLoanForm.setReturnSuccess(true);
3495 oleLoanForm.setReturnMessage(null);
3496 oleLoanForm.setCheckInNote(null);
3497 oleLoanForm.setInformation("");
3498 oleLoanForm.setSuccessInfo("");
3499
3500
3501
3502
3503
3504 if (oleLoanDocument.isCheckOut() && oleLoanDocument.getErrorMessage() != null) {
3505 oleLoanForm.setDueDateEmpty(oleLoanDocument.isDueDateEmpty());
3506 oleLoanForm.setDummyLoan(oleLoanDocument);
3507 oleLoanForm.setReturnSuccess(false);
3508 oleLoanForm.setMessage(oleLoanDocument.getErrorMessage());
3509 oleLoanForm.setCheckOut(true);
3510 oleLoanForm.setItem(oleLoanForm.getCheckInItem());
3511 oleLoanForm.setOleItem(oleLoanDocument.getOleItem());
3512 return getUIFModelAndView(form, "ReturnItemViewPage");
3513 }
3514 if (oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
3515 if (oleLoanDocument.getOleItem().isMissingPieceFlag() && oleLoanForm.isSendMissingPieceMail()) {
3516 OleNoticeBo oleNoticeBo = getLoanProcessor().getNotice(oleLoanDocument);
3517
3518 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
3519
3520 Date date = new Date(oleLoanDocument.getCheckInDate().getTime());
3521 if (oleNoticeBo != null) {
3522 oleNoticeBo.setCheckInDate(dateFormat.format(date));
3523 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
3524 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) {
3525 fromAddress = OLEConstants.KUALI_MAIL;
3526 }
3527 String missingNoticeDetails = getOleDeliverBatchService().sendMissingNotice(oleNoticeBo);
3528 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer");
3529 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(missingNoticeDetails), true);
3530 if (LOG.isInfoEnabled()) {
3531 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress());
3532 }
3533 }
3534 } else {
3535 if (oleLoanDocument.getItemStatusCode() != null && oleLoanDocument.getItemStatusCode().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isHoldQueue()) {
3536 oleLoanForm.setBillAvailability(false);
3537 } else {
3538 oleLoanForm.setBillAvailability(true);
3539 }
3540 }
3541 }
3542 if (oleLoanDocument.isCheckOut() && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
3543 oleLoanForm.setDueDateSlip(true);
3544 oleLoanForm.setBillAvailability(false);
3545 }
3546 if (oleLoanDocument.getItemStatus() != null && oleLoanDocument.getItemStatus().equalsIgnoreCase(OLEConstants.ITEM_STATUS_RECENTLY_RETURNED)) {
3547 oleLoanForm.setBillAvailability(false);
3548 oleLoanForm.setDueDateSlip(false);
3549 }
3550 return getUIFModelAndView(form, "ReturnItemViewPage");
3551 }
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562 @RequestMapping(params = "methodToCall=clearUI")
3563 public ModelAndView clearUI(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3564 HttpServletRequest request, HttpServletResponse response) {
3565 OleLoanForm oleLoanForm = (OleLoanForm) form;
3566 oleLoanForm.setClearUI(true);
3567 clearPatronScreen(oleLoanForm, result, request, response);
3568 endCheckInSession(oleLoanForm, result, request, response);
3569 oleLoanForm.setClearUI(false);
3570 return getUIFModelAndView(form, "PatronItemViewPage");
3571 }
3572
3573 @RequestMapping(params = "methodToCall=clearReturnUI")
3574 public ModelAndView clearReturnUI(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3575 HttpServletRequest request, HttpServletResponse response) {
3576 OleLoanForm oleLoanForm = (OleLoanForm) form;
3577 oleLoanForm.setClearUI(true);
3578 clearPatronScreen(oleLoanForm, result, request, response);
3579 endCheckInSession(oleLoanForm, result, request, response);
3580 oleLoanForm.setClearUI(false);
3581 return getUIFModelAndView(form, "ReturnItemViewPage");
3582 }
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594 @RequestMapping(params = "methodToCall=setItemBarcode")
3595 public ModelAndView setItemBarcode(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3596 HttpServletRequest request, HttpServletResponse response) throws Exception {
3597 OleLoanForm oleLoanForm = (OleLoanForm) form;
3598 oleLoanForm.setItem(fastAddBarcode);
3599 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
3600 }
3601
3602 @RequestMapping(params = "methodToCall=gotoReturn")
3603 public ModelAndView gotoReturn(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3604 HttpServletRequest request, HttpServletResponse response) throws IOException {
3605 OleLoanForm oleLoanForm = (OleLoanForm) form;
3606 String baseUrl = ConfigContext.getCurrentContextConfig().getProperty("ole.rice2.url.base");
3607 String url = baseUrl + "/portal.do?channelTitle=Loan&channelUrl=" + baseUrl + "/ole-kr-krad/loancontroller?viewId=ReturnItemView&methodToCall=start&formKey=" + oleLoanForm.getFormKey();
3608 Properties props = new Properties();
3609 props.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.REFRESH);
3610 if (StringUtils.isNotBlank(form.getReturnFormKey())) {
3611 props.put(UifParameters.FORM_KEY, form.getReturnFormKey());
3612 }
3613 oleLoanForm.setSuccessMessage(null);
3614 oleLoanForm.setInformation("");
3615 oleLoanForm.setSuccessInfo("");
3616 return performRedirect(oleLoanForm, url, props);
3617 }
3618
3619
3620 @RequestMapping(params = "methodToCall=gotoLoan")
3621 public ModelAndView gotoLoan(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3622 HttpServletRequest request, HttpServletResponse response) throws Exception {
3623 OleLoanForm oleLoanForm = (OleLoanForm) form;
3624 oleLoanForm.setReturnCheck(false);
3625 String baseUrl = ConfigContext.getCurrentContextConfig().getProperty("ole.rice2.url.base");
3626 String requestKey = request.getParameter("formKey");
3627 String url = baseUrl + "/portal.do?channelTitle=Loan&channelUrl=" + baseUrl + "/ole-kr-krad/loancontroller?viewId=PatronItemView&methodToCall=start&formKey=" + requestKey;
3628 Properties props = new Properties();
3629 props.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.REFRESH);
3630 if (StringUtils.isNotBlank(form.getReturnFormKey())) {
3631 props.put(UifParameters.FORM_KEY, form.getReturnFormKey());
3632 }
3633 oleLoanForm.setSuccessMessage(null);
3634 return performRedirect(oleLoanForm, url, props);
3635 }
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646 @RequestMapping(params = "methodToCall=damagedCheckIn")
3647 public ModelAndView damagedCheckIn(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3648 HttpServletRequest request, HttpServletResponse response) {
3649 if (LOG.isDebugEnabled()) {
3650 LOG.debug("Check in Note Exists ");
3651 }
3652 OleLoanForm oleLoanForm = (OleLoanForm) form;
3653 OleCirculationDesk oleCirculationDesk = loanProcessor.getCirculationDeskByLocationCode(oleLoanForm.getRouteToLocation());
3654 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
3655 if ((oleLoanForm.getRouteToLocation() == null || oleLoanForm.getRouteToLocation().isEmpty()) && oleLoanDocument.getItemStatusCode().contains(OLEConstants.ITEM_STATUS_IN_TRANSIT)) {
3656 oleLoanForm.setInformation(OLEConstants.CIRC_DESK_REQUIRED);
3657 return getUIFModelAndView(form, "ReturnItemViewPage");
3658 } else if (oleCirculationDesk == null) {
3659 oleLoanForm.setInformation(OLEConstants.CIRC_DESK_INVALID);
3660 return getUIFModelAndView(form, "ReturnItemViewPage");
3661 } else {
3662 oleLoanDocument.setRouteToLocationName(oleCirculationDesk.getCirculationDeskPublicName());
3663 }
3664 oleLoanForm.setDamagedCheckIn(false);
3665 oleLoanForm.setReturnSuccess(true);
3666 oleLoanForm.setReturnMessage(null);
3667 oleLoanForm.setInformation("");
3668 oleLoanForm.setSuccessInfo("");
3669 if (oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isPrintSlip()) {
3670 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
3671 OleNoticeBo oleNoticeBo = getLoanProcessor().getNotice(oleLoanDocument);
3672
3673 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
3674 Date date = new Date(oleLoanDocument.getCheckInDate().getTime());
3675 if (oleNoticeBo != null) {
3676 oleNoticeBo.setCheckInDate(dateFormat.format(date));
3677 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
3678 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) {
3679 fromAddress = OLEConstants.KUALI_MAIL;
3680 }
3681 String missingNoticeDetails = getOleDeliverBatchService().sendMissingNotice(oleNoticeBo);
3682 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer");
3683 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(missingNoticeDetails), true);
3684 if (LOG.isInfoEnabled()) {
3685 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress());
3686 }
3687 }
3688 } else {
3689 if (oleLoanDocument.getItemStatusCode() != null && oleLoanDocument.getItemStatusCode().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleLoanDocument.getOleCirculationDesk() != null && oleLoanDocument.getOleCirculationDesk().isHoldQueue()) {
3690 oleLoanForm.setBillAvailability(false);
3691 } else {
3692 oleLoanForm.setBillAvailability(true);
3693 }
3694 }
3695 }
3696 return getUIFModelAndView(form, "ReturnItemViewPage");
3697 }
3698
3699 @RequestMapping(params = "methodToCall=proceedLoan")
3700 public ModelAndView proceedLoan(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3701 HttpServletRequest request, HttpServletResponse response) {
3702 OleLoanForm oleLoanForm = (OleLoanForm) form;
3703 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
3704 oleLoanDocument.setItemUuid(oleLoanForm.getItemUuid());
3705 try {
3706 getLoanProcessor().isClaimsReturnedItem(oleLoanForm.getItem(), oleLoanDocument);
3707 oleLoanForm.setAddressVerified(false);
3708 oleLoanForm.getErrorsAndPermission().clear();
3709 oleLoanForm.setClaimsFlag(false);
3710 getLoanProcessor().processLoan(oleLoanForm, oleLoanDocument);
3711 } catch (Exception e) {
3712 e.printStackTrace();
3713 }
3714 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
3715 }
3716
3717 private void saveGeneralNoteForFlaggedItem(String systemParameter, boolean multiValue, OleLoanDocument oleLoanDocument, boolean isCheckOut, boolean isCheckIn, boolean backgroundCheckin, String formBarcode) {
3718 String note = getLoanProcessor().getParameter(systemParameter);
3719 SimpleDateFormat df = new SimpleDateFormat(OLEConstants.TIMESTAMP);
3720 if (multiValue) {
3721 note = note.replace("[0]", oleLoanDocument.getItemId());
3722 if (isCheckOut) {
3723 note = note.replace("[0]", oleLoanDocument.getItemId());
3724 note = note.replace("[1]", df.format(oleLoanDocument.getCreateDate()).toString());
3725 Map map = new HashMap();
3726 map.put("circulationDeskId", oleLoanDocument.getCirculationLocationId());
3727 OleCirculationDesk oleCirculationDesk = getLoanProcessor().getBusinessObjectService().findByPrimaryKey(OleCirculationDesk.class, map);
3728 note = note.replace("[2]", oleCirculationDesk.getCirculationDeskCode());
3729 if (systemParameter.equalsIgnoreCase(OLEConstants.MISSING_PIECE_ITEM_CHECKED_OUT_FLAG)) {
3730 int noOfMissingPiece = 0;
3731 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
3732 if (oleLoanDocument.getOleItem() != null && oleLoanDocument.getOleItem().getMissingPiecesCount() != null && !oleLoanDocument.getOleItem().getMissingPiecesCount().equalsIgnoreCase("")) {
3733 noOfMissingPiece = Integer.parseInt(oleLoanDocument.getOleItem().getMissingPiecesCount());
3734 }
3735 }
3736 note = note.replace("[3]", noOfMissingPiece + "");
3737 }
3738 map.clear();
3739 map.put("olePatronId", oleLoanDocument.getPatronId());
3740 OlePatronDocument olePatronDocument = getLoanProcessor().getBusinessObjectService().findByPrimaryKey(OlePatronDocument.class, map);
3741 OlePatronNotes olePatronNotes = new OlePatronNotes();
3742 olePatronNotes.setPatronNoteText(note);
3743 map.clear();
3744 map.put("patronNoteTypeCode", "GENERAL");
3745 OlePatronNoteType olePatronNoteType = (OlePatronNoteType) getLoanProcessor().getBusinessObjectService().findByPrimaryKey(OlePatronNoteType.class, map);
3746 olePatronNotes.setPatronNoteTypeId(olePatronNoteType.getPatronNoteTypeId());
3747 olePatronNotes.setOlePatronId(olePatronDocument.getOlePatronId());
3748 olePatronDocument.getNotes().add(olePatronNotes);
3749 OlePatronDocument patronDocument = (OlePatronDocument) ObjectUtils.deepCopy(olePatronDocument);
3750 getLoanProcessor().getBusinessObjectService().save(patronDocument);
3751 }
3752 if (isCheckIn) {
3753 note = note.replace("[0]", oleLoanDocument.getItemId());
3754 note = note.replace("[1]", df.format(oleLoanDocument.getCheckInDate()).toString());
3755 note = note.replace("[2]", oleLoanDocument.getOleCirculationDesk().getCirculationDeskCode());
3756 if (oleLoanDocument != null && oleLoanDocument.getOlePatron() != null && oleLoanDocument.getOlePatron().getOlePatronId() != null) {
3757 Map map = new HashMap();
3758 OlePatronDocument olePatronDocument = new OlePatronDocument();
3759
3760
3761
3762
3763 map.put("olePatronId", oleLoanDocument.getPatronId());
3764 olePatronDocument = getLoanProcessor().getBusinessObjectService().findByPrimaryKey(OlePatronDocument.class, map);
3765
3766 if (systemParameter.equalsIgnoreCase(OLEConstants.MISSING_PIECE_ITEM_CHECKED_IN_FLAG)) {
3767 int noOfMissingPiece = 0;
3768 if (oleLoanDocument.getOleItem().isMissingPieceFlag()) {
3769 if (oleLoanDocument != null && oleLoanDocument.getMissingPiecesCount() != null && !oleLoanDocument.getMissingPiecesCount().equalsIgnoreCase("")) {
3770 noOfMissingPiece = Integer.parseInt(oleLoanDocument.getMissingPiecesCount());
3771 }
3772 }
3773 note = note.replace("[3]", noOfMissingPiece + "");
3774 }
3775 List<OlePatronNotes> olePatronNotesList = olePatronDocument.getNotes();
3776 OlePatronNotes olePatronNotes = new OlePatronNotes();
3777 olePatronNotes.setPatronNoteText(note);
3778 map.clear();
3779 map.put("patronNoteTypeCode", "GENERAL");
3780 OlePatronNoteType olePatronNoteType = (OlePatronNoteType) getLoanProcessor().getBusinessObjectService().findByPrimaryKey(OlePatronNoteType.class, map);
3781 olePatronNotes.setPatronNoteTypeId(olePatronNoteType.getPatronNoteTypeId());
3782 olePatronNotes.setOlePatronId(olePatronDocument.getOlePatronId());
3783 olePatronNotesList.add(olePatronNotes);
3784 getLoanProcessor().getBusinessObjectService().save(olePatronDocument);
3785 }
3786 }
3787
3788 }
3789
3790
3791 }
3792
3793 @RequestMapping(params = "methodToCall=flaggedNoteSave")
3794 public ModelAndView flaggedNoteSave(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3795 HttpServletRequest request, HttpServletResponse response) {
3796 OleLoanForm oleLoanForm = (OleLoanForm) form;
3797 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
3798 oleLoanForm.setOleFormKey(oleLoanForm.getFormKey());
3799 Item oleItem = oleLoanDocument.getOleItem();
3800
3801 try {
3802 String itemUUid = oleLoanDocument.getItemUuid();
3803 String itemXmlContent = getLoanProcessor().getItemXML(oleLoanDocument.getItemUuid());
3804 oleItem = getLoanProcessor().getItemPojo(itemXmlContent);
3805 itemXmlContent = getLoanProcessor().getItemXML(oleLoanDocument.getItemUuid());
3806 oleLoanDocument.setOleItem(oleItem);
3807
3808 } catch (Exception e) {
3809 if (LOG.isDebugEnabled()) {
3810 LOG.error("Error occurred while retrieving item in flaggedNoteSave" + e);
3811 }
3812 }
3813
3814
3815 if (oleLoanDocument.isItemDamagedStatus()) {
3816 if (oleLoanForm.isSkipDamagedRecordPopup()) {
3817 if (oleLoanForm.isCheckoutDamagedRecordFlag()) {
3818 oleLoanForm.setMessage(null);
3819 saveGeneralNoteForFlaggedItem(OLEConstants.DAMAGED_ITEM_CHECKED_OUT_FLAG, true, oleLoanDocument, true, false, oleLoanForm.isBackGroundCheckIn(), oleLoanForm.getPatronBarcode());
3820 oleLoanForm.setCheckoutDamagedRecordFlag(false);
3821 }
3822 oleLoanForm.setDisplayDamagedRecordNotePopup(false);
3823 oleLoanForm.setSuccessMessage(oleLoanDocument.getSuccessMessage());
3824 } else {
3825 oleLoanForm.setDisplayDamagedRecordNotePopup(true);
3826 oleLoanForm.setSkipDamagedRecordPopup(true);
3827 oleLoanForm.setMessage(null);
3828 oleLoanForm.setSuccessMessage(null);
3829 return getUIFModelAndView(form);
3830 }
3831 }
3832 if (oleLoanDocument.isMissingPieceFlag() || (oleLoanDocument.getOleItem() != null && oleLoanDocument.getOleItem().isMissingPieceFlag())) {
3833 if (oleLoanForm.isSkipMissingPieceRecordPopup()) {
3834 if (oleLoanForm.isCheckoutMissingPieceRecordFlag()) {
3835 oleLoanForm.setMessage(null);
3836 saveGeneralNoteForFlaggedItem(OLEConstants.MISSING_PIECE_ITEM_CHECKED_OUT_FLAG, true, oleLoanDocument, true, false, false, oleLoanForm.getPatronBarcode());
3837 oleLoanForm.setCheckoutMissingPieceRecordFlag(false);
3838 }
3839 oleLoanForm.setDisplayMissingPieceNotePopup(false);
3840 oleLoanForm.setSuccessMessage(oleLoanDocument.getSuccessMessage());
3841 } else {
3842 oleLoanForm.setDisplayMissingPieceNotePopup(true);
3843 oleLoanForm.setSkipMissingPieceRecordPopup(true);
3844 oleLoanForm.setMessage(null);
3845 oleLoanForm.setSuccessMessage(null);
3846 return getUIFModelAndView(form);
3847 }
3848 }
3849 oleLoanForm.setSkipDamagedRecordPopup(false);
3850 oleLoanForm.setSkipMissingPieceRecordPopup(false);
3851 return getUIFModelAndView(oleLoanForm, "PatronItemViewPage");
3852 }
3853
3854 @RequestMapping(params = "methodToCall=refreshReturnLoanList")
3855 public ModelAndView refreshReturnLoanList(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3856 HttpServletRequest request, HttpServletResponse response) {
3857 OleLoanForm oleLoanForm = (OleLoanForm) form;
3858 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
3859 List<OleLoanDocument> documentList = oleLoanForm.getItemReturnList();
3860 if (documentList != null && documentList.size() > 0) {
3861 OleCirculationDesk oleCirculationDesk = null;
3862 OleLocation oleLocation = null;
3863 if (oleLoanDocument.getCirculationLocationId() != null) {
3864
3865 try{
3866 oleLocation = loanProcessor.getLocationByLocationCode(oleLoanDocument.getItemLocation());
3867 }
3868 catch (Exception e){
3869 LOG.error("Exception while fetching OleLocation based on item location" +e);
3870 }
3871 String routeTo = oleLoanForm.getRouteToLocation() != null ? oleLoanForm.getRouteToLocation() :
3872 (oleLoanDocument.getRouteToLocation() != null ? oleLoanDocument.getRouteToLocation() :
3873 (oleLocation != null ? oleLocation.getLocationCode() : null));
3874 documentList.get(0).setRouteToLocation(routeTo);
3875 }
3876 }
3877 return getUIFModelAndView(form, "ReturnItemViewPage");
3878 }
3879
3880 @RequestMapping(params = "methodToCall=printHoldSlips")
3881 public ModelAndView printHoldSlips(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
3882 HttpServletRequest request, HttpServletResponse response) {
3883 try {
3884 OlePrintSlip olePrintSlip = new OlePrintSlip();
3885 if (LOG.isDebugEnabled()) {
3886 LOG.debug(" Inside Print Hold Slips ");
3887 }
3888 String formKey = request.getParameter("formKey");
3889 OleLoanForm oleLoanForm = (OleLoanForm) GlobalVariables.getUifFormManager().getSessionForm(formKey);
3890 OleLoanDocument oleLoanDocument = oleLoanForm.getDummyLoan();
3891 OleCirculationDesk oleCirculationDesk = null;
3892 oleCirculationDesk = getLoanProcessor().getOleCirculationDesk(oleLoanDocument.getCirculationLocationId());
3893 olePrintSlip.createHoldSlipPdf(printHoldSlipList, response, oleCirculationDesk);
3894
3895 } catch (Exception e) {
3896 LOG.error("Exception while generating printHoldSlips " + e);
3897 }
3898 return null;
3899 }
3900
3901 }