001package org.kuali.asr.service.impl; 002 003 004import org.apache.commons.lang.StringUtils; 005import org.apache.log4j.Logger; 006import org.kuali.ole.DataCarrierService; 007import org.kuali.ole.LoanUtil; 008import org.kuali.ole.OLEConstants; 009import org.kuali.ole.OLEParameterConstants; 010import org.kuali.ole.deliver.batch.OleDeliverBatchServiceImpl; 011import org.kuali.ole.deliver.batch.OleMailer; 012import org.kuali.ole.deliver.batch.OleNoticeBo; 013import org.kuali.ole.deliver.batch.OleSms; 014import org.kuali.ole.deliver.bo.*; 015import org.kuali.ole.deliver.processor.LoanProcessor; 016import org.kuali.ole.describe.bo.OleInstanceItemType; 017import org.kuali.ole.docstore.common.client.DocstoreClientLocator; 018import org.kuali.ole.docstore.common.document.ItemOleml; 019import org.kuali.ole.docstore.common.document.content.enums.DocType; 020import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor; 021import org.kuali.ole.docstore.common.search.SearchResponse; 022import org.kuali.ole.docstore.common.search.SearchResult; 023import org.kuali.ole.docstore.common.search.SearchResultField; 024import org.kuali.ole.ingest.pojo.MatchBo; 025import org.kuali.ole.sys.context.SpringContext; 026import org.kuali.ole.util.DocstoreUtil; 027import org.kuali.rice.core.api.config.property.ConfigContext; 028import org.kuali.rice.core.api.mail.EmailBody; 029import org.kuali.rice.core.api.mail.EmailFrom; 030import org.kuali.rice.core.api.mail.EmailSubject; 031import org.kuali.rice.core.api.mail.EmailTo; 032import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; 033import org.kuali.rice.coreservice.impl.parameter.ParameterBo; 034import org.kuali.rice.kim.api.permission.PermissionService; 035import org.kuali.rice.kim.api.role.RoleService; 036import org.kuali.rice.kim.api.services.KimApiServiceLocator; 037import org.kuali.rice.kim.impl.identity.type.EntityTypeContactInfoBo; 038import org.kuali.rice.krad.service.BusinessObjectService; 039import org.kuali.rice.krad.service.KRADServiceLocator; 040import org.kuali.rice.krad.util.GlobalVariables; 041import org.kuali.rice.krad.util.ObjectUtils; 042import org.kuali.rice.krms.api.KrmsApiServiceLocator; 043import org.kuali.rice.krms.api.engine.*; 044import org.kuali.rice.krms.impl.repository.AgendaBo; 045 046import java.math.BigDecimal; 047import java.sql.Timestamp; 048import java.text.DateFormat; 049import java.text.SimpleDateFormat; 050import java.util.*; 051 052/** 053 * Created with IntelliJ IDEA. 054 * User: sheiksalahudeenm 055 * Date: 1/15/14 056 * Time: 11:45 AM 057 * To change this template use File | Settings | File Templates. 058 */ 059public class OLEASRPlaceRequestHelperServiceImpl { 060 private static final Logger LOG = Logger.getLogger(OLEASRPlaceRequestHelperServiceImpl.class); 061 private static final String NAMESPACE_CODE_SELECTOR = "namespaceCode"; 062 private static final String NAME_SELECTOR = "name"; 063 private final static String RULE_EVALUATED = "Rule Evaluated"; 064 private final static String ROUTED_EXTERNAL = "Routed External"; 065 private BusinessObjectService businessObjectService = KRADServiceLocator.getBusinessObjectService(); 066 private int queuePosition = 0; 067 private LoanProcessor loanProcessor = new LoanProcessor(); 068 private DocstoreUtil docstoreUtil = new DocstoreUtil(); 069 070 private PermissionService getPermissionService() { 071 PermissionService service = KimApiServiceLocator.getPermissionService(); 072 return service; 073 } 074 075 private DocstoreClientLocator docstoreClientLocator; 076 077 public DocstoreClientLocator getDocstoreClientLocator() { 078 079 if (docstoreClientLocator == null) { 080 docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class); 081 082 } 083 return docstoreClientLocator; 084 } 085 086 /** 087 * Gets the businessObjectService attribute. 088 * 089 * @return Returns the businessObjectService 090 */ 091 private BusinessObjectService getBusinessObjectService() { 092 if (null == businessObjectService) { 093 businessObjectService = KRADServiceLocator.getBusinessObjectService(); 094 } 095 return businessObjectService; 096 } 097 098 public void setbusinessObjectService(BusinessObjectService businessObjectService) { 099 this.businessObjectService = businessObjectService; 100 } 101 102 public LoanProcessor getLoanProcessor() { 103 return loanProcessor; 104 } 105 106 public void setLoanProcessor(LoanProcessor loanProcessor) { 107 this.loanProcessor = loanProcessor; 108 } 109 110 /** 111 * This method is used to change the request type based on selection of pick up location 112 * 113 * @param oleDeliverRequestBo 114 * @return oleDeliverRequestBo 115 */ 116 public OleDeliverRequestBo processRequestType(OleDeliverRequestBo oleDeliverRequestBo) { 117 118 LOG.debug("Inside processRequestType for the Request id :" + oleDeliverRequestBo.getRequestId()); 119 oleDeliverRequestBo = processPatron(oleDeliverRequestBo); 120 oleDeliverRequestBo = processItem(oleDeliverRequestBo); 121 if (oleDeliverRequestBo.getRequestTypeId() != null) { 122 if (oleDeliverRequestBo.getRequestTypeId().equals("3") && oleDeliverRequestBo.getPickUpLocationId() != null && !oleDeliverRequestBo.getPickUpLocationId().isEmpty()) { 123 oleDeliverRequestBo.setRequestTypeId("4"); 124 } else if (oleDeliverRequestBo.getRequestTypeId().equals("5") && oleDeliverRequestBo.getPickUpLocationId() != null && !oleDeliverRequestBo.getPickUpLocationId().isEmpty()) { 125 oleDeliverRequestBo.setRequestTypeId("6"); 126 } else if (oleDeliverRequestBo.getRequestTypeId().equals("1") && oleDeliverRequestBo.getPickUpLocationId() != null && !oleDeliverRequestBo.getPickUpLocationId().isEmpty()) { 127 oleDeliverRequestBo.setRequestTypeId("2"); 128 } 129 } 130 return oleDeliverRequestBo; 131 } 132 133 134 /** 135 * This is to create a new patron object if the user enters the operator Id manually 136 * 137 * @param oleDeliverRequestBo 138 * @return deliver 139 */ 140 public OleDeliverRequestBo processPatron(OleDeliverRequestBo oleDeliverRequestBo) { 141 LOG.debug("Inside processPatron"); 142 OleDeliverRequestBo deliver = oleDeliverRequestBo; 143 144 if (oleDeliverRequestBo.getBorrowerBarcode() != null || oleDeliverRequestBo.getProxyBorrowerBarcode() != null) { 145 Map<String, String> patronMap = new HashMap<String, String>(); 146 patronMap.put(OLEConstants.OleDeliverRequest.PATRON_BARCODE, oleDeliverRequestBo.getBorrowerBarcode()); 147 List<OlePatronDocument> olePatronDocumentList = (List<OlePatronDocument>) businessObjectService.findMatching(OlePatronDocument.class, patronMap); 148 if (olePatronDocumentList != null && olePatronDocumentList.size() > 0) { 149 deliver.setOlePatron(olePatronDocumentList.get(0)); 150 deliver.setBorrowerName(olePatronDocumentList.get(0).getPatronName()); 151 deliver.setBorrowerId(olePatronDocumentList.get(0).getOlePatronId()); 152 } else if (olePatronDocumentList != null && olePatronDocumentList.size() == 0) { 153 deliver.setBorrowerId(null); 154 deliver.setFirstName(null); 155 deliver.setLastName(null); 156 deliver.setOlePatron(null); 157 deliver.setBorrowerName(null); 158 deliver.setBorrowerBarcode(null); 159 } 160 if (oleDeliverRequestBo.getRequestCreator().equals(OLEConstants.OleDeliverRequest.REQUESTER_PROXY_PATRON)) { 161 Map<String, String> proxyPatronMap = new HashMap<String, String>(); 162 proxyPatronMap.put(OLEConstants.OleDeliverRequest.PATRON_BARCODE, oleDeliverRequestBo.getProxyBorrowerBarcode()); 163 List<OlePatronDocument> oleProxyPatronDocumentList = (List<OlePatronDocument>) businessObjectService.findMatching(OlePatronDocument.class, proxyPatronMap); 164 if (oleProxyPatronDocumentList != null && oleProxyPatronDocumentList.size() > 0) { 165 deliver.setOleProxyPatron(oleProxyPatronDocumentList.get(0)); 166 deliver.setProxyBorrowerName(oleProxyPatronDocumentList.get(0).getPatronName()); 167 deliver.setProxyBorrowerId(oleProxyPatronDocumentList.get(0).getOlePatronId()); 168 } else if (oleProxyPatronDocumentList != null && oleProxyPatronDocumentList.size() == 0) { 169 deliver.setProxyBorrowerId(null); 170 deliver.setProxyBorrowerName(null); 171 deliver.setOleProxyPatron(null); 172 } 173 } 174 175 } 176 177 return deliver; 178 } 179 180 public boolean processOperator(String principalId) { 181 /*if (getPermissionService().hasPermission(oleDeliverRequestBo.getOperatorCreateId(), OLEConstants.OlePatron.PATRON_NAMESPACE, OLEConstants.CAN_LOAN)) { 182 return true; 183 }*/ 184 // Modified as per comments in Jira OLE-4901 185 boolean isOperator = true; 186 Collection<String> roles = getRoleService().getRoleMemberPrincipalIds(OLEConstants.OlePatron.PATRON_NAMESPACE, OLEConstants.OleDeliverRequest.REQUESTER_OPERATOR, null); 187 if (roles != null) { 188 isOperator = roles.contains(principalId); 189 } 190 return isOperator; 191 } 192 193 /** 194 * This is to check whether the pick up location is selected for the hold type of Request 195 * 196 * @param oleDeliverRequestBo 197 * @return validRequest 198 */ 199 public boolean validateRequestType(OleDeliverRequestBo oleDeliverRequestBo) { 200 LOG.debug("Inside validateRequestType"); 201 boolean validRequest = true; 202 if ((oleDeliverRequestBo.getRequestTypeId().equals("2") || oleDeliverRequestBo.getRequestTypeId().equals("4") || oleDeliverRequestBo.getRequestTypeId().equals("6")) && (oleDeliverRequestBo.getPickUpLocationId() == null) || (oleDeliverRequestBo.getPickUpLocationId() != null && oleDeliverRequestBo.getPickUpLocationId().isEmpty())) { 203 validRequest = false; 204 } 205 return validRequest; 206 } 207 208 209 /** 210 * This is to check whether the patron is having delivery privilege or not 211 * 212 * @param oleDeliverRequestBo 213 * @return hasDeliveryPrivilege 214 */ 215 public boolean validateDeliveryPrivilege(OleDeliverRequestBo oleDeliverRequestBo) { 216 LOG.debug("Inside validateDeliveryPrivilege"); 217 boolean hasDeliveryPrivilege = true; 218 if (oleDeliverRequestBo.getRequestTypeId().equals("1") || oleDeliverRequestBo.getRequestTypeId().equals("3") || oleDeliverRequestBo.getRequestTypeId().equals("5")) { 219 if (oleDeliverRequestBo.getOlePatron() != null && !oleDeliverRequestBo.getOlePatron().isDeliveryPrivilege()) { 220 hasDeliveryPrivilege = false; 221 } 222 } else if (oleDeliverRequestBo.getRequestTypeId().equals("2") || oleDeliverRequestBo.getRequestTypeId().equals("4") || oleDeliverRequestBo.getRequestTypeId().equals("6")) { 223 if (oleDeliverRequestBo.getOlePatron() != null && !oleDeliverRequestBo.getOlePatron().isDeliveryPrivilege() && oleDeliverRequestBo.getPickUpLocationId() == null) { 224 hasDeliveryPrivilege = false; 225 } 226 } 227 return hasDeliveryPrivilege; 228 } 229 230 231 /** 232 * This is to check whether the patron is having paging privilege or not 233 * 234 * @param oleDeliverRequestBo 235 * @return hasPagePrivilege 236 */ 237 public boolean validatePagingPrivilege(OleDeliverRequestBo oleDeliverRequestBo) { 238 LOG.debug("Inside validatePagingPrivilege"); 239 boolean hasPagePrivilege = true; 240 if (oleDeliverRequestBo.getRequestTypeId().equals("5") || oleDeliverRequestBo.getRequestTypeId().equals("6")) { 241 if (!oleDeliverRequestBo.getOlePatron().isPagingPrivilege()) { 242 hasPagePrivilege = false; 243 } 244 } 245 return hasPagePrivilege; 246 } 247 248 249 /** 250 * This for setting the null values for the unselected requester 251 * 252 * @param oleDeliverRequestBo 253 * @return oleDeliverRequestBo 254 */ 255 public OleDeliverRequestBo processRequester(OleDeliverRequestBo oleDeliverRequestBo) { 256 LOG.debug("Inside processRequester"); 257 if (oleDeliverRequestBo.getRequestCreator().equals(OLEConstants.OleDeliverRequest.REQUESTER_PATRON)) { 258 oleDeliverRequestBo.setProxyBorrowerId(null); 259 oleDeliverRequestBo.setOleProxyPatron(null); 260 oleDeliverRequestBo.setOperatorCreateId(null); 261 oleDeliverRequestBo.setOperatorCreator(null); 262 } else if (oleDeliverRequestBo.getRequestCreator().equals(OLEConstants.OleDeliverRequest.REQUESTER_PROXY_PATRON)) { 263 oleDeliverRequestBo.setOperatorCreateId(null); 264 oleDeliverRequestBo.setOperatorCreator(null); 265 } else if (oleDeliverRequestBo.getRequestCreator().equals(OLEConstants.OleDeliverRequest.REQUESTER_OPERATOR)) { 266 oleDeliverRequestBo.setProxyBorrowerId(null); 267 oleDeliverRequestBo.setOleProxyPatron(null); 268 } 269 return oleDeliverRequestBo; 270 } 271 272 273 /** 274 * This is to check whether the login patron is the proxy patron for the real patron 275 * 276 * @param oleDeliverRequestBo 277 * @return validProxy 278 */ 279 public boolean isValidProxyPatron(OleDeliverRequestBo oleDeliverRequestBo) { 280 LOG.debug("Inside isValidProxyPatron"); 281 boolean validProxy = true; 282 Map<String, String> proxyMap = new HashMap<String, String>(); 283 proxyMap.put(OLEConstants.OleDeliverRequest.PATRON_ID, oleDeliverRequestBo.getBorrowerId()); 284 proxyMap.put(OLEConstants.OleDeliverRequest.PROXY_PATRON_ID, oleDeliverRequestBo.getProxyBorrowerId()); 285 if (oleDeliverRequestBo.getProxyBorrowerId() != null && !oleDeliverRequestBo.getProxyBorrowerId().isEmpty()) { 286 List<OleProxyPatronDocument> proxyPatronDocuments = (List<OleProxyPatronDocument>) businessObjectService.findMatching(OleProxyPatronDocument.class, proxyMap); 287 if (proxyPatronDocuments.size() == 0) { 288 validProxy = false; 289 } 290 } 291 return validProxy; 292 } 293 294 295 /** 296 * This is to check whether the request is already raised by the patron for this item 297 * 298 * @param oleDeliverRequestBo 299 * @return alreadyExist 300 */ 301 public boolean isRequestAlreadyRaisedByPatron(OleDeliverRequestBo oleDeliverRequestBo) { 302 LOG.debug("Inside isRequestAlreadyRaised"); 303 boolean alreadyExist = false; 304 Map<String, String> requestMap = new HashMap<String, String>(); 305 requestMap.put(OLEConstants.OleDeliverRequest.BORROWER_ID, oleDeliverRequestBo.getBorrowerId()); 306 requestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 307 List<OleDeliverRequestBo> deliverRequestBos = (List<OleDeliverRequestBo>) businessObjectService.findMatching(OleDeliverRequestBo.class, requestMap); 308 if (deliverRequestBos != null && deliverRequestBos.size() > 0) { 309 alreadyExist = true; 310 } 311 return alreadyExist; 312 } 313 314 315 /** 316 * This is to check whether the requested item is currently in loan to the requesting patron 317 * 318 * @param oleDeliverRequestBo 319 * @return alreadyLoaned 320 */ 321 public boolean isAlreadyLoaned(OleDeliverRequestBo oleDeliverRequestBo) { 322 LOG.debug("Inside isAlreadyLoaned"); 323 boolean alreadyLoaned = false; 324 Map<String, String> loanMap = new HashMap<String, String>(); 325 loanMap.put(OLEConstants.OleDeliverRequest.LOAN_PATRON_ID, oleDeliverRequestBo.getBorrowerId()); 326 loanMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 327 List<OleLoanDocument> loanDocuments = (List<OleLoanDocument>) businessObjectService.findMatching(OleLoanDocument.class, loanMap); 328 if (loanDocuments != null && loanDocuments.size() > 0) { 329 alreadyLoaned = true; 330 } 331 return alreadyLoaned; 332 } 333 334 335 /** 336 * This is to check whether the item is available in the desk or not 337 * 338 * @param oleDeliverRequestBo 339 * @return itemAvailable 340 */ 341 public boolean isItemAvailable(OleDeliverRequestBo oleDeliverRequestBo) { 342 LOG.debug("Inside isItemAvailable"); 343 boolean itemAvailable = true; 344 345 String itemStatuslist = null; 346 String requestTypeCode = oleDeliverRequestBo.getRequestTypeCode(); 347 if (requestTypeCode.equals("Recall/Delivery Request")) { 348 itemStatuslist = loanProcessor.getParameter(OLEConstants.RECALL_DELIVERY_ITEM_STATUS); 349 } else if (requestTypeCode.equals("Recall/Hold Request")) { 350 itemStatuslist = loanProcessor.getParameter(OLEConstants.RECALL_HOLD_ITEM_STATUS); 351 } else if (requestTypeCode.equals("Hold/Delivery Request")) { 352 itemStatuslist = loanProcessor.getParameter(OLEConstants.HOLD_DELIVERY_ITEM_STATUS); 353 } else if (requestTypeCode.equals("Hold/Hold Request")) { 354 itemStatuslist = loanProcessor.getParameter(OLEConstants.HOLD_HOLD_ITEM_STATUS); 355 } else if (requestTypeCode.equals("Page/Delivery Request")) { 356 itemStatuslist = loanProcessor.getParameter(OLEConstants.PAGE_DELIVERY_ITEM_STATUS); 357 } else if (requestTypeCode.equals("Page/Hold Request")) { 358 itemStatuslist = loanProcessor.getParameter(OLEConstants.PAGE_HOLD_ITEM_STATUS); 359 } else if (requestTypeCode.equals("Copy Request")) { 360 itemStatuslist = loanProcessor.getParameter(OLEConstants.COPY_REQUEST_ITEM_STATUS); 361 } else { 362 GlobalVariables.getMessageMap().putError(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, OLEConstants.OleDeliverRequest.REQUEST_ID_INVALID); 363 } 364 String[] str = itemStatuslist.split(";"); 365 for (String itemStatus : str) { 366 if ((itemStatus != null) && (!itemStatus.isEmpty()) && (itemStatus.equals(oleDeliverRequestBo.getItemStatus()))) { 367 itemAvailable = false; 368 } 369 } 370 return itemAvailable; 371 } 372 373 374 /** 375 * This is to check whether the item is available in the desk or not 376 * 377 * @param oleDeliverRequestBo 378 * @return itemAvailable 379 */ 380 public boolean isItemAvailableForLoan(OleDeliverRequestBo oleDeliverRequestBo) { 381 LOG.debug("Inside isItemAvailable"); 382 boolean itemAvailable = false; 383 Map<String, String> loanItemMap = new HashMap<String, String>(); 384 loanItemMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 385 List<OleLoanDocument> loanItemDocuments = (List<OleLoanDocument>) businessObjectService.findMatching(OleLoanDocument.class, loanItemMap); 386 if (loanItemDocuments.size() == 0) { 387 itemAvailable = true; 388 } 389 return itemAvailable; 390 } 391 392 393 /** 394 * This is to check whether the item is eligible to loan 395 * 396 * @param oleDeliverRequestBo 397 * @return itemEligible 398 */ 399 public boolean isItemEligible(OleDeliverRequestBo oleDeliverRequestBo) { 400 LOG.debug("Inside isItemEligible"); 401 boolean itemEligible = true; 402 Map<String, String> statusMap = new HashMap<String, String>(); 403 statusMap.put(OLEConstants.OleDeliverRequest.LOSTBILLREPLACEMENT, OLEConstants.OleDeliverRequest.LOSTBILLREPLACEMENT); 404 statusMap.put(OLEConstants.OleDeliverRequest.MISSINGFINALOVERDUE, OLEConstants.OleDeliverRequest.MISSINGFINALOVERDUE); 405 statusMap.put(OLEConstants.OleDeliverRequest.WITHDRAWNCLIAMSRETURN, OLEConstants.OleDeliverRequest.WITHDRAWNCLIAMSRETURN); 406 407 if (statusMap.containsKey(oleDeliverRequestBo.getItemStatus())) { 408 itemEligible = false; 409 } 410 return itemEligible; 411 } 412 413 /** 414 * This is to check whether the patron record is alive or expired 415 * 416 * @param oleDeliverRequestBo 417 * @return expired 418 */ 419 public String patronRecordExpired(OleDeliverRequestBo oleDeliverRequestBo) { 420 LOG.debug("Inside patronRecordExpired"); 421 String expired = null; 422 Map<String, String> patronMap = new HashMap<String, String>(); 423 patronMap.put(OLEConstants.OleDeliverRequest.PATRON_ID, oleDeliverRequestBo.getBorrowerId()); 424 List<OlePatronDocument> olePatronDocuments = (List<OlePatronDocument>) businessObjectService.findMatching(OlePatronDocument.class, patronMap); 425 if (olePatronDocuments != null && olePatronDocuments.size() > 0) { 426 SimpleDateFormat fmt = new SimpleDateFormat(OLEConstants.OleDeliverRequest.DATE_FORMAT); 427 Date expirationDate = olePatronDocuments.get(0).getExpirationDate(); 428 Date activationDate = olePatronDocuments.get(0).getActivationDate(); 429 if ((fmt.format(activationDate)).compareTo(fmt.format(new Date(System.currentTimeMillis()))) <= 0) { 430 if (expirationDate != null) { 431 if ((fmt.format(expirationDate)).compareTo(fmt.format(new Date(System.currentTimeMillis()))) < 0) { 432 expired = OLEConstants.OleDeliverRequest.PATRON_RECORD_EXPIRE; 433 } 434 } 435 } else { 436 expired = OLEConstants.OleDeliverRequest.PATRON_RECORD_FUTURE; 437 } 438 } 439 return expired; 440 } 441 442 443 /** 444 * This is for retrieving the request raised by the patron 445 * 446 * @param olePatronId 447 * @return deliverRequestBos 448 */ 449 public List<OleDeliverRequestBo> getRequestedItems(String olePatronId) { 450 LOG.debug("Inside getRequestedItems"); 451 Map<String, String> requestMap = new HashMap<String, String>(); 452 requestMap.put(OLEConstants.OleDeliverRequest.BORROWER_ID, olePatronId); 453 List<OleDeliverRequestBo> deliverRequestBos = (List<OleDeliverRequestBo>) businessObjectService.findMatching(OleDeliverRequestBo.class, requestMap); 454 for (int i = 0; i < deliverRequestBos.size(); i++) { 455 processItem(deliverRequestBos.get(i)); 456 } 457 return deliverRequestBos; 458 459 } 460 461 462 /** 463 * This is to check the duplicate in the queue Position while re -ordering 464 * 465 * @param itemList 466 * @return exist 467 */ 468 public String validateQueuePosition(List<OleDeliverRequestBo> itemList) { 469 LOG.debug("Inside validateQueuePosition"); 470 String message = OLEConstants.OleDeliverRequest.REORDER_SUCCESS; 471 List<Integer> queuePositionList = new ArrayList<Integer>(); 472 if (itemList.get(0).getBorrowerQueuePosition() < 1) { 473 return OLEConstants.OleDeliverRequest.POSITIVE_QUEUE_POSITION; 474 } 475 queuePositionList.add(itemList.get(0).getBorrowerQueuePosition()); 476 477 for (int i = 1; i < itemList.size(); i++) { 478 for (int j = 0; j < queuePositionList.size(); j++) { 479 if (itemList.get(i).getBorrowerQueuePosition() != null) { 480 if ((itemList.get(i).getBorrowerQueuePosition() >= 1) && (itemList.get(i).getBorrowerQueuePosition() == queuePositionList.get(j))) { 481 return OLEConstants.OleDeliverRequest.QUEUE_DUPLICATE; 482 } else if ((itemList.get(i).getBorrowerQueuePosition() <= 0)) { 483 return OLEConstants.OleDeliverRequest.POSITIVE_QUEUE_POSITION; 484 } 485 } 486 } 487 queuePositionList.add(itemList.get(i).getBorrowerQueuePosition()); 488 } 489 return message; 490 } 491 492 // 493 494 /** 495 * This is to check whether any request raised for the item 496 * 497 * @param oleDeliverRequestBo 498 * @return exist 499 */ 500 public boolean isRequestRaised(OleDeliverRequestBo oleDeliverRequestBo) { 501 LOG.debug("Inside isRequestRaised"); 502 boolean exist = false; 503 Map<String, String> requestMap = new HashMap<String, String>(); 504 requestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 505 List<OleDeliverRequestBo> deliverRequestBos = (List<OleDeliverRequestBo>) businessObjectService.findMatching(OleDeliverRequestBo.class, requestMap); 506 if (deliverRequestBos.size() > 0) { 507 exist = true; 508 } 509 return exist; 510 } 511 512 513 /** 514 * This method is used to cancel the request document 515 * 516 * @param oleDeliverRequestBo 517 */ 518 public void cancelDocument(OleDeliverRequestBo oleDeliverRequestBo) { 519 LOG.debug("Inside cancelDocument"); 520 Map<String, String> itemMap = new HashMap<String, String>(); 521 itemMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 522 Map<String, String> requestMap = new HashMap<String, String>(); 523 requestMap.put(OLEConstants.OleDeliverRequest.REQUEST_ID, oleDeliverRequestBo.getRequestId()); 524 businessObjectService.deleteMatching(OleDeliverRequestBo.class, requestMap); 525 List<OleDeliverRequestBo> oleDeliverRequestDocumentsList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, itemMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 526 businessObjectService.delete(oleDeliverRequestDocumentsList); 527 int queuePosition = 1; 528 for (int i = 0; i < oleDeliverRequestDocumentsList.size(); i++) { 529 oleDeliverRequestDocumentsList.get(i).setBorrowerQueuePosition(queuePosition); 530 queuePosition = queuePosition + 1; 531 } 532 businessObjectService.save(oleDeliverRequestDocumentsList); 533 } 534 535 public void cancelPendingRequestForClaimsReturnedItem(String itemUuid) throws Exception { 536 Map<String, String> requestMap = new HashMap<String, String>(); 537 requestMap.put("itemUuid", itemUuid); 538 OleDeliverBatchServiceImpl oleDeliverBatchService = new OleDeliverBatchServiceImpl(); 539 List<OleDeliverRequestBo> oleDeliverRequestBoList = (List<OleDeliverRequestBo>) businessObjectService.findMatching(OleDeliverRequestBo.class, requestMap); 540 for (OleDeliverRequestBo oleDeliverRequestBo : oleDeliverRequestBoList) { 541 cancelDocument(oleDeliverRequestBo); 542 OleItemSearch itemSearch = docstoreUtil.getOleItemSearchList(itemUuid); 543 EntityTypeContactInfoBo entityTypeContactInfoBo = oleDeliverRequestBo.getOlePatron().getEntity().getEntityTypeContactInfos().get(0); 544 List<OleNoticeBo> oleNoticeBos = new ArrayList<OleNoticeBo>(); 545 OleNoticeBo oleNoticeBo = new OleNoticeBo(); 546 oleNoticeBo.setNoticeName(OLEConstants.CANCELLATION_NOTICE); 547 oleNoticeBo.setAuthor(itemSearch.getAuthor() != null ? itemSearch.getAuthor() : ""); 548 oleNoticeBo.setItemCallNumber(itemSearch.getCallNumber() != null ? itemSearch.getCallNumber() : ""); 549 oleNoticeBo.setItemShelvingLocation(itemSearch.getShelvingLocation() != null ? itemSearch.getShelvingLocation() : ""); 550 oleNoticeBo.setItemId(itemSearch.getItemUUID() != null ? itemSearch.getItemUUID() : ""); 551 oleNoticeBo.setTitle(itemSearch.getTitle() != null ? itemSearch.getTitle() : ""); 552 oleNoticeBo.setOleItem(getItem(oleDeliverRequestBo.getItemUuid())); 553 oleNoticeBo.setPatronEmailAddress(getPatronHomeEmailId(entityTypeContactInfoBo) != null ? getPatronHomeEmailId(entityTypeContactInfoBo) : ""); 554 if (oleNoticeBo.getPatronEmailAddress() != null && !oleNoticeBo.getPatronEmailAddress().isEmpty()) { 555 oleNoticeBos.add(oleNoticeBo); 556 List list = oleDeliverBatchService.getNoticeForPatron(oleNoticeBos); 557 String content = list.toString(); 558 content = content.replace('[', ' '); 559 content = content.replace(']', ' '); 560 if (!content.trim().equals("")) { 561 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer"); 562 String replyToEmail = getLoanProcessor().getReplyToEmail(oleNoticeBo.getItemShelvingLocation()); 563 if (replyToEmail != null) { 564 oleMailer.sendEmail(new EmailFrom(replyToEmail), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.CANCELLATION_NOTICE), new EmailBody(content), true); 565 } else { 566 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL); 567 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) { 568 fromAddress = OLEConstants.KUALI_MAIL; 569 } 570 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.CANCELLATION_NOTICE), new EmailBody(content), true); 571 } 572 } 573 } 574 } 575 } 576 577 /** 578 * This method is to set the item values from docstore 579 * 580 * @param oleDeliverRequestBo 581 * @return oleDeliverRequestBo 582 */ 583 public OleDeliverRequestBo processItem(OleDeliverRequestBo oleDeliverRequestBo) { 584 LOG.debug("Inside processItem"); 585 OleItemSearch oleItemSearch = null; 586 if (oleDeliverRequestBo.getItemType() == null) { 587 // Map<String, String> itemMap = new HashMap<String, String>(); 588 //itemMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 589 OleItemSearch itemSearchList = docstoreUtil.getOleItemSearchList(oleDeliverRequestBo.getItemUuid()); 590 try { 591 //org.kuali.ole.docstore.common.document.Item item=getDocstoreClientLocator().getDocstoreClient().retrieveItem( oleDeliverRequestBo.getItemUuid()); 592 593 594 if (itemSearchList != null) { 595 oleItemSearch = itemSearchList; 596 oleDeliverRequestBo.setTitle(itemSearchList.getTitle()); 597 oleDeliverRequestBo.setAuthor(itemSearchList.getAuthor()); 598 oleDeliverRequestBo.setCallNumber(itemSearchList.getCallNumber()); 599 oleDeliverRequestBo.setItemType(itemSearchList.getItemType()); 600 oleDeliverRequestBo.setItemLocation(itemSearchList.getShelvingLocation()); 601 } 602 } catch (Exception ex) { 603 ex.printStackTrace(); 604 } 605 try { 606 if (oleItemSearch == null) { 607 oleItemSearch = new OleItemSearch(); 608 } 609 // Map docStoreDetails = loanProcessor.getItemDetails(oleDeliverRequestBo.getItemId()); 610 String itemXml = loanProcessor.getItemXML(oleDeliverRequestBo.getItemUuid()); 611 org.kuali.ole.docstore.common.document.content.instance.Item oleItem = loanProcessor.getItemPojo(itemXml); 612 oleItemSearch.setCopyNumber(oleItem.getCopyNumber()); 613 if (oleItem.getItemStatus() != null) { 614 oleItemSearch.setItemStatus(oleItem.getItemStatus().getCodeValue()); 615 } 616 oleItemSearch.setShelvingLocation(getShelvingLocation(oleItem.getLocation())); 617 oleDeliverRequestBo.setCopyNumber(oleItem.getCopyNumber()); 618 if (oleItem.getItemStatus() != null) { 619 oleDeliverRequestBo.setItemStatus(oleItem.getItemStatus().getCodeValue()); 620 } 621 oleDeliverRequestBo.setShelvingLocation(getShelvingLocation(oleItem.getLocation())); 622 if (oleDeliverRequestBo.getRequestTypeId().equals("8")) { 623 oleDeliverRequestBo.setInTransitCheckInNote(oleItem.getCheckinNote()); 624 } 625 } catch (Exception e) { 626 LOG.error(ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.INVAL_LOC), e); //To change body of catch statement use File | Settings | File Templates. 627 } 628 } 629 oleDeliverRequestBo.setOleItemSearch(oleItemSearch); 630 oleDeliverRequestBo = processItemType(oleDeliverRequestBo); 631 return oleDeliverRequestBo; 632 } 633 634 /** 635 * This method is to set the item type name based on the item type code 636 * 637 * @param oleDeliverRequestBo 638 * @return 639 */ 640 public OleDeliverRequestBo processItemType(OleDeliverRequestBo oleDeliverRequestBo) { 641 LOG.debug("Inside process Item Type"); 642 Map<String, String> itemMap = new HashMap<String, String>(); 643 itemMap = new HashMap<String, String>(); 644 itemMap.put(OLEConstants.OleDeliverRequest.ITEM_TYPE_CODE, oleDeliverRequestBo.getItemType()); 645 List<OleInstanceItemType> oleInstanceItemTypeList = (List<OleInstanceItemType>) businessObjectService.findMatching(OleInstanceItemType.class, itemMap); 646 if (oleInstanceItemTypeList != null && oleInstanceItemTypeList.size() > 0) { 647 OleInstanceItemType oleInstanceItemType = oleInstanceItemTypeList.get(0); 648 oleDeliverRequestBo.setItemTypeName(oleInstanceItemType.getInstanceItemTypeName()); 649 } 650 651 return oleDeliverRequestBo; 652 } 653 654 /** 655 * This method is to retrieve the shelving location from item 656 * 657 * @param oleLocation 658 * @return locationLevelName 659 */ 660 private String getShelvingLocation(org.kuali.ole.docstore.common.document.content.instance.Location oleLocation) { 661 662 LOG.debug("Inside getShelvingLocation"); 663 String locationLevelName = ""; 664 if (oleLocation != null) { 665 org.kuali.ole.docstore.common.document.content.instance.LocationLevel locationLevel = 666 oleLocation.getLocationLevel(); 667 if (locationLevel != null) { 668 while (locationLevel.getLocationLevel() != null && !locationLevel.getLevel().equalsIgnoreCase(OLEConstants.OleDeliverRequest.SHELVING)) { 669 locationLevel = locationLevel.getLocationLevel(); 670 } 671 locationLevelName = locationLevel.getName(); 672 } 673 } 674 return locationLevelName; 675 } 676 677 678 /** 679 * This method is to check whether the selected request can be raised for the item 680 * 681 * @param oleDeliverRequestBo 682 * @return canRaiseRequest 683 */ 684 public boolean canRaiseRequest(OleDeliverRequestBo oleDeliverRequestBo) { 685 LOG.debug("Inside canRaiseRequest"); 686 boolean canRaiseRequest = true; 687 688 if (isItemAvailable(oleDeliverRequestBo)) { 689 canRaiseRequest = false; 690 691 692 } 693 return canRaiseRequest; 694 } 695 696 697 /** 698 * racle 699 * This method is to update the request id in the loan document 700 * 701 * @param oleDeliverRequestBo 702 */ 703 public OleDeliverRequestBo updateLoanDocument(OleDeliverRequestBo oleDeliverRequestBo) { 704 LOG.debug("Inside updateLoanDocument"); 705 Map<String, String> loanMap = new HashMap<String, String>(); 706 loanMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 707 List<OleLoanDocument> oleLoanDocumentList = (List<OleLoanDocument>) businessObjectService.findMatching(OleLoanDocument.class, loanMap); 708 if (oleLoanDocumentList != null && oleLoanDocumentList.size() > 0 && oleLoanDocumentList.get(0) != null && oleLoanDocumentList.get(0).getOleRequestId() == null) { 709 if (oleLoanDocumentList.get(0).getLoanId() != null) { 710 // oleLoanDocumentList.get(0).setOleRequestId(oleDeliverRequestBo.getRequestId()); 711 oleDeliverRequestBo.setLoanTransactionRecordNumber(oleLoanDocumentList.get(0).getLoanId()); 712 } 713 // businessObjectService.save(oleLoanDocumentList.get(0)); 714 715 } 716 return oleDeliverRequestBo; 717 } 718 719 /** 720 * @param requestId 721 * @param itemUUID 722 * @param operatorId 723 * @param loanTransactionNumber 724 */ 725 public void deleteRequest(String requestId, String itemUUID, String operatorId, String loanTransactionNumber) { 726 LOG.debug("Inside deleteRequest"); 727 Map<String, String> requestMap = new HashMap<String, String>(); 728 requestMap.put(OLEConstants.OleDeliverRequest.REQUEST_ID, requestId); 729 createRequestHistoryRecord(requestId, operatorId, loanTransactionNumber); 730 Map<String, String> itemMap = new HashMap<String, String>(); 731 itemMap.put(OLEConstants.ITEM_UUID, itemUUID); 732 List<OleDeliverRequestBo> oleDeliverRequestDocumentsList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, itemMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 733 businessObjectService.delete(oleDeliverRequestDocumentsList); 734 int queuePosition = 1; 735 for (int i = 0; i < oleDeliverRequestDocumentsList.size(); i++) { 736 oleDeliverRequestDocumentsList.get(i).setBorrowerQueuePosition(queuePosition); 737 queuePosition = queuePosition + 1; 738 } 739 businessObjectService.save(oleDeliverRequestDocumentsList); 740 741 } 742 743 /** 744 * This for retrieving the item Details from docstore 745 * 746 * @param itemUUID 747 * @return oleItemSearch 748 */ 749 public OleItemSearch getItemDetails(String itemUUID) { 750 LOG.debug("Inside getItemDetails"); 751 OleItemSearch oleItemSearch = getItemDetailsForPatron(itemUUID); 752 try { 753 // Map docStoreDetails= loanProcessor.getItemDetails(itemBarCode); 754 String itemXml = loanProcessor.getItemXML(itemUUID); 755 org.kuali.ole.docstore.common.document.content.instance.Item oleItem = loanProcessor.getItemPojo(itemXml); 756 if (oleItem != null && oleItem.getItemType() != null) { 757 oleItemSearch.setItemType(processItemType(oleItem.getItemType().getCodeValue())); 758 } 759 oleItemSearch.setCopyNumber(oleItem.getCopyNumber()); 760 if (oleItem.getItemStatus() != null) { 761 oleItemSearch.setItemStatus(oleItem.getItemStatus().getCodeValue()); 762 } 763 oleItemSearch.setShelvingLocation(getShelvingLocation(oleItem.getLocation())); 764 oleItemSearch.setVolumeNumber(oleItem.getVolumeNumber()); 765 } catch (Exception e) { 766 LOG.error("Not able to retrieve information from the docstore for the Item Barcode : " + itemUUID, e); //To change body of catch statement use File | Settings | File Templates. 767 } 768 return oleItemSearch; 769 } 770 771 /** 772 * This method is for retrieving the item details for displaying in the patron screen 773 * 774 * @param itemUUID 775 * @return OleItemSearch 776 */ 777 public OleItemSearch getItemDetailsForPatron(String itemUUID) { 778 LOG.debug("Inside getItemDetailsForPatron"); 779 OleItemSearch oleItemSearch; 780 try { 781 782 Map<String, String> itemMap = new HashMap<String, String>(); 783 // itemMap.put(OLEConstants.OleDeliverRequest.ITEM_UUID, itemUUID); 784 OleItemSearch itemSearchList = docstoreUtil.getOleItemSearchList(itemUUID); 785 if (itemSearchList != null) { 786 return oleItemSearch = itemSearchList; 787 } 788 } catch (NullPointerException e) { 789 LOG.error("No item details available for the Item Barcode : " + itemUUID, e); 790 } 791 792 return new OleItemSearch(); 793 794 } 795 796 /** 797 * This method is to re-order the queuePosition based on the priority while creating the request 798 * 799 * @param oleDeliverRequestBo 800 * @return OleDeliverRequestBo 801 */ 802 public OleDeliverRequestBo reOrderQueuePosition(OleDeliverRequestBo oleDeliverRequestBo) { 803 LOG.debug("Inside reOrderQueuePosition"); 804 List<OleDeliverRequestBo> existingRequest = new ArrayList<OleDeliverRequestBo>(); 805 String queue = getLoanProcessor().getParameter(OLEConstants.OleDeliverRequest.REQUEST_QUEUE); 806 List<String> orderQueue = new ArrayList<String>(); 807 String[] queueArray = queue.split(";"); 808 for (int i = 0; i < queueArray.length; i++) { 809 orderQueue.add(queueArray[i]); 810 } 811 List<OleDeliverRequestBo> finalList = new ArrayList<OleDeliverRequestBo>(); 812 Map<String, String> recallRequestMap = new HashMap<String, String>(); 813 recallRequestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 814 recallRequestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "1"); 815 Map<String, String> recallHoldRequestMap = new HashMap<String, String>(); 816 recallHoldRequestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 817 recallHoldRequestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "2"); 818 Map<String, String> holdRequestMap = new HashMap<String, String>(); 819 holdRequestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 820 holdRequestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "3"); 821 Map<String, String> holdHoldRequestMap = new HashMap<String, String>(); 822 holdHoldRequestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 823 holdHoldRequestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "4"); 824 Map<String, String> pageRequestMap = new HashMap<String, String>(); 825 pageRequestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 826 pageRequestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "5"); 827 Map<String, String> pageHoldRequestMap = new HashMap<String, String>(); 828 pageHoldRequestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 829 pageHoldRequestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "6"); 830 Map<String, String> copyRequestMap = new HashMap<String, String>(); 831 copyRequestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 832 copyRequestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "7"); 833 Map<String, String> inTransitRequestMap = new HashMap<String, String>(); 834 inTransitRequestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 835 inTransitRequestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "8"); 836 List<OleDeliverRequestBo> recallList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, recallRequestMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 837 List<OleDeliverRequestBo> recallHoldList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, recallHoldRequestMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 838 List<OleDeliverRequestBo> holdList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, holdRequestMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 839 List<OleDeliverRequestBo> holdHoldList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, holdHoldRequestMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 840 List<OleDeliverRequestBo> pageList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, pageRequestMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 841 List<OleDeliverRequestBo> pageHoldList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, pageHoldRequestMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 842 List<OleDeliverRequestBo> copyList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, copyRequestMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 843 List<OleDeliverRequestBo> inTransitList = (List<OleDeliverRequestBo>) businessObjectService.findMatchingOrderBy(OleDeliverRequestBo.class, inTransitRequestMap, OLEConstants.OleDeliverRequest.QUEUE_POSITION, true); 844 if (oleDeliverRequestBo.getOleDeliverRequestType().getRequestTypeCode().contains(OLEConstants.OleDeliverRequest.RECALL_DELIVERY)) { 845 recallList.add(oleDeliverRequestBo); 846 } else if (oleDeliverRequestBo.getOleDeliverRequestType().getRequestTypeCode().contains(OLEConstants.OleDeliverRequest.HOLD_DELIVERY)) { 847 holdList.add(oleDeliverRequestBo); 848 } else if (oleDeliverRequestBo.getOleDeliverRequestType().getRequestTypeCode().contains(OLEConstants.OleDeliverRequest.PAGE_DELIVERY)) { 849 pageList.add(oleDeliverRequestBo); 850 } else if (oleDeliverRequestBo.getOleDeliverRequestType().getRequestTypeCode().contains(OLEConstants.OleDeliverRequest.COPY)) { 851 copyList.add(oleDeliverRequestBo); 852 } else if (oleDeliverRequestBo.getOleDeliverRequestType().getRequestTypeCode().contains(OLEConstants.OleDeliverRequest.INTRANSIT)) { 853 inTransitList.add(oleDeliverRequestBo); 854 } else if (oleDeliverRequestBo.getOleDeliverRequestType().getRequestTypeCode().contains(OLEConstants.OleDeliverRequest.RECALL_HOLD)) { 855 recallHoldList.add(oleDeliverRequestBo); 856 } else if (oleDeliverRequestBo.getOleDeliverRequestType().getRequestTypeCode().contains(OLEConstants.OleDeliverRequest.HOLD_HOLD)) { 857 holdHoldList.add(oleDeliverRequestBo); 858 } else if (oleDeliverRequestBo.getOleDeliverRequestType().getRequestTypeCode().contains(OLEConstants.OleDeliverRequest.PAGE_HOLD)) { 859 pageHoldList.add(oleDeliverRequestBo); 860 } 861 OleDeliverRequestBo oleDeliverRequestBo1; 862 for (int i = 0; i < orderQueue.size(); i++) { 863 if (orderQueue.get(i).equals(OLEConstants.OleDeliverRequest.RECALL) && recallList.size() > 0) { 864 for (int x = 0; x < recallList.size(); x++) { 865 oleDeliverRequestBo1 = (OleDeliverRequestBo) ObjectUtils.deepCopy(recallList.get(x)); 866 oleDeliverRequestBo1.setBorrowerQueuePosition(this.queuePosition + 1); 867 this.queuePosition = this.queuePosition + 1; 868 finalList.add(oleDeliverRequestBo1); 869 870 } 871 } 872 if (orderQueue.get(i).equals(OLEConstants.OleDeliverRequest.HOLD) && holdList.size() > 0) { 873 for (int x = 0; x < holdList.size(); x++) { 874 oleDeliverRequestBo1 = (OleDeliverRequestBo) ObjectUtils.deepCopy(holdList.get(x)); 875 oleDeliverRequestBo1.setBorrowerQueuePosition(this.queuePosition + 1); 876 this.queuePosition = this.queuePosition + 1; 877 finalList.add(oleDeliverRequestBo1); 878 879 } 880 } 881 if (orderQueue.get(i).equals(OLEConstants.OleDeliverRequest.PAGE) && pageList.size() > 0) { 882 for (int x = 0; x < pageList.size(); x++) { 883 oleDeliverRequestBo1 = (OleDeliverRequestBo) ObjectUtils.deepCopy(pageList.get(x)); 884 oleDeliverRequestBo1.setBorrowerQueuePosition(this.queuePosition + 1); 885 this.queuePosition = this.queuePosition + 1; 886 finalList.add(oleDeliverRequestBo1); 887 } 888 } 889 if (orderQueue.get(i).equals(OLEConstants.OleDeliverRequest.RECALL) && recallHoldList.size() > 0) { 890 for (int x = 0; x < recallHoldList.size(); x++) { 891 oleDeliverRequestBo1 = (OleDeliverRequestBo) ObjectUtils.deepCopy(recallHoldList.get(x)); 892 oleDeliverRequestBo1.setBorrowerQueuePosition(this.queuePosition + 1); 893 this.queuePosition = this.queuePosition + 1; 894 finalList.add(oleDeliverRequestBo1); 895 896 } 897 } 898 if (orderQueue.get(i).equals(OLEConstants.OleDeliverRequest.HOLD) && holdHoldList.size() > 0) { 899 for (int x = 0; x < holdHoldList.size(); x++) { 900 oleDeliverRequestBo1 = (OleDeliverRequestBo) ObjectUtils.deepCopy(holdHoldList.get(x)); 901 oleDeliverRequestBo1.setBorrowerQueuePosition(this.queuePosition + 1); 902 this.queuePosition = this.queuePosition + 1; 903 finalList.add(oleDeliverRequestBo1); 904 905 } 906 } 907 if (orderQueue.get(i).equals(OLEConstants.OleDeliverRequest.PAGE) && pageHoldList.size() > 0) { 908 for (int x = 0; x < pageHoldList.size(); x++) { 909 oleDeliverRequestBo1 = (OleDeliverRequestBo) ObjectUtils.deepCopy(pageHoldList.get(x)); 910 oleDeliverRequestBo1.setBorrowerQueuePosition(this.queuePosition + 1); 911 this.queuePosition = this.queuePosition + 1; 912 finalList.add(oleDeliverRequestBo1); 913 } 914 } 915 if (orderQueue.get(i).equals(OLEConstants.OleDeliverRequest.COPY) && copyList.size() > 0) { 916 for (int x = 0; x < copyList.size(); x++) { 917 oleDeliverRequestBo1 = (OleDeliverRequestBo) ObjectUtils.deepCopy(copyList.get(x)); 918 oleDeliverRequestBo1.setBorrowerQueuePosition(this.queuePosition + 1); 919 this.queuePosition = this.queuePosition + 1; 920 finalList.add(oleDeliverRequestBo1); 921 922 } 923 } 924 if (orderQueue.get(i).equals(OLEConstants.OleDeliverRequest.INTRANSIT) && inTransitList.size() > 0) { 925 for (int x = 0; x < inTransitList.size(); x++) { 926 oleDeliverRequestBo1 = (OleDeliverRequestBo) ObjectUtils.deepCopy(inTransitList.get(x)); 927 oleDeliverRequestBo1.setBorrowerQueuePosition(this.queuePosition + 1); 928 this.queuePosition = this.queuePosition + 1; 929 finalList.add(oleDeliverRequestBo1); 930 931 } 932 } 933 } 934 for (int i = 0; i < finalList.size(); i++) { 935 if (finalList.get(i).getRequestId() == null) { 936 oleDeliverRequestBo.setBorrowerQueuePosition(finalList.get(i).getBorrowerQueuePosition()); 937 finalList.remove(finalList.get(i)); 938 } 939 } 940 businessObjectService.save(finalList); 941 this.queuePosition = 0; 942 return oleDeliverRequestBo; 943 } 944 945 /** 946 * Thsi method is to check whether the item is available in doc store or not 947 * 948 * @param oleDeliverRequestBo 949 * @return boolean 950 */ 951 public boolean isItemAvailbleInDocstore(OleDeliverRequestBo oleDeliverRequestBo) { 952 LOG.debug("Inside isItemAvailbleInDocstore"); 953 boolean available = false; 954 Map<String, String> itemMap = new HashMap<String, String>(); 955 try { 956 String itemUUID = ""; 957 org.kuali.ole.docstore.common.document.Item item = new ItemOleml(); 958 org.kuali.ole.docstore.common.search.SearchParams search_Params = new org.kuali.ole.docstore.common.search.SearchParams(); 959 SearchResponse searchResponse = null; 960 search_Params.getSearchConditions().add(search_Params.buildSearchCondition("", search_Params.buildSearchField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), item.ITEM_BARCODE, oleDeliverRequestBo.getItemId()), "")); 961 962 963 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "id")); 964 ; 965 966 /* Map<String,String> map=new HashMap<>(); 967 map.put(item.BARCODE, itemBarcode); 968 item=getDocstoreClientLocator().getDocstoreClient().findItem(map);*/ 969 970 searchResponse = getDocstoreClientLocator().getDocstoreClient().search(search_Params); 971 for (SearchResult searchResult : searchResponse.getSearchResults()) { 972 for (SearchResultField searchResultField : searchResult.getSearchResultFields()) { 973 String fieldName = searchResultField.getFieldName(); 974 String fieldValue = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : ""; 975 976 if (fieldName.equalsIgnoreCase("id") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("item")) { 977 itemUUID = fieldValue; 978 } 979 980 } 981 } 982 983 984 oleDeliverRequestBo.setItemUuid(itemUUID); 985 } catch (Exception e) { 986 LOG.error(e, e); 987 //To change body of catch statement use File | Settings | File Templates. 988 } 989 // itemMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 990 OleItemSearch itemSearchList = docstoreUtil.getOleItemSearchList(oleDeliverRequestBo.getItemUuid()); 991 if (itemSearchList != null) { 992 oleDeliverRequestBo.setTitle(itemSearchList.getTitle()); 993 oleDeliverRequestBo.setAuthor(itemSearchList.getAuthor()); 994 oleDeliverRequestBo.setCallNumber(itemSearchList.getCallNumber()); 995 oleDeliverRequestBo.setItemType(itemSearchList.getItemType()); 996 } 997 try { 998 // Map docStoreDetails = loanProcessor.getItemDetailsByUUID(oleDeliverRequestBo.getItemId()); 999 String itemXml = loanProcessor.getItemXML(oleDeliverRequestBo.getItemUuid()); 1000 org.kuali.ole.docstore.common.document.content.instance.Item oleItem = loanProcessor.getItemPojo(itemXml); 1001 1002 oleDeliverRequestBo.setCopyNumber(oleItem.getCopyNumber()); 1003 if (oleItem.getItemStatus() != null) { 1004 oleDeliverRequestBo.setItemStatus(oleItem.getItemStatus().getCodeValue()); 1005 } 1006 oleDeliverRequestBo.setShelvingLocation(getShelvingLocation(oleItem.getLocation())); 1007 available = true; 1008 } catch (Exception e) { 1009 LOG.error(ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.INVAL_LOC), e); //To change body of catch statement use File | Settings | File Templates. 1010 } 1011 return available; 1012 } 1013 1014 public OleDeliverRequestBo populateItemDetailsToRequest(OleDeliverRequestBo oleDeliverRequestBo, OleItemSearch oleItemSearch) { 1015 LOG.debug("Inside populateItemDetailsToRequest"); 1016 if (oleDeliverRequestBo != null && oleItemSearch != null) { 1017 oleDeliverRequestBo.setAuthor(oleItemSearch.getAuthor()); 1018 oleDeliverRequestBo.setTitle(oleItemSearch.getTitle()); 1019 oleDeliverRequestBo.setCallNumber(oleItemSearch.getCallNumber()); 1020 oleDeliverRequestBo.setCopyNumber(oleItemSearch.getCopyNumber()); 1021 oleDeliverRequestBo.setItemType(oleItemSearch.getItemType()); 1022 oleDeliverRequestBo.setItemStatus(oleItemSearch.getItemStatus()); 1023 oleItemSearch.setShelvingLocation(oleDeliverRequestBo.getShelvingLocation()); 1024 } 1025 return oleDeliverRequestBo; 1026 } 1027 1028 1029 public OleDeliverRequestBo generateRecallNotice(OleDeliverRequestBo oleDeliverRequestBo) throws Exception { 1030 Map<String, String> loanMap = new HashMap<String, String>(); 1031 loanMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 1032 List<OleLoanDocument> loanDocuments = (List<OleLoanDocument>) businessObjectService.findMatching(OleLoanDocument.class, loanMap); 1033 OleLoanDocument oleLoanDocument = loanDocuments.get(0); 1034 Map<String, String> patronMap = new HashMap<String, String>(); 1035 patronMap.put(OLEConstants.OleDeliverRequest.PATRON_ID, oleLoanDocument.getPatronId()); 1036 List<OlePatronDocument> patronDocumentList = (List<OlePatronDocument>) businessObjectService.findMatching(OlePatronDocument.class, patronMap); 1037 OleNoticeBo oleNoticeBo = new OleNoticeBo(); 1038 org.kuali.ole.docstore.common.document.content.instance.Item item; 1039 if (patronDocumentList.size() > 0) { 1040 OlePatronDocument olePatronDocument = patronDocumentList.get(0); 1041 EntityTypeContactInfoBo entityTypeContactInfoBo = olePatronDocument.getEntity().getEntityTypeContactInfos().get(0); 1042 oleNoticeBo.setPatronName(olePatronDocument.getEntity().getNames().get(0).getFirstName() + " " + oleDeliverRequestBo.getOlePatron().getEntity().getNames().get(0).getLastName()); 1043 oleNoticeBo.setPatronAddress(getPatronPreferredAddress(entityTypeContactInfoBo) != null ? getPatronPreferredAddress(entityTypeContactInfoBo) : ""); 1044 oleNoticeBo.setPatronEmailAddress(getPatronHomeEmailId(entityTypeContactInfoBo) != null ? getPatronHomeEmailId(entityTypeContactInfoBo) : ""); 1045 oleNoticeBo.setPatronPhoneNumber(getPatronHomePhoneNumber(entityTypeContactInfoBo) != null ? getPatronHomePhoneNumber(entityTypeContactInfoBo) : ""); 1046 } 1047 oleNoticeBo.setAuthor(oleDeliverRequestBo.getAuthor() != null ? oleDeliverRequestBo.getAuthor() : ""); 1048 oleNoticeBo.setCirculationDeskAddress(""); 1049 oleNoticeBo.setCirculationDeskName(""); 1050 oleNoticeBo.setCirculationDeskEmailAddress(""); 1051 oleNoticeBo.setCirculationDeskPhoneNumber(""); 1052 oleNoticeBo.setItemCallNumber(oleDeliverRequestBo.getCallNumber() != null ? oleDeliverRequestBo.getCallNumber() : ""); 1053 oleNoticeBo.setItemShelvingLocation(oleDeliverRequestBo.getShelvingLocation() != null ? oleDeliverRequestBo.getShelvingLocation() : ""); 1054 oleNoticeBo.setItemId(oleDeliverRequestBo.getItemId() != null ? oleDeliverRequestBo.getItemId() : ""); 1055 oleNoticeBo.setTitle(oleDeliverRequestBo.getTitle() != null ? oleDeliverRequestBo.getTitle() : ""); 1056 oleNoticeBo.setOleItem(getItem(oleDeliverRequestBo.getItemUuid())); 1057 oleNoticeBo.setOlePatron(oleDeliverRequestBo.getOlePatron()); 1058 oleNoticeBo.setVolumeNumber(oleNoticeBo.getOleItem().getVolumeNumber() != null ? oleNoticeBo.getOleItem().getVolumeNumber() : ""); 1059 oleNoticeBo.setOriginalDueDate(oleLoanDocument.getLoanDueDate()); 1060 oleNoticeBo.setNewDueDate(oleDeliverRequestBo.getNewDueDate()); 1061 oleNoticeBo.setOriginalDueDate(oleDeliverRequestBo.getOriginalDueDate()); 1062 /*if (oleDeliverRequestBo.getRecallDueDate() != null) { 1063 oleNoticeBo.setNewDueDate(oleDeliverRequestBo.getRecallDueDate()); 1064 } else { 1065 oleNoticeBo.setNewDueDate(oleLoanDocument.getLoanDueDate()); 1066 }*/ 1067 oleNoticeBo.setNoticeName(OLEConstants.NOTICE_RECALL); 1068 String noticeContent = getLoanProcessor().getParameter(OLEConstants.OleDeliverRequest.RECALL_BODY); 1069 oleNoticeBo.setNoticeSpecificContent(noticeContent); 1070 // oleNoticeBo = setPatronDetailsForNotice(oleNoticeBo,oleDeliverRequestBo.getOlePatron()); 1071 OleDeliverBatchServiceImpl oleDeliverBatchService = new OleDeliverBatchServiceImpl(); 1072 List<OleNoticeBo> oleNoticeBos = new ArrayList<OleNoticeBo>(); 1073 String noticeType = getLoanProcessor().getParameter(OLEConstants.OleDeliverRequest.RECALL_NOTICE_TYPE); 1074 oleNoticeBos.add(oleNoticeBo); 1075 if (noticeType.equalsIgnoreCase(OLEConstants.EMAIL)) { 1076 if (oleNoticeBo.getPatronEmailAddress() != null && !oleNoticeBo.getPatronEmailAddress().isEmpty()) { 1077 List list = oleDeliverBatchService.getNoticeForPatron(oleNoticeBos); 1078 String content = list.toString(); 1079 content = content.replace('[', ' '); 1080 content = content.replace(']', ' '); 1081 if (!content.trim().equals("")) { 1082 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer"); 1083 String replyToEmail = getLoanProcessor().getReplyToEmail(oleNoticeBo.getItemShelvingLocation()); 1084 if (replyToEmail != null) { 1085 oleMailer.sendEmail(new EmailFrom(replyToEmail), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(content), true); 1086 } else { 1087 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL); 1088 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) { 1089 fromAddress = OLEConstants.KUALI_MAIL; 1090 } 1091 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(content), true); 1092 } 1093 } else { 1094 for (OleNoticeBo oleNoticeBo1 : oleNoticeBos) { 1095 LOG.info("Notice Type :" + oleNoticeBo1.getNoticeName() + " " + "Item Barcode : " + oleNoticeBo1.getItemId() + " " + "Patron Name :" + oleNoticeBo1.getPatronName()); 1096 } 1097 } 1098 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress()); 1099/* 1100 Mailer mailer = CoreApiServiceLocator.getMailer(); 1101 mailer.sendEmail(new EmailFrom(OLEConstants.KUALI_MAIL), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(list.toString()), true); 1102 */ 1103 } 1104 } else if (noticeType.equalsIgnoreCase(OLEConstants.SMS)) { 1105 //oleNoticeBos.add(oleNoticeBo); 1106 Map map = oleDeliverBatchService.getSMSForPatron(oleNoticeBos); 1107 HashMap sms = (HashMap) map.get(OLEConstants.OleDeliverRequest.RECALL); 1108 Iterator it = sms.entrySet().iterator(); 1109 while (it.hasNext()) { 1110 Map.Entry pairs = (Map.Entry) it.next(); 1111 String patronPhoneNumber = oleNoticeBo.getPatronPhoneNumber(); 1112 OleSms oleSms = new OleSms(); 1113 oleSms.sendSms("", patronPhoneNumber, (String) pairs.getValue()); 1114 } 1115 1116 } 1117 if (noticeType.equalsIgnoreCase(OLEConstants.MAIL) || noticeType.equalsIgnoreCase(OLEConstants.EMAIL)) { 1118 //oleNoticeBos.add(oleNoticeBo); 1119 oleDeliverBatchService.getPdfNoticeForPatron(oleNoticeBos); 1120 LOG.info("Recall Notice Pdf generated for item Id" + oleNoticeBo.getItemId()); 1121 } 1122 oleDeliverRequestBo = (OleDeliverRequestBo) ObjectUtils.deepCopy(oleDeliverRequestBo); 1123 oleDeliverRequestBo.setRecallNoticeSentDate(new java.sql.Date(System.currentTimeMillis())); 1124 return oleDeliverRequestBo; 1125 } 1126 1127 1128 public void generateOnHoldNotice() throws Exception { 1129 1130 List<OleDeliverRequestBo> finalDeliverRequestBoList = new ArrayList<OleDeliverRequestBo>(); 1131 Map<String, String> onHoldNoticeMap = new HashMap<String, String>(); 1132 onHoldNoticeMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "2"); 1133 List<OleDeliverRequestBo> oleDeliverRequestBoList = (List<OleDeliverRequestBo>) businessObjectService.findMatching(OleDeliverRequestBo.class, onHoldNoticeMap); 1134 Map<String, String> onHoldHoldNoticeMap = new HashMap<String, String>(); 1135 onHoldHoldNoticeMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "4"); 1136 List<OleDeliverRequestBo> oleDeliverRequestBoList1 = (List<OleDeliverRequestBo>) businessObjectService.findMatching(OleDeliverRequestBo.class, onHoldHoldNoticeMap); 1137 oleDeliverRequestBoList.addAll(oleDeliverRequestBoList1); 1138 OleDeliverRequestBo oleDeliverRequestBo; 1139 List<OleNoticeBo> noticesList = new ArrayList<OleNoticeBo>(); 1140 EntityTypeContactInfoBo entityTypeContactInfoBo; 1141 OleNoticeBo oleNoticeBo; 1142 org.kuali.ole.docstore.common.document.content.instance.Item item; 1143 for (int i = 0; i < oleDeliverRequestBoList.size(); i++) { 1144 if (docstoreUtil.isItemAvailableInDocStore(oleDeliverRequestBoList.get(i))) { 1145 item = oleDeliverRequestBoList.get(i).getOleItem(); 1146 if (item != null && item.getItemStatus() != null && item.getItemStatus().getCodeValue() != null && item.getItemStatus().getCodeValue().equals(OLEConstants.ITEM_STATUS_ON_HOLD) && oleDeliverRequestBoList.get(i).getOnHoldNoticeSentDate() == null) { 1147 entityTypeContactInfoBo = oleDeliverRequestBoList.get(i).getOlePatron().getEntity().getEntityTypeContactInfos().get(0); 1148 oleNoticeBo = new OleNoticeBo(); 1149 oleNoticeBo.setAuthor(oleDeliverRequestBoList.get(i).getAuthor()); 1150 oleNoticeBo.setCirculationDeskAddress(""); 1151 oleNoticeBo.setCirculationDeskName(""); 1152 oleNoticeBo.setCirculationDeskEmailAddress(""); 1153 oleNoticeBo.setCirculationDeskPhoneNumber(""); 1154 oleNoticeBo.setPatronName(oleDeliverRequestBoList.get(i).getOlePatron().getEntity().getNames().get(0).getFirstName() + " " + oleDeliverRequestBoList.get(i).getOlePatron().getEntity().getNames().get(0).getLastName()); 1155 oleNoticeBo.setPatronAddress(getPatronPreferredAddress(entityTypeContactInfoBo) != null ? getPatronPreferredAddress(entityTypeContactInfoBo) : ""); 1156 oleNoticeBo.setPatronEmailAddress(getPatronHomeEmailId(entityTypeContactInfoBo) != null ? getPatronHomeEmailId(entityTypeContactInfoBo) : ""); 1157 oleNoticeBo.setPatronPhoneNumber(getPatronHomePhoneNumber(entityTypeContactInfoBo) != null ? getPatronHomePhoneNumber(entityTypeContactInfoBo) : ""); 1158 oleNoticeBo.setItemCallNumber(oleDeliverRequestBoList.get(i).getCallNumber() != null ? oleDeliverRequestBoList.get(i).getCallNumber() : ""); 1159 oleNoticeBo.setItemShelvingLocation(oleDeliverRequestBoList.get(i).getShelvingLocation() != null ? oleDeliverRequestBoList.get(i).getShelvingLocation() : ""); 1160 oleNoticeBo.setItemId(oleDeliverRequestBoList.get(i).getItemId() != null ? oleDeliverRequestBoList.get(i).getItemId() : ""); 1161 oleNoticeBo.setTitle(oleDeliverRequestBoList.get(i).getTitle() != null ? oleDeliverRequestBoList.get(i).getTitle() : ""); 1162 oleNoticeBo.setOleItem(item); 1163 oleNoticeBo.setOlePatron(oleDeliverRequestBoList.get(i).getOlePatron()); 1164 oleNoticeBo.setVolumeNumber(item.getVolumeNumber() != null ? item.getVolumeNumber() : ""); 1165 oleNoticeBo.setNewDueDate(new Date()); 1166 oleNoticeBo.setOriginalDueDate(new Date()); 1167 oleNoticeBo.setNoticeName(OLEConstants.NOTICE_ONHOLD); 1168 oleNoticeBo.setCirculationDeskName(oleDeliverRequestBoList.get(i).getOlePickUpLocation().getCirculationDeskPublicName()); 1169 String circulationDeskId = oleDeliverRequestBoList.get(i).getPickUpLocationId(); 1170 int noDays = 0; 1171 Map<String, String> mapCirculationDesk = new HashMap<String, String>(); 1172 mapCirculationDesk.put("circulationDeskId", circulationDeskId); 1173 List<OleCirculationDesk> oleCirculationDesks = (List<OleCirculationDesk>) KRADServiceLocator.getBusinessObjectService().findMatching(OleCirculationDesk.class, mapCirculationDesk); 1174 if (oleCirculationDesks.size() > 0) { 1175 OleCirculationDesk oleCirculationDesk = oleCirculationDesks.get(0); 1176 noDays = Integer.parseInt(oleCirculationDesk.getOnHoldDays()); 1177 } 1178 Calendar calendar = Calendar.getInstance(); 1179 calendar.add(Calendar.DATE, noDays); 1180 Date date = calendar.getTime(); 1181 oleNoticeBo.setExpiredOnHoldDate(date); 1182 String maxNumOfDays = oleDeliverRequestBoList.get(i).getOlePickUpLocation().getOnHoldDays() != null ? oleDeliverRequestBoList.get(i).getOlePickUpLocation().getOnHoldDays() : loanProcessor.getParameter(OLEConstants.MAX_NO_OF_DAYS_ON_HOLD); 1183 Integer maxNumberOfDaysOnHold = new Integer(maxNumOfDays); 1184 oleNoticeBo.setOnHoldDueDate(dateAdd(oleDeliverRequestBoList.get(i).getCreateDate(), maxNumberOfDaysOnHold)); 1185 String noticeContent = getLoanProcessor().getParameter(OLEConstants.OleDeliverRequest.ONHOLD_BODY); 1186 oleNoticeBo.setNoticeSpecificContent(noticeContent); 1187 noticesList.add(oleNoticeBo); 1188 OleDeliverBatchServiceImpl oleDeliverBatchService = new OleDeliverBatchServiceImpl(); 1189 String agendaName = OLEConstants.BATCH_PROGRAM_AGENDA; 1190 HashMap<String, Object> termValues = new HashMap<String, Object>(); 1191 OleCirculationDesk oleCirculationDesk = oleDeliverRequestBoList.get(i).getOlePickUpLocation(); 1192 OlePatronDocument olePatronDocument = oleDeliverRequestBoList.get(i).getOlePatron(); 1193 String deskLocation = oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskCode() : ""; 1194 String deskLocationName = oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : ""; 1195 termValues.put(OLEConstants.BORROWER_TYPE, olePatronDocument.getOleBorrowerType().getBorrowerTypeCode()); 1196 termValues.put(OLEConstants.DESK_LOCATION, deskLocation); 1197 termValues.put(OLEConstants.NOTICE, OLEConstants.NOTICE_ONHOLD); 1198 LOG.info("termValues.toString()" + termValues.toString()); 1199 EngineResults engineResults = loanProcessor.getEngineResults(agendaName, termValues); 1200 String noticeType = (String) engineResults.getAttribute(OLEConstants.NOTICE_TYPE); 1201 LOG.info("**************" + noticeType); 1202 noticeType = noticeType != null ? noticeType : getLoanProcessor().getParameter(OLEConstants.OleDeliverRequest.ONHOLD_NOTICE_TYPE); 1203 if (noticeType != null && (noticeType.equalsIgnoreCase(OLEConstants.EMAIL) || noticeType.equalsIgnoreCase(OLEConstants.MAIL))) { 1204 LOG.info("noticesList.size()" + noticesList.size()); 1205 oleDeliverBatchService.getPdfNoticeForPatron(noticesList); 1206 LOG.info("OnHold Notice Pdf generated for item Id" + oleNoticeBo.getItemId()); 1207 } 1208 if (noticeType != null && noticeType.equalsIgnoreCase(OLEConstants.EMAIL)) { 1209 if (oleNoticeBo.getPatronEmailAddress() != null && !oleNoticeBo.getPatronEmailAddress().isEmpty()) { 1210 List list = oleDeliverBatchService.getNoticeForPatron(noticesList); 1211 String content = list.toString(); 1212 content = content.replace('[', ' '); 1213 content = content.replace(']', ' '); 1214 if (!content.trim().equals("")) { 1215 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer"); 1216 if (oleDeliverRequestBoList.get(i).getOlePickUpLocation() != null && StringUtils.isNotBlank(oleDeliverRequestBoList.get(i).getOlePickUpLocation().getReplyToEmail())) { 1217 oleMailer.sendEmail(new EmailFrom(oleDeliverRequestBoList.get(i).getOlePickUpLocation().getReplyToEmail()), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(content), true); 1218 } else { 1219 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL); 1220 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) { 1221 fromAddress = OLEConstants.KUALI_MAIL; 1222 } 1223 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(content), true); 1224 } 1225 } else { 1226 for (OleNoticeBo oleNoticeBo1 : noticesList) { 1227 LOG.info("Notice Type :" + oleNoticeBo1.getNoticeName() + " " + "Item Barcode : " + oleNoticeBo1.getItemId() + " " + "Patron Name :" + oleNoticeBo1.getPatronName()); 1228 } 1229 } 1230 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress()); 1231 /* Mailer mailer = CoreApiServiceLocator.getMailer(); 1232 mailer.sendEmail(new EmailFrom(OLEConstants.KUALI_MAIL), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(list.toString()), true); 1233 */ 1234 } 1235 } else if (noticeType != null && noticeType.equalsIgnoreCase(OLEConstants.SMS)) { 1236 Map map = oleDeliverBatchService.getSMSForPatron(noticesList); 1237 HashMap sms = (HashMap) map.get(OLEConstants.NOTICE_ONHOLD); 1238 Iterator it = sms.entrySet().iterator(); 1239 while (it.hasNext()) { 1240 Map.Entry pairs = (Map.Entry) it.next(); 1241 String patronPhoneNumber = oleNoticeBo.getPatronPhoneNumber(); 1242 OleSms oleSms = new OleSms(); 1243 oleSms.sendSms("", patronPhoneNumber, (String) pairs.getValue()); 1244 } 1245 } 1246 // To do send Notice 1247 oleDeliverRequestBoList.get(i).setOleItem(null); 1248 oleDeliverRequestBo = (OleDeliverRequestBo) ObjectUtils.deepCopy(oleDeliverRequestBoList.get(i)); 1249 oleDeliverRequestBo.setOnHoldNoticeSentDate(new java.sql.Date(System.currentTimeMillis())); 1250 finalDeliverRequestBoList.add(oleDeliverRequestBo); 1251 } 1252 } 1253 businessObjectService.save(finalDeliverRequestBoList); 1254 } 1255 } 1256 1257 public void generateRequestExpirationNotice() throws Exception { 1258 List<OleDeliverRequestBo> oleDeliverRequestBoList = new ArrayList<OleDeliverRequestBo>(); 1259 OleDeliverBatchServiceImpl oleDeliverBatchService = new OleDeliverBatchServiceImpl(); 1260 oleDeliverRequestBoList = (List<OleDeliverRequestBo>) businessObjectService.findAll(OleDeliverRequestBo.class); 1261 SimpleDateFormat fmt = new SimpleDateFormat(OLEConstants.OleDeliverRequest.DATE_FORMAT); 1262 EntityTypeContactInfoBo entityTypeContactInfoBo; 1263 List<OleNoticeBo> noticesList = new ArrayList<OleNoticeBo>(); 1264 org.kuali.ole.docstore.common.document.content.instance.Item item; 1265 String noticeType = null; 1266 OleNoticeBo oleNoticeBo = new OleNoticeBo(); 1267 if (oleDeliverRequestBoList.size() > 0) { 1268 for (int i = 0; i < oleDeliverRequestBoList.size(); i++) { 1269 if (docstoreUtil.isItemAvailableInDocStore(oleDeliverRequestBoList.get(i))) { 1270 // processItem(oleDeliverRequestBoList.get(i)); 1271 item = oleDeliverRequestBoList.get(i).getOleItem(); 1272 LOG.info("Expiration Date :" + oleDeliverRequestBoList.get(i).getRequestExpiryDate()); 1273 if (oleDeliverRequestBoList.get(i).getOlePatron().isCourtesyNotice() && (fmt.format(oleDeliverRequestBoList.get(i).getRequestExpiryDate())).compareTo(fmt.format(new Date(System.currentTimeMillis()))) <= 0) { 1274 LOG.info("Inside Expiration Date :" + oleDeliverRequestBoList.get(i).getRequestExpiryDate()); 1275 entityTypeContactInfoBo = oleDeliverRequestBoList.get(i).getOlePatron().getEntity().getEntityTypeContactInfos().get(0); 1276 oleNoticeBo = new OleNoticeBo(); 1277 oleNoticeBo.setAuthor(oleDeliverRequestBoList.get(i).getAuthor()); 1278 oleNoticeBo.setCirculationDeskAddress(""); 1279 oleNoticeBo.setCirculationDeskName(""); 1280 oleNoticeBo.setCirculationDeskEmailAddress(""); 1281 oleNoticeBo.setCirculationDeskPhoneNumber(""); 1282 oleNoticeBo.setPatronName(oleDeliverRequestBoList.get(i).getOlePatron().getEntity().getNames().get(0).getFirstName() + " " + oleDeliverRequestBoList.get(i).getOlePatron().getEntity().getNames().get(0).getLastName()); 1283 oleNoticeBo.setPatronAddress(getPatronPreferredAddress(entityTypeContactInfoBo) != null ? getPatronPreferredAddress(entityTypeContactInfoBo) : ""); 1284 oleNoticeBo.setPatronEmailAddress(getPatronHomeEmailId(entityTypeContactInfoBo) != null ? getPatronHomeEmailId(entityTypeContactInfoBo) : ""); 1285 oleNoticeBo.setPatronPhoneNumber(getPatronHomePhoneNumber(entityTypeContactInfoBo) != null ? getPatronHomePhoneNumber(entityTypeContactInfoBo) : ""); 1286 oleNoticeBo.setItemCallNumber(oleDeliverRequestBoList.get(i).getCallNumber() != null ? oleDeliverRequestBoList.get(i).getCallNumber() : ""); 1287 oleNoticeBo.setItemShelvingLocation(oleDeliverRequestBoList.get(i).getShelvingLocation() != null ? oleDeliverRequestBoList.get(i).getShelvingLocation() : ""); 1288 oleNoticeBo.setItemId(oleDeliverRequestBoList.get(i).getItemId() != null ? oleDeliverRequestBoList.get(i).getItemId() : ""); 1289 oleNoticeBo.setTitle(oleDeliverRequestBoList.get(i).getTitle() != null ? oleDeliverRequestBoList.get(i).getTitle() : ""); 1290 oleNoticeBo.setOleItem(item); 1291 oleNoticeBo.setOlePatron(oleDeliverRequestBoList.get(i).getOlePatron()); 1292 oleNoticeBo.setVolumeNumber(item.getVolumeNumber() != null ? item.getVolumeNumber() : ""); 1293 oleNoticeBo.setNewDueDate(new Date()); 1294 oleNoticeBo.setOriginalDueDate(new Date()); 1295 oleNoticeBo.setNoticeName(OLEConstants.OleDeliverRequest.EXPIRED_REQUEST); 1296 String noticeContent = getLoanProcessor().getParameter(OLEConstants.OleDeliverRequest.EXP_HOLD_NOTICE_CONTENT); 1297 oleNoticeBo.setNoticeSpecificContent(noticeContent); 1298 noticesList.add(oleNoticeBo); 1299 String agendaName = OLEConstants.BATCH_PROGRAM_AGENDA; 1300 HashMap<String, Object> termValues = new HashMap<String, Object>(); 1301 OleCirculationDesk oleCirculationDesk = oleDeliverRequestBoList.get(i).getOlePickUpLocation(); 1302 OlePatronDocument olePatronDocument = oleDeliverRequestBoList.get(i).getOlePatron(); 1303 String deskLocation = oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskCode() : ""; 1304 String deskLocationName = oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : ""; 1305 termValues.put(OLEConstants.BORROWER_TYPE, olePatronDocument.getOleBorrowerType().getBorrowerTypeCode()); 1306 termValues.put(OLEConstants.DESK_LOCATION, deskLocation); 1307 termValues.put(OLEConstants.NOTICE, OLEConstants.OleDeliverRequest.EXPIRED_REQUEST); 1308 LOG.info("termValues.toString()" + termValues.toString()); 1309 EngineResults engineResults = loanProcessor.getEngineResults(agendaName, termValues); 1310 noticeType = (String) engineResults.getAttribute(OLEConstants.NOTICE_TYPE); 1311 LOG.info("**************" + noticeType); 1312 noticeType = noticeType != null ? noticeType : getLoanProcessor().getParameter(OLEConstants.OleDeliverRequest.RQST_EXPR_NOTICE_TYPE); 1313 if (noticeType != null && noticeType.equalsIgnoreCase(OLEConstants.SMS)) { 1314 // noticesList.add(oleNoticeBo); 1315 Map map = oleDeliverBatchService.getSMSForPatron(noticesList); 1316 HashMap sms = (HashMap) map.get(OLEConstants.OleDeliverRequest.EXPIRED_REQUEST); 1317 Iterator it = sms.entrySet().iterator(); 1318 while (it.hasNext()) { 1319 Map.Entry pairs = (Map.Entry) it.next(); 1320 1321 String patronPhoneNumber = oleNoticeBo.getPatronPhoneNumber(); 1322 OleSms oleSms = new OleSms(); 1323 oleSms.sendSms("", patronPhoneNumber, (String) pairs.getValue()); 1324 } 1325 } 1326 } 1327 } 1328 if (noticeType != null && (noticeType.equalsIgnoreCase(OLEConstants.EMAIL) || noticeType.equalsIgnoreCase(OLEConstants.MAIL))) { 1329 oleDeliverBatchService.getPdfNoticeForPatron(noticesList); 1330 LOG.info("Request Expiration Notice Pdf generated for item Id"); 1331 } 1332 if (noticeType != null && noticeType.equalsIgnoreCase(OLEConstants.EMAIL)) { 1333 // noticesList.add(oleNoticeBo); 1334 List list = (List) oleDeliverBatchService.getNoticeForPatron(noticesList); 1335 String noticeContent = list.toString(); 1336 noticeContent = noticeContent.replace('[', ' '); 1337 noticeContent = noticeContent.replace(']', ' '); 1338 if (!noticeContent.trim().equals("")) { 1339 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer"); 1340 String replyToEmail = getLoanProcessor().getReplyToEmail(oleNoticeBo.getItemShelvingLocation()); 1341 if (replyToEmail != null) { 1342 oleMailer.sendEmail(new EmailFrom(replyToEmail), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(noticeContent), true); 1343 } else { 1344 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL); 1345 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) { 1346 fromAddress = OLEConstants.KUALI_MAIL; 1347 } 1348 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(noticeContent), true); 1349 } 1350 } else { 1351 for (OleNoticeBo oleNoticeBo1 : noticesList) { 1352 LOG.info("Notice Type :" + oleNoticeBo1.getNoticeName() + " " + "Item Barcode : " + oleNoticeBo1.getItemId() + " " + "Patron Name :" + oleNoticeBo1.getPatronName()); 1353 } 1354 } 1355 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress()); 1356 1357 } 1358 } 1359 } 1360 } 1361 1362 private java.sql.Date dateAdd(java.sql.Date in, int daysToAdd) { 1363 if (in == null) { 1364 return null; 1365 } 1366 GregorianCalendar cal = new GregorianCalendar(); 1367 cal.setTime(in); 1368 cal.add(Calendar.DAY_OF_MONTH, daysToAdd); 1369 return new java.sql.Date(cal.getTime().getTime()); 1370 } 1371 1372 public void deletingExpiredRequests() { 1373 LOG.info("Inside deletingExpiredRequests"); 1374 List<OleDeliverRequestBo> oleDeliverRequestBoList = new ArrayList<OleDeliverRequestBo>(); 1375 List<OleDeliverRequestBo> newOleDeliverRequestBoList = new ArrayList<OleDeliverRequestBo>(); 1376 try { 1377 oleDeliverRequestBoList = (List<OleDeliverRequestBo>) businessObjectService.findAll(OleDeliverRequestBo.class); 1378 businessObjectService.delete(oleDeliverRequestBoList); 1379 SimpleDateFormat fmt = new SimpleDateFormat(OLEConstants.OleDeliverRequest.DATE_FORMAT); 1380 for (int i = 0; i < oleDeliverRequestBoList.size(); i++) { 1381 if ((fmt.format(oleDeliverRequestBoList.get(i).getRequestExpiryDate())).compareTo(fmt.format(new Date(System.currentTimeMillis()))) > 0) { 1382 newOleDeliverRequestBoList.add(oleDeliverRequestBoList.get(i)); 1383 } 1384 } 1385 businessObjectService.save(newOleDeliverRequestBoList); 1386 } catch (Exception e) { 1387 businessObjectService.save(oleDeliverRequestBoList); 1388 LOG.error(e, e); 1389 } 1390 } 1391 1392 private org.kuali.ole.docstore.common.document.content.instance.Item getItem(String itemUUID) { 1393 LOG.debug("Inside getItem"); 1394 try { 1395 // Map docStoreDetails= loanProcessor.getItemDetails(itemBarCode); 1396 String itemXml = loanProcessor.getItemXML(itemUUID); 1397 org.kuali.ole.docstore.common.document.content.instance.Item oleItem = loanProcessor.getItemPojo(itemXml); 1398 return oleItem; 1399 } catch (Exception e) { 1400 LOG.error("Item not available in doc store", e); 1401 } 1402 return null; 1403 } 1404 1405 1406 private OleNoticeBo setPatronDetailsForNotice(OleNoticeBo oleNoticeBo, OlePatronDocument olePatronDocument) { 1407 LOG.debug("Inside setPatronDetailsForNotice"); 1408 if (oleNoticeBo.getAuthor() != null && olePatronDocument.getOlePatronId() != null) { 1409 oleNoticeBo.setPatronName(olePatronDocument.getName().getFirstName()); 1410 if (olePatronDocument.getAddresses().size() > 0) { 1411 oleNoticeBo.setPatronAddress(olePatronDocument.getAddresses().get(0).getLine1() + "/n" + olePatronDocument.getAddresses().get(0).getLine2() + "/n" + olePatronDocument.getAddresses().get(0).getCity()); 1412 } 1413 oleNoticeBo.setPatronEmailAddress(olePatronDocument.getEmailAddress()); 1414 oleNoticeBo.setPatronPhoneNumber(olePatronDocument.getPhoneNumber()); 1415 } 1416 return oleNoticeBo; 1417 } 1418 1419 1420 private void createRequestHistoryRecord(String requestId, String OperatorId, String loanTransactionNumber) { 1421 LOG.debug("Inside createRequestHistoryRecord"); 1422 Map<String, String> requestMap = new HashMap<String, String>(); 1423 requestMap.put(OLEConstants.OleDeliverRequest.REQUEST_ID, requestId); 1424 List<OleDeliverRequestBo> oleDeliverRequestBoList = (List<OleDeliverRequestBo>) businessObjectService.findMatching(OleDeliverRequestBo.class, requestMap); 1425 if (oleDeliverRequestBoList.size() > 0) { 1426 OleDeliverRequestBo oleDeliverRequestBo = oleDeliverRequestBoList.get(0); 1427 OleDeliverRequestHistoryRecord oleDeliverRequestHistoryRecord = new OleDeliverRequestHistoryRecord(); 1428 oleDeliverRequestHistoryRecord.setRequestId(oleDeliverRequestBo.getRequestId()); 1429 oleDeliverRequestHistoryRecord.setItemId(oleDeliverRequestBo.getItemId()); 1430 oleDeliverRequestHistoryRecord.setPatronId(oleDeliverRequestBo.getOlePatron()!=null?oleDeliverRequestBo.getOlePatron().getOlePatronId():null); 1431 oleDeliverRequestHistoryRecord.setArchiveDate(new java.sql.Date(System.currentTimeMillis())); 1432 oleDeliverRequestHistoryRecord.setPickUpLocationCode(oleDeliverRequestBo.getPickUpLocationCode()); 1433 oleDeliverRequestHistoryRecord.setOperatorId(OperatorId); 1434 oleDeliverRequestHistoryRecord.setDeliverRequestTypeCode(oleDeliverRequestBo.getRequestTypeCode()); 1435 oleDeliverRequestHistoryRecord.setPoLineItemNumber(""); 1436 oleDeliverRequestHistoryRecord.setLoanTransactionId(loanTransactionNumber); 1437 //oleDeliverRequestHistoryRecord.setMachineId(""); //commented for jira OLE-5675 1438 businessObjectService.save(oleDeliverRequestHistoryRecord); 1439 } 1440 businessObjectService.delete(oleDeliverRequestBoList); 1441 } 1442 1443 public OleDeliverRequestBo getOleDeliverRequestBo(String itemUUID) { 1444 1445 LOG.debug("Inside getOleDeliverRequestBo method"); 1446 Map<String, String> requestMap = new HashMap<String, String>(); 1447 requestMap.put(OLEConstants.ITEM_UUID, itemUUID); 1448 List<OleDeliverRequestBo> oleDeliverRequestBoList = (List<OleDeliverRequestBo>) businessObjectService.findMatching(OleDeliverRequestBo.class, requestMap); 1449 if (oleDeliverRequestBoList.size() > 0) 1450 return oleDeliverRequestBoList.get(0); 1451 return null; 1452 } 1453 1454 public String getPatronPreferredAddress(EntityTypeContactInfoBo entityTypeContactInfoBo) throws Exception { 1455 LOG.debug("Inside the getPatronPreferredAddress method"); 1456 String address = ""; 1457 if (entityTypeContactInfoBo.getAddresses() != null) { 1458 for (int i = 0; i < entityTypeContactInfoBo.getAddresses().size(); i++) { 1459 if (entityTypeContactInfoBo.getAddresses().get(i).isDefaultValue()) { 1460 if (entityTypeContactInfoBo.getAddresses().get(i).getLine1() != null) 1461 if (!entityTypeContactInfoBo.getAddresses().get(i).getLine1().isEmpty()) 1462 address += entityTypeContactInfoBo.getAddresses().get(i).getLine1() + ","; 1463 1464 if (entityTypeContactInfoBo.getAddresses().get(i).getLine2() != null) 1465 if (!entityTypeContactInfoBo.getAddresses().get(i).getLine2().isEmpty()) 1466 address += entityTypeContactInfoBo.getAddresses().get(i).getLine2() + ","; 1467 1468 if (entityTypeContactInfoBo.getAddresses().get(i).getLine3() != null) 1469 if (!entityTypeContactInfoBo.getAddresses().get(i).getLine3().isEmpty()) 1470 address += entityTypeContactInfoBo.getAddresses().get(i).getLine3() + ","; 1471 1472 if (entityTypeContactInfoBo.getAddresses().get(i).getCity() != null) 1473 if (!entityTypeContactInfoBo.getAddresses().get(i).getCity().isEmpty()) 1474 address += entityTypeContactInfoBo.getAddresses().get(i).getCity() + ","; 1475 1476 if (entityTypeContactInfoBo.getAddresses().get(i).getStateProvinceCode() != null) 1477 if (!entityTypeContactInfoBo.getAddresses().get(i).getStateProvinceCode().isEmpty()) 1478 address += entityTypeContactInfoBo.getAddresses().get(i).getStateProvinceCode() + ","; 1479 1480 if (entityTypeContactInfoBo.getAddresses().get(i).getCountryCode() != null) 1481 if (!entityTypeContactInfoBo.getAddresses().get(i).getCountryCode().isEmpty()) 1482 address += entityTypeContactInfoBo.getAddresses().get(i).getCountryCode() + ","; 1483 1484 if (entityTypeContactInfoBo.getAddresses().get(i).getPostalCode() != null) 1485 if (!entityTypeContactInfoBo.getAddresses().get(i).getPostalCode().isEmpty()) 1486 address += entityTypeContactInfoBo.getAddresses().get(i).getPostalCode(); 1487 } 1488 } 1489 } 1490 1491 return address; 1492 } 1493 1494 public String getPatronHomePhoneNumber(EntityTypeContactInfoBo entityTypeContactInfoBo) throws Exception { 1495 LOG.debug("Inside the getPatronHomePhoneNumber method"); 1496 String phoneNumber = ""; 1497 if (entityTypeContactInfoBo.getPhoneNumbers() != null) { 1498 for (int j = 0; j < entityTypeContactInfoBo.getPhoneNumbers().size(); j++) { 1499 if (entityTypeContactInfoBo.getPhoneNumbers().get(j).getPhoneTypeCode().equalsIgnoreCase("HM")) { 1500 phoneNumber = (entityTypeContactInfoBo.getPhoneNumbers().get(j).getPhoneNumber()); 1501 } 1502 } 1503 } 1504 return phoneNumber; 1505 } 1506 1507 public String getPatronHomeEmailId(EntityTypeContactInfoBo entityTypeContactInfoBo) throws Exception { 1508 LOG.debug("Inside the getPatronHomeEmailId method"); 1509 String emailId = ""; 1510 if (entityTypeContactInfoBo.getEmailAddresses() != null) { 1511 for (int j = 0; j < entityTypeContactInfoBo.getEmailAddresses().size(); j++) { 1512 if (entityTypeContactInfoBo.getEmailAddresses().get(j).getEmailTypeCode().equalsIgnoreCase("HM")) { 1513 emailId = (entityTypeContactInfoBo.getEmailAddresses().get(j).getEmailAddress()); 1514 } 1515 } 1516 } 1517 return emailId; 1518 } 1519 1520 private static int determineDifferenceInDays(Date currentDate, Date dueDate) { 1521 Calendar calendar1 = Calendar.getInstance(); 1522 calendar1.setTime(dueDate); 1523 Calendar calendar2 = Calendar.getInstance(); 1524 calendar2.setTime(currentDate); 1525 long diffInMillis = calendar2.getTimeInMillis() - calendar1.getTimeInMillis(); 1526 return (int) (diffInMillis / (24 * 1000 * 60 * 60)); 1527 } 1528 1529 1530 public void generateNotices() throws Exception { 1531 DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE); 1532 List<OlePatronDocument> patronDocumentList = (List<OlePatronDocument>) KRADServiceLocator.getBusinessObjectService().findAll(OlePatronDocument.class); 1533 for (OlePatronDocument olePatronDocument : patronDocumentList) { 1534 Map<String, String> requestMap = new HashMap<String, String>(); 1535 requestMap.put(OLEConstants.OleDeliverRequest.LOAN_PATRON_ID, olePatronDocument.getOlePatronId()); 1536 List<OleLoanDocument> oleLoanDocumentList = (List<OleLoanDocument>) KRADServiceLocator.getBusinessObjectService().findMatching(OleLoanDocument.class, requestMap); 1537 for (OleLoanDocument oleLoanDocument : oleLoanDocumentList) { 1538 try { 1539 List<OleNoticeBo> oleNoticeBos = new ArrayList<OleNoticeBo>(); 1540 org.kuali.ole.docstore.common.document.Item item = new ItemOleml(); 1541 org.kuali.ole.docstore.common.search.SearchParams search_Params = new org.kuali.ole.docstore.common.search.SearchParams(); 1542 SearchResponse searchResponse = null; 1543 search_Params.getSearchConditions().add(search_Params.buildSearchCondition("", search_Params.buildSearchField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), item.ITEM_BARCODE, oleLoanDocument.getItemId()), "")); 1544 //search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), "id")); 1545 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.HOLDINGS.getCode(), "id")); 1546 // search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), "id")); 1547 /* Map<String,String> map=new HashMap<>(); 1548 map.put(item.BARCODE, itemBarcode); 1549 item=getDocstoreClientLocator().getDocstoreClient().findItem(map);*/ 1550 searchResponse = getDocstoreClientLocator().getDocstoreClient().search(search_Params); 1551 for (SearchResult searchResult : searchResponse.getSearchResults()) { 1552 for (SearchResultField searchResultField : searchResult.getSearchResultFields()) { 1553 String fieldName = searchResultField.getFieldName(); 1554 String fieldValue = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : ""; 1555 1556 if (fieldName.equalsIgnoreCase("id") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("holdings")) { 1557 oleLoanDocument.setInstanceUuid(fieldValue); 1558 } 1559 1560 } 1561 } 1562 String itemXml = loanProcessor.getItemXML(oleLoanDocument.getItemUuid()); 1563 org.kuali.ole.docstore.common.document.content.instance.Item oleItem = loanProcessor.getItemPojo(itemXml); 1564 oleLoanDocument.setOleItem(oleItem); 1565 oleLoanDocument.setOlePatron(olePatronDocument); 1566 OleNoticeBo oleNoticeBo = new OleNoticeBo(); 1567 Date dueDate = oleLoanDocument.getLoanDueDate(); 1568 Date currentDate = new Date(); 1569 Integer dueDateDiffInterval = dueDate!=null ? determineDifferenceInDays(dueDate, currentDate) : 0; 1570 DateFormat formatter = new SimpleDateFormat(OLEConstants.DAT_FORMAT_EFFECTIVE_NOTICE); 1571 LOG.info("oleItem.getItemStatusEffectiveDate()" + oleItem.getItemStatusEffectiveDate()); 1572 Date itemStatusEffectiveDate = (Date) formatter.parse(oleItem.getItemStatusEffectiveDate()); 1573 Integer numberOfDaysOnHold = determineDifferenceInDays(itemStatusEffectiveDate, currentDate); 1574 Integer dueDateSumInterval = dueDate!=null ? determineDifferenceInDays(currentDate, dueDate) : 0; 1575 Integer overdueNoticeInterval = Integer.parseInt(getIntervalForOverdueNotice()); 1576 Integer intervalWithNoticeCount = 0; 1577 Integer loanNoOfOverdueNoticeSent = oleLoanDocument.getNumberOfOverdueNoticesSent() != null ? Integer.parseInt(oleLoanDocument.getNumberOfOverdueNoticesSent()) : 0; 1578 if (oleLoanDocument.getNumberOfOverdueNoticesSent() != null) { 1579 intervalWithNoticeCount = Integer.parseInt(oleLoanDocument.getNumberOfOverdueNoticesSent()) + 1; 1580 } else { 1581 intervalWithNoticeCount = intervalWithNoticeCount + 1; 1582 } 1583 // intervalWithNoticeCount = intervalWithNoticeCount * overdueNoticeInterval; 1584 dueDateSumInterval = dueDateSumInterval / intervalWithNoticeCount; 1585 if (dueDateSumInterval < 0) { 1586 dueDateSumInterval = 0; 1587 } 1588 if (dueDateDiffInterval < 0) { 1589 dueDateDiffInterval = 0; 1590 } 1591 Integer maxNumberOfDaysOnHold = 0; 1592 OleCirculationDesk oleCirculationDesk = null; 1593 if (oleLoanDocument.getCirculationLocationId() != null) { 1594 oleCirculationDesk = loanProcessor.getOleCirculationDesk(oleLoanDocument.getCirculationLocationId()); 1595 String maxNumOfDays = oleCirculationDesk.getOnHoldDays() != null ? oleCirculationDesk.getOnHoldDays() : loanProcessor.getParameter(OLEConstants.MAX_NO_OF_DAYS_ON_HOLD); 1596 maxNumberOfDaysOnHold = new Integer(maxNumOfDays); 1597 } 1598 if (oleItem.getTemporaryItemType() != null && oleItem.getTemporaryItemType().getCodeValue() != "") { 1599 OleInstanceItemType oleInstanceItemType = loanProcessor.getItemTypeIdByItemType(oleItem.getTemporaryItemType().getCodeValue()); 1600 oleLoanDocument.setItemTypeName(oleInstanceItemType.getInstanceItemTypeCode()); 1601 } 1602 else if (oleItem.getItemType() != null && oleItem.getItemType().getCodeValue() != "") { 1603 OleInstanceItemType oleInstanceItemType = loanProcessor.getItemTypeIdByItemType(oleItem.getItemType().getCodeValue()); 1604 oleLoanDocument.setItemTypeName(oleInstanceItemType.getInstanceItemTypeCode()); 1605 } 1606 oleLoanDocument.setInstanceUuid(oleLoanDocument.getInstanceUuid()); 1607 loanProcessor.getLocation(oleItem, oleLoanDocument); 1608 String agendaName = OLEConstants.NOTICE_AGENDA_NM; 1609 dataCarrierService.addData(OLEConstants.CIRC_POLICY_FOUND, null); 1610 HashMap<String, Object> termValues = new HashMap<String, Object>(); 1611 termValues.put(OLEConstants.BORROWER_TYPE, olePatronDocument.getOleBorrowerType().getBorrowerTypeCode()); 1612 termValues.put(OLEConstants.ITEM_TYPE, oleLoanDocument.getItemTypeName()); 1613 termValues.put(OLEConstants.OVERLAY_ITEM_LOCATION, oleLoanDocument.getItemLocation()); 1614 termValues.put(OLEConstants.DUE_DATE_DIFF_INTERVAL, dueDateDiffInterval); 1615 if (oleItem.getItemStatus() != null) 1616 termValues.put(OLEConstants.ITEM_STATUS, oleItem.getItemStatus().getCodeValue()); 1617 termValues.put(OLEConstants.NO_OF_DAYS_ON_HOLD, numberOfDaysOnHold); 1618 termValues.put(OLEConstants.MAX_NO_OF_DAYS_ONHOLD, maxNumberOfDaysOnHold); 1619 termValues.put(OLEConstants.OleDeliverRequest.CLAIM_RETURNED, oleItem.isClaimsReturnedFlag() ? "true" : "false"); 1620 termValues.put(OLEConstants.OleDeliverRequest.REPLACEMENT_FEE_PATRON_BILL, oleLoanDocument.getRepaymentFeePatronBillId() != null ? "true" : "false"); 1621 termValues.put(OLEConstants.OleDeliverRequest.NUBER_OF_OVER_DUE_SENT, loanNoOfOverdueNoticeSent); 1622 termValues.put(OLEConstants.OleDeliverRequest.DUE_DATE_SUM_INTERVAL, dueDateSumInterval); 1623 termValues.put(OLEConstants.OleDeliverRequest.CONFIGURABLE_INTERVAL, Integer.parseInt(getIntervalForCourtesyNotice())); 1624 termValues.put(OLEConstants.OleDeliverRequest.INTERVAL_WITH_NOTICE_COUNT, intervalWithNoticeCount); 1625 termValues.put(OLEConstants.ITEM_SHELVING, oleLoanDocument.getItemLocation()); 1626 termValues.put(OLEConstants.ITEM_COLLECTION, oleLoanDocument.getItemCollection()); 1627 termValues.put(OLEConstants.ITEM_LIBRARY, oleLoanDocument.getItemLibrary()); 1628 termValues.put(OLEConstants.ITEM_CAMPUS, oleLoanDocument.getItemCampus()); 1629 termValues.put(OLEConstants.ITEM_INSTITUTION, oleLoanDocument.getItemInstitution()); 1630 LOG.info("termValues.toString()" + termValues.toString()); 1631 EngineResults engineResults = loanProcessor.getEngineResults(agendaName, termValues); 1632 String notice = (String) engineResults.getAttribute(OLEConstants.NOTICE); 1633 String itemStatus = (String) engineResults.getAttribute(OLEConstants.ITEM_STATUS); 1634 BigDecimal replacementBill = (BigDecimal) engineResults.getAttribute(OLEConstants.REPLACEMENT_BILL); 1635 List<String> errorMessage = (List<String>) engineResults.getAttribute(OLEConstants.ERROR_ACTION); 1636 if (errorMessage != null) { 1637 LOG.info("errorMessage" + errorMessage.toString()); 1638 } 1639 LOG.info("notice" + notice); 1640 agendaName = OLEConstants.BATCH_PROGRAM_AGENDA; 1641 termValues = new HashMap<String, Object>(); 1642 String deskLocation = oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskCode() : ""; 1643 String deskLocationName = oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : ""; 1644 termValues.put(OLEConstants.BORROWER_TYPE, olePatronDocument.getOleBorrowerType().getBorrowerTypeCode()); 1645 termValues.put(OLEConstants.DESK_LOCATION, deskLocation); 1646 termValues.put(OLEConstants.NOTICE, notice); 1647 engineResults = loanProcessor.getEngineResults(agendaName, termValues); 1648 String noticeType = (String) engineResults.getAttribute(OLEConstants.NOTICE_TYPE); 1649 errorMessage = (List<String>) engineResults.getAttribute(OLEConstants.ERROR_ACTION); 1650 if (errorMessage != null) { 1651 LOG.info("errorMessage" + errorMessage); 1652 } 1653 LOG.info("noticeType" + noticeType); 1654 if (itemStatus != null) { 1655 int noOfOverdueNoticeSent = Integer.parseInt(oleLoanDocument.getNumberOfOverdueNoticesSent() != null ? oleLoanDocument.getNumberOfOverdueNoticesSent() : "0"); 1656 noOfOverdueNoticeSent = noOfOverdueNoticeSent + 1; 1657 oleLoanDocument.setNumberOfOverdueNoticesSent(Integer.toString(noOfOverdueNoticeSent)); 1658 oleLoanDocument.setOverDueNoticeDate(new java.sql.Date(System.currentTimeMillis())); 1659 String billNumber = loanProcessor.generatePatronBillPayment(oleLoanDocument, OLEConstants.REPLACEMENT_FEE, replacementBill); 1660 oleLoanDocument.setRepaymentFeePatronBillId(billNumber); 1661 getBusinessObjectService().save(oleLoanDocument); 1662 loanProcessor.updateItemStatus(oleItem, itemStatus); 1663 } 1664 OleDeliverBatchServiceImpl oleDeliverBatchService = new OleDeliverBatchServiceImpl(); 1665 if (notice != null) { 1666 oleNoticeBo.setNoticeName(notice); 1667 /*if(notice.equalsIgnoreCase(OLEConstants.NOTICE_HOLD_COURTESY)){ 1668 oleNoticeBo = getExpiredHoldNotice(oleLoanDocument); 1669 } else */ 1670 if (notice.equalsIgnoreCase(OLEConstants.NOTICE_OVERDUE)) { 1671 oleNoticeBo = getOverdueNotice(oleLoanDocument); 1672 noticeType = noticeType == null ? loanProcessor.getParameter(OLEParameterConstants.OVERDUE_NOTICE_TYPE) : noticeType; 1673 } else if (notice.equalsIgnoreCase(OLEConstants.NOTICE_COURTESY) && olePatronDocument.isCourtesyNotice() && !oleLoanDocument.isCourtesyNoticeFlag()) { 1674 oleNoticeBo = getCourtesyNotice(oleLoanDocument); 1675 noticeType = noticeType == null ? loanProcessor.getParameter(OLEParameterConstants.COURTESY_NOTICE_TYPE) : noticeType; 1676 } 1677 oleNoticeBo.setCirculationDeskName(deskLocationName); 1678 if (!olePatronDocument.isCourtesyNotice()) { 1679 oleNoticeBo = null; 1680 } 1681 if (oleNoticeBo != null) { 1682 oleNoticeBos.add(oleNoticeBo); 1683 } 1684 if (oleNoticeBos != null && oleNoticeBos.size() > 0 && noticeType != null && (noticeType.equalsIgnoreCase(OLEConstants.EMAIL) || noticeType.equalsIgnoreCase(OLEConstants.MAIL))) { 1685 oleDeliverBatchService.getPdfNoticeForPatron(oleNoticeBos); 1686 } 1687 } 1688 olePatronDocument = oleLoanDocument.getOlePatron(); 1689 if (oleNoticeBos != null && oleNoticeBos.size() > 0 && oleNoticeBos != null && oleNoticeBos.size() > 0 && noticeType != null && noticeType.equalsIgnoreCase(OLEConstants.EMAIL)) { 1690 if (olePatronDocument.getEmailAddress() != null && !olePatronDocument.getEmailAddress().isEmpty()) { 1691 List list = oleDeliverBatchService.getNoticeForPatron(oleNoticeBos); 1692 String noticeContent = list.toString(); 1693 noticeContent = noticeContent.replace('[', ' '); 1694 noticeContent = noticeContent.replace(']', ' '); 1695 if (!noticeContent.trim().equals("")) { 1696 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer"); 1697 String replyToEmail = getLoanProcessor().getReplyToEmail(oleNoticeBo.getItemShelvingLocation()); 1698 if (replyToEmail != null) { 1699 oleMailer.sendEmail(new EmailFrom(replyToEmail), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(noticeContent), true); 1700 } else { 1701 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL); 1702 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) { 1703 fromAddress = OLEConstants.KUALI_MAIL; 1704 } 1705 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(noticeContent), true); 1706 } 1707 } else { 1708 for (OleNoticeBo oleNoticeBo1 : oleNoticeBos) { 1709 LOG.info("Notice Type :" + oleNoticeBo1.getNoticeName() + " " + "Item Barcode : " + oleNoticeBo1.getItemId() + " " + "Patron Name :" + oleNoticeBo1.getPatronName()); 1710 } 1711 } 1712 LOG.info("Mail send successfully to " + oleNoticeBo.getPatronEmailAddress()); 1713 /* Mailer mailer =CoreApiServiceLocator.getMailer(); 1714 mailer.sendEmail(new EmailFrom(OLEConstants.KUALI_MAIL), new EmailTo(olePatronDocument.getEmailAddress()), new EmailSubject("Notice Mail"), new EmailBody(list.toString()), true); 1715 */ 1716 LOG.info("olePatronDocument.getEmailAddress()" + olePatronDocument.getEmailAddress()); 1717 } 1718 } else if (noticeType != null && noticeType.equalsIgnoreCase(OLEConstants.SMS)) { 1719 //TODO : sms in progress. 1720 } 1721 } catch (Exception e) { 1722 LOG.error("Exception in generateNotices()" + e.getMessage(), e); 1723 } 1724 } 1725 } 1726 } 1727 1728 public void generateHoldCourtesyNotice() throws Exception { 1729 List<OleDeliverRequestBo> oleDeliverRequestBos = (List<OleDeliverRequestBo>) KRADServiceLocator.getBusinessObjectService().findAll(OleDeliverRequestBo.class); 1730 for (OleDeliverRequestBo oleDeliverRequestBo : oleDeliverRequestBos) { 1731 List<OleNoticeBo> oleNoticeBos = new ArrayList<OleNoticeBo>(); 1732 DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE); 1733 if (docstoreUtil.isItemAvailableInDocStore(oleDeliverRequestBo)) { 1734 org.kuali.ole.docstore.common.document.content.instance.Item oleItem = oleDeliverRequestBo.getOleItem(); 1735 OleNoticeBo oleNoticeBo = new OleNoticeBo(); 1736 Date currentDate = new Date(); 1737 DateFormat formatter = new SimpleDateFormat(OLEConstants.DAT_FORMAT_EFFECTIVE_NOTICE); 1738 Date itemStatusEffectiveDate = (Date) formatter.parse(oleItem.getItemStatusEffectiveDate()); 1739 Integer numberOfDaysOnHold = determineDifferenceInDays(currentDate, itemStatusEffectiveDate); 1740 Integer maxNumberOfDaysOnHold = 0; 1741 OleCirculationDesk oleCirculationDesk = null; 1742 if (oleDeliverRequestBo.getPickUpLocationId() != null) { 1743 oleCirculationDesk = loanProcessor.getOleCirculationDesk(oleDeliverRequestBo.getPickUpLocationId()); 1744 String maxNumOfDays = oleCirculationDesk.getOnHoldDays() != null ? oleCirculationDesk.getOnHoldDays() : loanProcessor.getParameter(OLEConstants.MAX_NO_OF_DAYS_ON_HOLD); 1745 maxNumberOfDaysOnHold = new Integer(maxNumOfDays); 1746 } 1747 String itemTypeName = null; 1748 if (oleItem.getTemporaryItemType() != null && oleItem.getTemporaryItemType().getCodeValue() != "") { 1749 OleInstanceItemType oleInstanceItemType = loanProcessor.getItemTypeIdByItemType(oleItem.getTemporaryItemType().getCodeValue()); 1750 itemTypeName = oleInstanceItemType.getInstanceItemTypeCode(); 1751 }else if (oleItem.getItemType() != null && oleItem.getItemType().getCodeValue() != "") { 1752 OleInstanceItemType oleInstanceItemType = loanProcessor.getItemTypeIdByItemType(oleItem.getItemType().getCodeValue()); 1753 itemTypeName = oleInstanceItemType.getInstanceItemTypeCode(); 1754 } 1755 OlePatronDocument olePatronDocument = oleDeliverRequestBo.getOlePatron(); 1756 String agendaName = "Notice Validation"; 1757 dataCarrierService.addData(OLEConstants.CIRC_POLICY_FOUND, null); 1758 HashMap<String, Object> termValues = new HashMap<String, Object>(); 1759 termValues.put(OLEConstants.BORROWER_TYPE, olePatronDocument.getOleBorrowerType().getBorrowerTypeCode()); 1760 termValues.put(OLEConstants.ITEM_TYPE, itemTypeName); 1761 termValues.put(OLEConstants.OVERLAY_ITEM_LOCATION, oleDeliverRequestBo.getShelvingLocation()); 1762 termValues.put(OLEConstants.NO_OF_DAYS_ON_HOLD, numberOfDaysOnHold); 1763 termValues.put(OLEConstants.MAX_NO_OF_DAYS_ONHOLD, maxNumberOfDaysOnHold); 1764 termValues.put(OLEConstants.ITEM_SHELVING, oleDeliverRequestBo.getShelvingLocation()); 1765 termValues.put(OLEConstants.ITEM_COLLECTION, oleDeliverRequestBo.getItemCollection()); 1766 termValues.put(OLEConstants.ITEM_LIBRARY, oleDeliverRequestBo.getItemLibrary()); 1767 termValues.put(OLEConstants.ITEM_CAMPUS, oleDeliverRequestBo.getItemCampus()); 1768 termValues.put(OLEConstants.ITEM_INSTITUTION, oleDeliverRequestBo.getItemInstitution()); 1769 if (oleItem.getItemStatus() != null) 1770 termValues.put(OLEConstants.ITEM_STATUS, oleItem.getItemStatus().getCodeValue()); 1771 LOG.info("termValues.toString()" + termValues.toString()); 1772 EngineResults engineResults = loanProcessor.getEngineResults(agendaName, termValues); 1773 String notice = (String) engineResults.getAttribute(OLEConstants.NOTICE); 1774 LOG.info("notice" + notice); 1775 agendaName = OLEConstants.BATCH_PROGRAM_AGENDA; 1776 termValues = new HashMap<String, Object>(); 1777 String deskLocation = oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskCode() : ""; 1778 String deskLocationName = oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : ""; 1779 termValues.put(OLEConstants.BORROWER_TYPE, olePatronDocument.getOleBorrowerType().getBorrowerTypeCode()); 1780 termValues.put(OLEConstants.DESK_LOCATION, deskLocation); 1781 termValues.put(OLEConstants.NOTICE, notice); 1782 LOG.info("termValues.toString()" + termValues.toString()); 1783 engineResults = loanProcessor.getEngineResults(agendaName, termValues); 1784 String noticeType = (String) engineResults.getAttribute(OLEConstants.NOTICE_TYPE); 1785 LOG.info("**************" + noticeType); 1786 OleDeliverBatchServiceImpl oleDeliverBatchService = new OleDeliverBatchServiceImpl(); 1787 if (notice != null) { 1788 oleNoticeBo.setNoticeName(notice); 1789 if (notice.equalsIgnoreCase(OLEConstants.NOTICE_HOLD_COURTESY)) { 1790 oleNoticeBo = getExpiredHoldNotice(oleDeliverRequestBo); 1791 oleNoticeBo.setCirculationDeskName(deskLocationName); 1792 oleNoticeBos.add(oleNoticeBo); 1793 noticeType = noticeType == null ? loanProcessor.getParameter("HOLDCOURTESY_NOTICE_TYPE") : noticeType; 1794 } 1795 if (oleNoticeBos.size() > 0 && noticeType != null && (noticeType.equalsIgnoreCase(OLEConstants.EMAIL) || noticeType.equalsIgnoreCase(OLEConstants.MAIL))) { 1796 oleDeliverBatchService.getPdfNoticeForPatron(oleNoticeBos); 1797 } 1798 1799 } 1800 olePatronDocument = oleDeliverRequestBo.getOlePatron(); 1801 if (noticeType != null && noticeType.equalsIgnoreCase(OLEConstants.EMAIL)) { 1802 if (olePatronDocument.getEmailAddress() != null && !olePatronDocument.getEmailAddress().isEmpty()) { 1803 List list = oleDeliverBatchService.getNoticeForPatron(oleNoticeBos); 1804 String noticeContent = list.toString(); 1805 noticeContent = noticeContent.replace('[', ' '); 1806 noticeContent = noticeContent.replace(']', ' '); 1807 if (!noticeContent.trim().equals("")) { 1808 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer"); 1809 if (oleDeliverRequestBo.getOlePickUpLocation() != null && StringUtils.isNotBlank(oleDeliverRequestBo.getOlePickUpLocation().getReplyToEmail())) { 1810 oleMailer.sendEmail(new EmailFrom(oleDeliverRequestBo.getOlePickUpLocation().getReplyToEmail()), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(noticeContent), true); 1811 } else { 1812 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL); 1813 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) { 1814 fromAddress = OLEConstants.KUALI_MAIL; 1815 } 1816 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(noticeContent), true); 1817 } 1818 } else { 1819 for (OleNoticeBo oleNoticeBo1 : oleNoticeBos) { 1820 LOG.info("Notice Type :" + oleNoticeBo1.getNoticeName() + " " + "Item Barcode : " + oleNoticeBo1.getItemId() + " " + "Patron Name :" + oleNoticeBo1.getPatronName()); 1821 } 1822 } 1823/* 1824 Mailer mailer =CoreApiServiceLocator.getMailer(); 1825 mailer.sendEmail(new EmailFrom(OLEConstants.KUALI_MAIL), new EmailTo(olePatronDocument.getEmailAddress()), new EmailSubject("Notice Mail"), new EmailBody(list.toString()), true); 1826 */ 1827 LOG.info("olePatronDocument.getEmailAddress()" + olePatronDocument.getEmailAddress()); 1828 } 1829 } else if (noticeType != null && noticeType.equalsIgnoreCase(OLEConstants.SMS)) { 1830 //TODO : sms in progress. 1831 } 1832 } 1833 } 1834 } 1835 1836 public void deleteTemporaryHistoryRecord() throws Exception { 1837 List<OlePatronDocument> patronDocumentList = (List<OlePatronDocument>) KRADServiceLocator.getBusinessObjectService().findAll(OlePatronDocument.class); 1838 for (OlePatronDocument olePatronDocument : patronDocumentList) { 1839 Map<String, String> requestMap = new HashMap<String, String>(); 1840 requestMap.put(OLEConstants.OlePatron.PATRON_ID, olePatronDocument.getOlePatronId()); 1841 List<OleTemporaryCirculationHistory> oleTemporaryCirculationHistoryList = (List<OleTemporaryCirculationHistory>) KRADServiceLocator.getBusinessObjectService().findMatching(OleTemporaryCirculationHistory.class, requestMap); 1842 List<OleTemporaryCirculationHistory> deleteRecords = new ArrayList<OleTemporaryCirculationHistory>(); 1843 for (OleTemporaryCirculationHistory oleTemporaryCirculationHistory : oleTemporaryCirculationHistoryList) { 1844 String agendaName = OLEConstants.BATCH_PROGRAM_AGENDA; 1845 HashMap<String, Object> termValues = new HashMap<String, Object>(); 1846 termValues.put(OLEConstants.OleDeliverRequest.IS_TEMPORARY_HISTORY_RECORD, "true"); 1847 DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE); 1848 dataCarrierService.addData(OLEConstants.DATE_CHECK_IN, oleTemporaryCirculationHistory.getCheckInDate()); 1849 EngineResults engineResults = loanProcessor.getEngineResults(agendaName, termValues); 1850 Boolean deleteRecord = (Boolean) engineResults.getAttribute(OLEConstants.OVERLAY_OPTION_DELETE); 1851 if (deleteRecord != null && deleteRecord) { 1852 deleteRecords.add(oleTemporaryCirculationHistory); 1853 } 1854 } 1855 getBusinessObjectService().delete(deleteRecords); 1856 } 1857 } 1858 1859 private OleNoticeBo getExpiredHoldNotice(OleDeliverRequestBo oleDeliverRequestBo) throws Exception { 1860 LOG.debug("Expired Hold Notice"); 1861 org.kuali.ole.docstore.common.document.content.instance.Item oleItem = oleDeliverRequestBo.getOleItem(); 1862 EntityTypeContactInfoBo entityTypeContactInfoBo = oleDeliverRequestBo.getOlePatron().getEntity().getEntityTypeContactInfos().get(0); 1863 OleNoticeBo oleNoticeBo = new OleNoticeBo(); 1864 org.kuali.ole.docstore.common.document.Item item = getDocstoreClientLocator().getDocstoreClient().retrieveItem(oleDeliverRequestBo.getItemUuid()); 1865 String shelvingLocation = oleDeliverRequestBo.getShelvingLocation(); 1866 OleCirculationDesk oleCirculationDesk = getOleCirculationDesk(oleDeliverRequestBo.getPickUpLocationId()); 1867 if (oleCirculationDesk != null) 1868 oleNoticeBo.setCirculationDeskName(oleCirculationDesk.getCirculationDeskPublicName()); 1869 else 1870 oleNoticeBo.setCirculationDeskName(""); 1871 oleNoticeBo.setCirculationDeskAddress(""); 1872 oleNoticeBo.setCirculationDeskEmailAddress(""); 1873 oleNoticeBo.setCirculationDeskPhoneNumber(""); 1874 oleNoticeBo.setCirculationDeskPhoneNumber(""); 1875 oleNoticeBo.setPatronName(oleDeliverRequestBo.getOlePatron().getEntity().getNames().get(0).getFirstName() + " " + oleDeliverRequestBo.getOlePatron().getEntity().getNames().get(0).getLastName()); 1876 oleNoticeBo.setPatronAddress(getPatronPreferredAddress(entityTypeContactInfoBo) != null ? getPatronPreferredAddress(entityTypeContactInfoBo) : ""); 1877 oleNoticeBo.setPatronEmailAddress(getPatronHomeEmailId(entityTypeContactInfoBo) != null ? getPatronHomeEmailId(entityTypeContactInfoBo) : ""); 1878 oleNoticeBo.setPatronPhoneNumber(getPatronHomePhoneNumber(entityTypeContactInfoBo) != null ? getPatronHomePhoneNumber(entityTypeContactInfoBo) : ""); 1879 oleNoticeBo.setNoticeName(OLEConstants.NOTICE_HOLD_COURTESY); 1880 oleNoticeBo.setNoticeSpecificContent(LoanUtil.getLoanUtil().getProperty(OLEConstants.OleDeliverRequest.EXP_HOLD_NOTICE_CONTENT)); 1881 oleNoticeBo.setTitle(item.getHolding().getBib().getTitle()); 1882 oleNoticeBo.setAuthor(item.getHolding().getBib().getAuthor()); 1883 /*oleNoticeBo.setTitle((String) bibInformation.get(OLEConstants.TITLE) != null ? (String) bibInformation.get(OLEConstants.TITLE) : ""); 1884 oleNoticeBo.setAuthor((String) bibInformation.get(OLEConstants.AUTHOR) != null ? (String) bibInformation.get(OLEConstants.AUTHOR) : "");*/ 1885 oleNoticeBo.setVolumeNumber(item.getVolumeNumber()); 1886 oleNoticeBo.setItemShelvingLocation(shelvingLocation != null ? shelvingLocation : ""); 1887 //oleNoticeBo.setItemCallNumber((String) docStoreDetails.get(OLEConstants.CALL_NUM) != null ? (String) docStoreDetails.get(OLEConstants.CALL_NUM) : ""); 1888 oleNoticeBo.setItemCallNumber((String) oleItem.getCallNumber().getNumber() != null && !oleItem.getCallNumber().getNumber().equals("") ? oleItem.getCallNumber().getNumber() : ""); 1889 oleNoticeBo.setItemId(oleDeliverRequestBo.getItemId() != null ? oleDeliverRequestBo.getItemId() : ""); 1890 oleNoticeBo.setOleItem(oleItem); 1891 oleNoticeBo.setOlePatron(oleDeliverRequestBo.getOlePatron()); 1892 oleNoticeBo = setPatronDetailsForNotice(oleNoticeBo, oleDeliverRequestBo.getOlePatron()); 1893 oleDeliverRequestBo.getOlePatron().setEmailAddress(oleNoticeBo.getPatronEmailAddress()); 1894 return oleNoticeBo; 1895 } 1896 1897 private OleNoticeBo getCourtesyNotice(OleLoanDocument oleLoanDocument) throws Exception { 1898 LOG.debug("Courtesy Notice"); 1899 oleLoanDocument.setCourtesyNoticeFlag(true); 1900 Map<String, String> map = new HashMap<String, String>(); 1901 map.put("loanId", oleLoanDocument.getLoanId()); 1902 KRADServiceLocator.getBusinessObjectService().save(oleLoanDocument); 1903 EntityTypeContactInfoBo entityTypeContactInfoBo = oleLoanDocument.getOlePatron().getEntity().getEntityTypeContactInfos().get(0); 1904 OleNoticeBo oleNoticeBo = new OleNoticeBo(); 1905 //String itemId = oleLoanDocument.getItemId(); 1906 org.kuali.ole.docstore.common.document.content.instance.Item oleItem = oleLoanDocument.getOleItem(); 1907 org.kuali.ole.docstore.common.document.Item item = getDocstoreClientLocator().getDocstoreClient().retrieveItem(oleLoanDocument.getItemUuid()); 1908 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor(); 1909 org.kuali.ole.docstore.common.document.content.instance.Item itemContent = itemOlemlRecordProcessor.fromXML(item.getContent()); 1910 String shelvingLocation = oleLoanDocument.getItemLocation(); 1911 OleCirculationDesk oleCirculationDesk = getOleCirculationDesk(oleLoanDocument.getCirculationLocationId()); 1912 if (oleCirculationDesk != null) 1913 oleNoticeBo.setCirculationDeskName(oleCirculationDesk.getCirculationDeskPublicName()); 1914 else 1915 oleNoticeBo.setCirculationDeskName(""); 1916 oleNoticeBo.setCirculationDeskAddress(""); 1917 oleNoticeBo.setCirculationDeskEmailAddress(""); 1918 oleNoticeBo.setCirculationDeskPhoneNumber(""); 1919 oleNoticeBo.setPatronName(oleLoanDocument.getOlePatron().getEntity().getNames().get(0).getFirstName() + " " + oleLoanDocument.getOlePatron().getEntity().getNames().get(0).getLastName()); 1920 oleNoticeBo.setPatronAddress(getPatronPreferredAddress(entityTypeContactInfoBo) != null ? getPatronPreferredAddress(entityTypeContactInfoBo) : ""); 1921 oleNoticeBo.setPatronEmailAddress(getPatronHomeEmailId(entityTypeContactInfoBo) != null ? getPatronHomeEmailId(entityTypeContactInfoBo) : ""); 1922 oleNoticeBo.setPatronPhoneNumber(getPatronHomePhoneNumber(entityTypeContactInfoBo) != null ? getPatronHomePhoneNumber(entityTypeContactInfoBo) : ""); 1923 oleNoticeBo.setNoticeName(OLEConstants.NOTICE_COURTESY); 1924 oleNoticeBo.setNoticeSpecificContent(LoanUtil.getLoanUtil().getProperty(OLEConstants.OleDeliverRequest.COURTESY_NOTICE_CONTENT)); 1925 /* oleNoticeBo.setTitle((String) bibInformation.get(OLEConstants.TITLE) != null ? (String) bibInformation.get(OLEConstants.TITLE) : ""); 1926 oleNoticeBo.setAuthor((String) bibInformation.get(OLEConstants.AUTHOR) != null ? (String) bibInformation.get(OLEConstants.AUTHOR) : "");*/ 1927 oleNoticeBo.setTitle(item.getHolding().getBib().getTitle()); 1928 oleNoticeBo.setAuthor(item.getHolding().getBib().getAuthor()); 1929 oleNoticeBo.setVolumeNumber(item.getVolumeNumber()); 1930 oleNoticeBo.setItemShelvingLocation(shelvingLocation != null ? shelvingLocation : ""); 1931 // oleNoticeBo.setItemCallNumber((String) docStoreDetails.get(OLEConstants.CALL_NUM) != null ? (String) docStoreDetails.get(OLEConstants.CALL_NUM) : ""); 1932 oleNoticeBo.setItemCallNumber(loanProcessor.getItemCallNumber(itemContent, item.getHolding().getId())); 1933 oleNoticeBo.setItemId(oleLoanDocument.getItemId()); 1934 oleLoanDocument.getOlePatron().setEmailAddress(oleNoticeBo.getPatronEmailAddress()); 1935 LOG.info("oleNoticeBo.getPatronEmailAddress()" + oleNoticeBo.getPatronEmailAddress()); 1936 return oleNoticeBo; 1937 } 1938 1939 private OleNoticeBo getOverdueNotice(OleLoanDocument oleLoanDocument) throws Exception { 1940 LOG.debug("Overdue Notice"); 1941 EntityTypeContactInfoBo entityTypeContactInfoBo = oleLoanDocument.getOlePatron().getEntity().getEntityTypeContactInfos().get(0); 1942 OleNoticeBo oleNoticeBo = new OleNoticeBo(); 1943 // String itemId = oleLoanDocument.getItemId(); 1944 org.kuali.ole.docstore.common.document.content.instance.Item oleItem = oleLoanDocument.getOleItem(); 1945 // String itemUuid = oleItem.getItemIdentifier(); 1946 //String shelvingLocation = oleLoanDocument.getItemLocation(); 1947 org.kuali.ole.docstore.common.document.Item item = getDocstoreClientLocator().getDocstoreClient().retrieveItem(oleLoanDocument.getItemUuid()); 1948 OleCirculationDesk oleCirculationDesk = getOleCirculationDesk(oleLoanDocument.getCirculationLocationId()); 1949 if (oleCirculationDesk != null) 1950 oleNoticeBo.setCirculationDeskName(oleCirculationDesk.getCirculationDeskPublicName()); 1951 else 1952 oleNoticeBo.setCirculationDeskName(""); 1953 oleNoticeBo.setCirculationDeskAddress(""); 1954 oleNoticeBo.setCirculationDeskEmailAddress(""); 1955 oleNoticeBo.setCirculationDeskPhoneNumber(""); 1956 oleNoticeBo.setPatronName(oleLoanDocument.getOlePatron().getEntity().getNames().get(0).getFirstName() + " " + oleLoanDocument.getOlePatron().getEntity().getNames().get(0).getLastName()); 1957 oleNoticeBo.setPatronAddress(getPatronPreferredAddress(entityTypeContactInfoBo) != null ? getPatronPreferredAddress(entityTypeContactInfoBo) : ""); 1958 oleNoticeBo.setPatronEmailAddress(getPatronHomeEmailId(entityTypeContactInfoBo) != null ? getPatronHomeEmailId(entityTypeContactInfoBo) : ""); 1959 oleNoticeBo.setPatronPhoneNumber(getPatronHomePhoneNumber(entityTypeContactInfoBo) != null ? getPatronHomePhoneNumber(entityTypeContactInfoBo) : ""); 1960 oleNoticeBo.setNoticeName(OLEConstants.NOTICE_OVERDUE); 1961 oleNoticeBo.setNoticeSpecificContent(LoanUtil.getLoanUtil().getProperty(OLEConstants.OleDeliverRequest.OVERDUE_NOTICE_CONTENT)); 1962 oleNoticeBo.setTitle(item.getHolding().getBib().getTitle()); 1963 oleNoticeBo.setAuthor(item.getHolding().getBib().getAuthor()); 1964 /*oleNoticeBo.setTitle((String) bibInformation.get(OLEConstants.TITLE) != null ? (String) bibInformation.get(OLEConstants.TITLE) : ""); 1965 oleNoticeBo.setAuthor((String) bibInformation.get(OLEConstants.AUTHOR) != null ? (String) bibInformation.get(OLEConstants.AUTHOR) : "");*/ 1966 1967 //oleNoticeBo.setVolumeNumber((String) docStoreDetails.get(OLEConstants.VOL_NUM) != null ? (String) docStoreDetails.get(OLEConstants.VOL_NUM) : ""); 1968 String volume = (String) oleItem.getEnumeration() != null && !oleItem.getEnumeration().equals("") ? oleItem.getEnumeration() : ""; 1969 String issue = new String(" "); 1970 String copyNumber = (String) oleItem.getCopyNumber() != null && !oleItem.getCopyNumber().equals("") ? oleItem.getCopyNumber() : ""; 1971 oleNoticeBo.setVolumeIssueCopyNumber(volume + "/" + issue + "/" + copyNumber); 1972 oleNoticeBo.setItemShelvingLocation(item.getLocationName()); 1973 /*if (oleItem.getCallNumber().getNumber() != null && !oleItem.getCallNumber().getNumber().equals("")) { 1974 oleNoticeBo.setItemCallNumber((String) oleItem.getCallNumber().getNumber() != null && !oleItem.getCallNumber().getNumber().equals("") ? oleItem.getCallNumber().getNumber() : ""); 1975 } else { 1976 oleNoticeBo.setItemCallNumber(getLoanProcessor().getItemCallNumber(oleItem, oleLoanDocument.getInstanceUuid())); 1977 }*/ 1978 oleNoticeBo.setItemCallNumber(getLoanProcessor().getItemCallNumber(oleItem, oleLoanDocument.getInstanceUuid())); 1979 //oleNoticeBo.setItemCallNumber((String) docStoreDetails.get(OLEConstants.CALL_NUM) != null ? (String) docStoreDetails.get(OLEConstants.CALL_NUM) : ""); 1980 oleNoticeBo.setItemId(oleLoanDocument.getItemId()); 1981 //oleNoticeBo.setDueDate(oleLoanDocument.getLoanDueDate()!=null ? oleLoanDocument.getLoanDueDate().toString().substring(0, 10) : null); 1982 oleNoticeBo.setDueDate(oleLoanDocument.getLoanDueDate()!=null ? oleLoanDocument.getLoanDueDate() :null); 1983 oleLoanDocument.getOlePatron().setEmailAddress(oleNoticeBo.getPatronEmailAddress()); 1984 LOG.info("oleNoticeBo.getPatronEmailAddress()" + oleNoticeBo.getPatronEmailAddress()); 1985 int noOfOverdueNoticeSent = Integer.parseInt(oleLoanDocument.getNumberOfOverdueNoticesSent() != null ? oleLoanDocument.getNumberOfOverdueNoticesSent() : "0"); 1986 noOfOverdueNoticeSent = noOfOverdueNoticeSent + 1; 1987 LOG.debug("Updated Loan Record : " + oleLoanDocument); 1988 oleLoanDocument.setNumberOfOverdueNoticesSent(Integer.toString(noOfOverdueNoticeSent)); 1989 oleLoanDocument.setOverDueNoticeDate(new java.sql.Date(System.currentTimeMillis())); 1990 getBusinessObjectService().save(oleLoanDocument); 1991 return oleNoticeBo; 1992 } 1993 1994 public void updateItem(org.kuali.ole.docstore.common.document.content.instance.Item oleItem, String itemUuid) throws Exception { 1995 org.kuali.ole.docstore.common.document.content.instance.ItemStatus itemStatus = new org.kuali.ole.docstore.common.document.content.instance.ItemStatus(); 1996 itemStatus.setCodeValue(OLEConstants.OleDeliverRequest.MISSING); 1997 itemStatus.setFullValue(OLEConstants.OleDeliverRequest.MISSING); 1998 oleItem.setItemStatus(itemStatus); 1999 oleItem.setStaffOnlyFlag(true); 2000 String itemContent = new ItemOlemlRecordProcessor().toXML(oleItem); 2001 org.kuali.ole.docstore.common.document.Item item = new ItemOleml(); 2002 item.setId(itemUuid); 2003 item.setContent(itemContent); 2004 item.setCategory(OLEConstants.WORK_CATEGORY); 2005 item.setType(DocType.ITEM.getCode()); 2006 item.setFormat(OLEConstants.OLEML_FORMAT); 2007 getDocstoreClientLocator().getDocstoreClient().updateItem(item); 2008 } 2009 2010 public String getShelvingLocation(org.kuali.ole.docstore.common.document.content.instance.LocationLevel oleLocationLevel) { 2011 String location = null; 2012 if (oleLocationLevel != null) { 2013 if (OLEConstants.LOCATION_LEVEL_SHELVING.equalsIgnoreCase(oleLocationLevel.getLevel())) 2014 location = oleLocationLevel.getName(); 2015 else 2016 location = getShelvingLocation(oleLocationLevel.getLocationLevel()); 2017 } 2018 if ("".equals(location) || location == null) 2019 return null; 2020 return location; 2021 } 2022 2023 2024 public String getIntervalForCourtesyNotice() { 2025 BusinessObjectService businessObjectService = KRADServiceLocator.getBusinessObjectService(); 2026 Map<String, String> criteriaMap = new HashMap<String, String>(); 2027 criteriaMap.put(OLEConstants.NAMESPACE_CODE, OLEConstants.DLVR_NMSPC); 2028 criteriaMap.put(OLEConstants.COMPONENT_CODE, OLEConstants.DLVR_CMPNT); 2029 criteriaMap.put(OLEConstants.NAME, OLEParameterConstants.COURTESY_NOTICE_INTER); 2030 List<ParameterBo> parametersList = (List<ParameterBo>) businessObjectService.findMatching(ParameterBo.class, criteriaMap); 2031 return parametersList.get(0).getValue(); 2032 } 2033 2034 public String getIntervalForOverdueNotice() { 2035 BusinessObjectService businessObjectService = KRADServiceLocator.getBusinessObjectService(); 2036 Map<String, String> criteriaMap = new HashMap<String, String>(); 2037 criteriaMap.put(OLEConstants.NAMESPACE_CODE, OLEConstants.DLVR_NMSPC); 2038 criteriaMap.put(OLEConstants.COMPONENT_CODE, OLEConstants.DLVR_CMPNT); 2039 criteriaMap.put(OLEConstants.NAME, OLEConstants.OVERDUE_NOTICE_INTER); 2040 List<ParameterBo> parametersList = (List<ParameterBo>) businessObjectService.findMatching(ParameterBo.class, criteriaMap); 2041 return parametersList.get(0).getValue(); 2042 } 2043 2044 2045 private PatronBillPayment getPatronBillPayment(String patronId) { 2046 LOG.debug("Inside the getPatronBillPayment method"); 2047 Map billMap = new HashMap(); 2048 billMap.put(OLEConstants.OleDeliverRequest.LOAN_PATRON_ID, patronId); 2049 List<PatronBillPayment> patronBillPaymentList = (List<PatronBillPayment>) getBusinessObjectService().findMatching(PatronBillPayment.class, billMap); 2050 return patronBillPaymentList != null && patronBillPaymentList.size() > 0 ? patronBillPaymentList.get(0) : null; 2051 } 2052 2053 private OlePaymentStatus getPaymentStatus() { 2054 LOG.debug("Inside the getPaymentStatus method"); 2055 Map statusMap = new HashMap(); 2056 statusMap.put(OLEConstants.OleDeliverRequest.PAYMENT_STATUS_NAME, OLEConstants.PAYMENT_STATUS_OUTSTANDING); 2057 List<OlePaymentStatus> olePaymentStatusList = (List<OlePaymentStatus>) getBusinessObjectService().findMatching(OlePaymentStatus.class, statusMap); 2058 return olePaymentStatusList != null && olePaymentStatusList.size() > 0 ? olePaymentStatusList.get(0) : null; 2059 } 2060 2061 private String getFeeTypeId(String feeTypeName) { 2062 LOG.debug("Inside the getOverdueFeeTypeId method"); 2063 Map feeMap = new HashMap(); 2064 feeMap.put(OLEConstants.FEE_TYPE_NAME, feeTypeName); 2065 List<OleFeeType> oleFeeTypes = (List<OleFeeType>) getBusinessObjectService().findMatching(OleFeeType.class, feeMap); 2066 return oleFeeTypes != null && oleFeeTypes.size() > 0 ? oleFeeTypes.get(0).getFeeTypeId() : null; 2067 } 2068 2069 public String processItemType(String itemType) { 2070 2071 LOG.debug("Inside process Item Type"); 2072 Map<String, String> itemMap = new HashMap<String, String>(); 2073 itemMap.put(OLEConstants.OleDeliverRequest.ITEM_TYPE_CODE, itemType); 2074 List<OleInstanceItemType> oleInstanceItemTypeList = (List<OleInstanceItemType>) businessObjectService.findMatching(OleInstanceItemType.class, itemMap); 2075 if (oleInstanceItemTypeList != null && oleInstanceItemTypeList.size() > 0) { 2076 OleInstanceItemType oleInstanceItemType = oleInstanceItemTypeList.get(0); 2077 return oleInstanceItemType.getInstanceItemTypeName(); 2078 } 2079 return null; 2080 } 2081 2082 public String placeRequest(String patronId, String operatorId, String itemBarcode, String requestType, String pickUpLocation, String itemIdentifier) { 2083 OleDeliverRequestBo oleDeliverRequestBo = new OleDeliverRequestBo(); 2084 oleDeliverRequestBo.setCreateDate(new java.sql.Date(System.currentTimeMillis())); 2085 OlePatronDocument olePatronDocument = null; 2086 Map<String, String> patronMap = new HashMap<String, String>(); 2087 patronMap.put("olePatronId", patronId); 2088 OleNoticeBo oleNoticeBo = new OleNoticeBo(); 2089 List<OlePatronDocument> olePatronDocumentList = (List<OlePatronDocument>) businessObjectService.findMatching(OlePatronDocument.class, patronMap); 2090 if (olePatronDocumentList.size() > 0) { 2091 olePatronDocument = olePatronDocumentList.get(0); 2092 oleDeliverRequestBo.setBorrowerId(patronId); 2093 oleDeliverRequestBo.setBorrowerBarcode(olePatronDocument.getBarcode()); 2094 oleDeliverRequestBo.setOlePatron(olePatronDocument); 2095 EntityTypeContactInfoBo entityTypeContactInfoBo = olePatronDocument.getEntity().getEntityTypeContactInfos().get(0); 2096 try { 2097 oleNoticeBo.setPatronName(olePatronDocument.getEntity().getNames().get(0).getFirstName() + " " + oleDeliverRequestBo.getOlePatron().getEntity().getNames().get(0).getLastName()); 2098 oleNoticeBo.setPatronAddress(getPatronPreferredAddress(entityTypeContactInfoBo) != null ? getPatronPreferredAddress(entityTypeContactInfoBo) : ""); 2099 oleNoticeBo.setPatronEmailAddress(getPatronHomeEmailId(entityTypeContactInfoBo) != null ? getPatronHomeEmailId(entityTypeContactInfoBo) : ""); 2100 oleNoticeBo.setPatronPhoneNumber(getPatronHomePhoneNumber(entityTypeContactInfoBo) != null ? getPatronHomePhoneNumber(entityTypeContactInfoBo) : ""); 2101 } catch (Exception e) { 2102 LOG.error(e, e); 2103 LOG.info("Exception Occured while setting the patron information for the patron . Patron Barcode : " + oleDeliverRequestBo.getBorrowerBarcode()); 2104 } 2105 } else { 2106 return "No patron information"; 2107 } 2108 if (requestType != null) { 2109 Map<String, String> requestTypeMap = new HashMap<String, String>(); 2110 requestTypeMap.put("requestTypeCode", requestType); 2111 List<OleDeliverRequestType> oleDeliverRequestTypeList = (List<OleDeliverRequestType>) businessObjectService.findMatching(OleDeliverRequestType.class, requestTypeMap); 2112 if (oleDeliverRequestTypeList != null && (oleDeliverRequestTypeList.size() > 0)) { 2113 oleDeliverRequestBo.setRequestTypeId(oleDeliverRequestTypeList.get(0).getRequestTypeId()); 2114 oleDeliverRequestBo.setOleDeliverRequestType(oleDeliverRequestTypeList.get(0)); 2115 } else 2116 return "Invalid Request Type Code"; 2117 2118 } 2119 if (pickUpLocation != null) { 2120 Map<String, String> circulationDeskMap = new HashMap<String, String>(); 2121 circulationDeskMap.put("circulationDeskCode", pickUpLocation); 2122 List<OleCirculationDesk> oleCirculationDeskList = (List<OleCirculationDesk>) businessObjectService.findMatching(OleCirculationDesk.class, circulationDeskMap); 2123 if (oleCirculationDeskList != null && oleCirculationDeskList.size() > 0) { 2124 oleDeliverRequestBo.setPickUpLocationId(oleCirculationDeskList.get(0).getCirculationDeskId()); 2125 oleDeliverRequestBo.setPickUpLocationCode(oleCirculationDeskList.get(0).getCirculationDeskCode()); 2126 oleDeliverRequestBo.setOlePickUpLocation(oleCirculationDeskList.get(0)); 2127 } else { 2128 return "Invalid Pick Up Location"; 2129 } 2130 2131 } 2132 try { 2133 if (itemBarcode == null || (itemBarcode != null && itemBarcode.isEmpty())) { 2134 return "invalid barcode"; 2135 } 2136 oleDeliverRequestBo.setItemId(itemBarcode); 2137 oleDeliverRequestBo.setItemUuid(itemIdentifier); 2138 Thread.sleep(2000); 2139 docstoreUtil.isItemAvailableInDocStore(oleDeliverRequestBo); 2140 if (oleDeliverRequestBo.getItemUuid() == null || (oleDeliverRequestBo.getItemUuid() != null && oleDeliverRequestBo.getItemUuid().trim().isEmpty())) { 2141 return "invalid barcode"; 2142 } else { 2143 oleDeliverRequestBo.setRequestCreator("Operator"); 2144 oleDeliverRequestBo.setOperatorCreateId(operatorId); 2145 oleDeliverRequestBo.setBorrowerId(patronId); 2146 oleDeliverRequestBo.setItemId(itemBarcode); 2147 oleDeliverRequestBo.setRequestStatus("1"); 2148 if (!processOperator(operatorId)) { 2149 return OLEConstants.INVALID_OPERATOR; 2150 } 2151 processRequestType(oleDeliverRequestBo); 2152 String message = this.patronRecordExpired(oleDeliverRequestBo); 2153 if (message != null) 2154 return message; 2155 boolean requestRaised = this.isRequestAlreadyRaisedByPatron(oleDeliverRequestBo); 2156 if (requestRaised) 2157 return "Request Already Raised For This Item By The Patron "; 2158 boolean itemEligible = this.isItemEligible(oleDeliverRequestBo); 2159 if (!itemEligible) 2160 return "Item is not eligible for circulation"; 2161 boolean alreadyLoaned = this.isAlreadyLoaned(oleDeliverRequestBo); 2162 if (alreadyLoaned) 2163 return "Item is currently in loan with the requested borrower"; 2164 2165 boolean valid = false; 2166 EngineResults engineResult = this.executeEngineResults(oleDeliverRequestBo); 2167 if (engineResult != null) { 2168 List<ResultEvent> allResults = engineResult.getAllResults(); 2169 if (allResults.size() > 0) { 2170 for (Iterator<ResultEvent> resultEventIterator = allResults.iterator(); resultEventIterator.hasNext(); ) { 2171 ResultEvent resultEvent = resultEventIterator.next(); 2172 if (resultEvent.getType().equals(RULE_EVALUATED)) 2173 valid |= resultEvent.getResult(); 2174 } 2175 if ((oleDeliverRequestBo.getMessage() != null && !oleDeliverRequestBo.getMessage().isEmpty())) 2176 return oleDeliverRequestBo.getMessage(); 2177 } 2178 } 2179 OleDeliverRequestBo oleDeliverRequestBo1 = oleDeliverRequestBo; 2180 if (oleDeliverRequestBo.getRequestTypeId().equals("1") || oleDeliverRequestBo.getRequestTypeId().equals("2") || oleDeliverRequestBo.getRequestTypeId().equals("3") || oleDeliverRequestBo.getRequestTypeId().equals("4")) { 2181 if (oleDeliverRequestBo.getRequestTypeId().equals("1") || oleDeliverRequestBo.getRequestTypeId().equals("2")) 2182 oleDeliverRequestBo1 = this.updateLoanDocument(oleDeliverRequestBo); 2183 if (isItemAvailable(oleDeliverRequestBo1)) { 2184 return "Recall / Hold type of request can be raised only for the item which is currently in circulation"; 2185 } 2186 } 2187 oleDeliverRequestBo.setOleItem(null); 2188 this.reOrderQueuePosition(oleDeliverRequestBo1); 2189 getBusinessObjectService().save(oleDeliverRequestBo1); 2190 Map<String, String> requestMap = new HashMap<String, String>(); 2191 requestMap.put("borrowerId", patronId); 2192 requestMap.put("itemId", itemBarcode); 2193 List<OleDeliverRequestBo> oleDeliverRequestBoList = (List<OleDeliverRequestBo>) businessObjectService.findMatching(OleDeliverRequestBo.class, requestMap); 2194 String requestId = ""; 2195 if (oleDeliverRequestBoList.size() > 0) { 2196 requestId = ":Request Id :" + oleDeliverRequestBoList.get(0).getRequestId(); 2197 } 2198 LOG.info("Request Raised Succesfully" + requestId); 2199 oleNoticeBo.setNoticeName(OLEConstants.PICKUP_NOTICE); 2200 Date pickupDate = addDate(new java.sql.Date(System.currentTimeMillis()), new Integer(oleDeliverRequestBo.getOlePickUpLocation().getOnHoldDays())); 2201 oleNoticeBo.setNoticeSpecificContent(OLEConstants.PICKUP_NOTICE_START_CONTENT + oleDeliverRequestBo.getOlePickUpLocation().getCirculationDeskPublicName() + OLEConstants.PICKUP_NOTICE_MIDDLE_CONTENT + pickupDate + OLEConstants.PICKUP_NOTICE_FINAL_CONTENT); 2202 oleNoticeBo.setAuthor(oleDeliverRequestBo.getAuthor() != null ? oleDeliverRequestBo.getAuthor() : ""); 2203 oleNoticeBo.setItemCallNumber(oleDeliverRequestBo.getCallNumber() != null ? oleDeliverRequestBo.getCallNumber() : ""); 2204 oleNoticeBo.setItemId(oleDeliverRequestBo.getItemId() != null ? oleDeliverRequestBo.getItemId() : ""); 2205 oleNoticeBo.setTitle(oleDeliverRequestBo.getTitle() != null ? oleDeliverRequestBo.getTitle() : ""); 2206 OleDeliverBatchServiceImpl oleDeliverBatchService = new OleDeliverBatchServiceImpl(); 2207 String content = oleDeliverBatchService.getEmailPickUpNotice(oleNoticeBo); 2208 try { 2209 if (!content.trim().equals("")) { 2210 OleMailer oleMailer = GlobalResourceLoader.getService("oleMailer"); 2211 if (oleDeliverRequestBo.getOlePickUpLocation() != null && StringUtils.isNotBlank(oleDeliverRequestBo.getOlePickUpLocation().getReplyToEmail())) { 2212 oleMailer.sendEmail(new EmailFrom(oleDeliverRequestBo.getOlePickUpLocation().getReplyToEmail()), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(content), true); 2213 } else { 2214 String fromAddress = getLoanProcessor().getParameter(OLEParameterConstants.NOTICE_FROM_MAIL); 2215 if (fromAddress != null && (fromAddress.equals("") || fromAddress.trim().isEmpty())) { 2216 fromAddress = OLEConstants.KUALI_MAIL; 2217 } 2218 oleMailer.sendEmail(new EmailFrom(fromAddress), new EmailTo(oleNoticeBo.getPatronEmailAddress()), new EmailSubject(OLEConstants.NOTICE_MAIL), new EmailBody(content), true); 2219 } 2220 LOG.info("Mail send Successfully to " + oleNoticeBo.getPatronEmailAddress()); 2221 oleDeliverBatchService.getPdfPickUpNotice(oleNoticeBo); 2222 } else { 2223 LOG.info("Notice Type :" + oleNoticeBo.getNoticeName() + " " + "Item Barcode : " + oleNoticeBo.getItemId() + " " + "Patron Name :" + oleNoticeBo.getPatronName()); 2224 } 2225 } catch (Exception e) { 2226 LOG.error(e, e); 2227 return "Request Raised Succesfully" + requestId + ".Problem occured while sending notice."; 2228 } 2229 return "Request Raised Succesfully" + requestId; 2230 } 2231 } catch (Exception e) { 2232 LOG.error(e, e); 2233 if (e.getMessage().equalsIgnoreCase("Item barcode does not exist.")) { 2234 return "Item barcode does not exist."; 2235 } 2236 return "Request failed"; 2237 } 2238 } 2239 2240 private java.sql.Date addDate(java.sql.Date in, int daysToAdd) { 2241 if (in == null) { 2242 return null; 2243 } 2244 GregorianCalendar cal = new GregorianCalendar(); 2245 cal.setTime(in); 2246 cal.add(Calendar.DAY_OF_MONTH, daysToAdd); 2247 return new java.sql.Date(cal.getTime().getTime()); 2248 } 2249 2250 public EngineResults executeEngineResults(OleDeliverRequestBo oleDeliverRequestBo) { 2251 List<OleDeliverRequestBo> recallList = new ArrayList<OleDeliverRequestBo>(); 2252 List<OleDeliverRequestBo> holdList = new ArrayList<OleDeliverRequestBo>(); 2253 List<OleDeliverRequestBo> pageList = new ArrayList<OleDeliverRequestBo>(); 2254 List<OleDeliverRequestBo> requestsByBorrower = new ArrayList<OleDeliverRequestBo>(); 2255 Engine engine = KrmsApiServiceLocator.getEngine(); 2256 EngineResults engineResult = null; 2257 HashMap<String, Object> agendaValue = new HashMap<String, Object>(); 2258 agendaValue.put(OLEConstants.NAME_NM, OLEConstants.REQUEST_AGENDA_NM); 2259 List<AgendaBo> agendaBos = (List<AgendaBo>) KRADServiceLocator.getBusinessObjectService().findMatching(AgendaBo.class, agendaValue); 2260 if (agendaBos != null && agendaBos.size() > 0) { 2261 AgendaBo agendaBo = agendaBos.get(0); 2262 HashMap<String, String> map = new HashMap<String, String>(); 2263 map.put(OLEConstants.AGENDA_NAME, agendaBo.getName()); 2264 List<MatchBo> matchBos = (List<MatchBo>) KRADServiceLocator.getBusinessObjectService().findMatching(MatchBo.class, map); 2265 2266 SelectionCriteria selectionCriteria = 2267 SelectionCriteria.createCriteria(null, getSelectionContext(agendaBo.getContext().getName()), 2268 getAgendaContext(OLEConstants.REQUEST_AGENDA_NM)); 2269 2270 ExecutionOptions executionOptions = new ExecutionOptions(); 2271 executionOptions.setFlag(ExecutionFlag.LOG_EXECUTION, true); 2272 2273 Facts.Builder factBuilder = Facts.Builder.create(); 2274 2275 String borrowerType = ""; 2276 if (oleDeliverRequestBo.getOlePatron() != null && oleDeliverRequestBo.getOlePatron().getOleBorrowerType() != null) { 2277 borrowerType = oleDeliverRequestBo.getOlePatron().getOleBorrowerType().getBorrowerTypeCode(); 2278 } 2279 String itemType = oleDeliverRequestBo.getItemType(); 2280 2281 String requestTypeId = oleDeliverRequestBo.getRequestTypeId(); 2282 2283 String requestType = oleDeliverRequestBo.getRequestTypeCode(); 2284 2285 String location = oleDeliverRequestBo.getShelvingLocation(); 2286 LoanProcessor loanProcessor = getLoanProcessor(); 2287 OleLoanDocument oleLoanDocument = loanProcessor.getOleLoanDocumentUsingItemUUID(oleDeliverRequestBo.getItemUuid()); 2288 DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE); 2289 dataCarrierService.addData(OLEConstants.LOANED_DATE, oleLoanDocument != null ? oleLoanDocument.getCreateDate() : null); 2290 dataCarrierService.addData(OLEConstants.CIRC_POLICY_FOUND, null); 2291 String borrowerId = oleDeliverRequestBo.getBorrowerId(); 2292 Map<String, String> requestMap = new HashMap<String, String>(); 2293 requestMap.put(OLEConstants.ITEM_UUID, oleDeliverRequestBo.getItemUuid()); 2294 if (requestTypeId != null && (requestTypeId.equals("1") || requestTypeId.equals("2"))) { 2295 requestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "1"); 2296 recallList = (List<OleDeliverRequestBo>) getBusinessObjectService().findMatching(OleDeliverRequestBo.class, requestMap); 2297 requestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "2"); 2298 recallList.addAll((List<OleDeliverRequestBo>) getBusinessObjectService().findMatching(OleDeliverRequestBo.class, requestMap)); 2299 } else if (requestTypeId != null && (requestTypeId.equals("3") || requestTypeId.equals("4"))) { 2300 // holdList = (List<OleDeliverRequestBo>)getBusinessObjectService().findMatching(OleDeliverRequestBo.class,requestMap); 2301 requestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "3"); 2302 holdList = (List<OleDeliverRequestBo>) getBusinessObjectService().findMatching(OleDeliverRequestBo.class, requestMap); 2303 requestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "4"); 2304 holdList.addAll((List<OleDeliverRequestBo>) getBusinessObjectService().findMatching(OleDeliverRequestBo.class, requestMap)); 2305 } else if (requestTypeId != null && (requestTypeId.equals("5") || requestTypeId.equals("6"))) { 2306 // pageList = (List<OleDeliverRequestBo>)getBusinessObjectService().findMatching(OleDeliverRequestBo.class,requestMap); 2307 requestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "5"); 2308 pageList = (List<OleDeliverRequestBo>) getBusinessObjectService().findMatching(OleDeliverRequestBo.class, requestMap); 2309 requestMap.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, "6"); 2310 pageList.addAll((List<OleDeliverRequestBo>) getBusinessObjectService().findMatching(OleDeliverRequestBo.class, requestMap)); 2311 } 2312 Map<String, String> requestByBorrower = new HashMap<String, String>(); 2313 requestByBorrower.put(OLEConstants.OleDeliverRequest.BORROWER_ID, borrowerId); 2314 requestsByBorrower = (List<OleDeliverRequestBo>) getBusinessObjectService().findMatching(OleDeliverRequestBo.class, requestByBorrower); 2315 HashMap<String, Object> termValues = new HashMap<String, Object>(); 2316 termValues.put(OLEConstants.BORROWER_TYPE, borrowerType); 2317 termValues.put(OLEConstants.ITEM_TYPE, itemType); 2318 termValues.put(OLEConstants.LOCATION, location); 2319 termValues.put(OLEConstants.ITEM_SHELVING, oleDeliverRequestBo.getShelvingLocation()); 2320 termValues.put(OLEConstants.ITEM_COLLECTION, oleDeliverRequestBo.getItemCollection()); 2321 termValues.put(OLEConstants.ITEM_LIBRARY, oleDeliverRequestBo.getItemLibrary()); 2322 termValues.put(OLEConstants.ITEM_CAMPUS, oleDeliverRequestBo.getItemCampus()); 2323 termValues.put(OLEConstants.ITEM_INSTITUTION, oleDeliverRequestBo.getItemInstitution()); 2324 termValues.put(OLEConstants.MAX_NO_OF_RECALL_REQUEST, new Integer(recallList.size()) + 1); 2325 termValues.put(OLEConstants.MAX_NO_OF_HOLD_REQUEST, new Integer(holdList.size()) + 1); 2326 termValues.put(OLEConstants.MAX_NO_OF_PAGE_REQUEST, new Integer(pageList.size()) + 1); 2327 // termValues.put("maxNumberOfRequestByBorrower",requestsByBorrower.size()); 2328 termValues.put(OLEConstants.OleDeliverRequest.REQUEST_TYPE_ID, requestTypeId); 2329 termValues.put(OLEConstants.REQUEST_TYPE, requestType); 2330 2331 2332 for (Iterator<MatchBo> matchBoIterator = matchBos.iterator(); matchBoIterator.hasNext(); ) { 2333 MatchBo matchBo = matchBoIterator.next(); 2334 factBuilder.addFact(matchBo.getTermName(), termValues.get((matchBo.getTermName()))); 2335 } 2336 LOG.info("termValues.toString()" + termValues.toString()); 2337 engineResult = engine.execute(selectionCriteria, factBuilder.build(), executionOptions); 2338 List<String> errorMessage = (List<String>) engineResult.getAttribute(OLEConstants.ERROR_ACTION); 2339 java.sql.Date d = (java.sql.Date) engineResult.getAttribute(OLEConstants.REQ_EXPIRATION_DATE); 2340 Timestamp recallDueDate = (Timestamp) engineResult.getAttribute(OLEConstants.RECALL_DUE_DATE); 2341 String notice = (String) engineResult.getAttribute(OLEConstants.NOTICE); 2342 oleDeliverRequestBo.setNoticeType(notice); 2343 if (recallDueDate != null && oleLoanDocument.getLoanDueDate()!=null) { 2344 oleLoanDocument.setLoanDueDate(recallDueDate); 2345 oleDeliverRequestBo.setRecallDueDate(recallDueDate); 2346 getBusinessObjectService().save(oleLoanDocument); 2347 } 2348 oleDeliverRequestBo.setRequestExpiryDate(d); 2349 StringBuffer failures = new StringBuffer(); 2350 if (errorMessage != null && errorMessage.size() > 0) { 2351 int i = 1; 2352 for (String errMsg : errorMessage) { 2353 failures.append(i++ + ". " + errMsg + OLEConstants.BREAK); 2354 } 2355 } 2356 if (!failures.toString().isEmpty()) { 2357 oleDeliverRequestBo.setMessage(failures.toString()); 2358 } 2359 dataCarrierService.addData(OLEConstants.ERROR_ACTION, null); 2360 } 2361 return engineResult; 2362 } 2363 2364 /** 2365 * This method returns SelectionContext using contextName. 2366 * 2367 * @param contextName 2368 * @return Map 2369 */ 2370 protected Map<String, String> getSelectionContext(String contextName) { 2371 Map<String, String> selector = new HashMap<String, String>(); 2372 selector.put(NAMESPACE_CODE_SELECTOR, OLEConstants.OLE_NAMESPACE); 2373 selector.put(NAME_SELECTOR, contextName); 2374 return selector; 2375 } 2376 2377 /** 2378 * This method returns AgendaContext using agendaName.. 2379 * 2380 * @param agendaName 2381 * @return Map 2382 */ 2383 protected Map<String, String> getAgendaContext(String agendaName) { 2384 Map<String, String> selector = new HashMap<String, String>(); 2385 selector.put(NAME_SELECTOR, agendaName); 2386 return selector; 2387 } 2388 2389 private OleCirculationDesk getOleCirculationDesk(String circulationDeskId) { 2390 Map<String, String> circulationDeskMap = new HashMap<String, String>(); 2391 circulationDeskMap.put("circulationDeskId", circulationDeskId); 2392 List<OleCirculationDesk> oleCirculationDeskList = (List<OleCirculationDesk>) businessObjectService.findMatching(OleCirculationDesk.class, circulationDeskMap); 2393 if (oleCirculationDeskList != null && oleCirculationDeskList.size() > 0) { 2394 return oleCirculationDeskList.get(0); 2395 } else 2396 return null; 2397 } 2398 2399 private RoleService getRoleService() { 2400 RoleService service = KimApiServiceLocator.getRoleService(); 2401 return service; 2402 } 2403 2404 2405} 2406 2407 2408 2409 2410 2411