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