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