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