View Javadoc
1   package org.kuali.ole.deliver.service.impl;
2   
3   import org.apache.commons.collections.CollectionUtils;
4   import org.apache.commons.lang3.StringUtils;
5   import org.kuali.ole.DocumentUniqueIDPrefix;
6   import org.kuali.ole.OLEConstants;
7   import org.kuali.ole.deliver.bo.*;
8   import org.kuali.ole.deliver.processor.LoanProcessor;
9   import org.kuali.ole.deliver.service.OLEDeliverItemSearchService;
10  import org.kuali.ole.deliver.service.OLEDeliverService;
11  import org.kuali.ole.deliver.service.OleLoanDocumentDaoOjb;
12  import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
13  import org.kuali.ole.docstore.common.document.BibTree;
14  import org.kuali.ole.docstore.common.document.HoldingsTree;
15  import org.kuali.ole.docstore.common.document.Item;
16  import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemClaimsReturnedRecord;
17  import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemDamagedRecord;
18  import org.kuali.ole.sys.context.SpringContext;
19  import org.kuali.rice.krad.service.KRADServiceLocator;
20  import org.kuali.rice.krad.util.GlobalVariables;
21  
22  import java.util.ArrayList;
23  import java.util.HashMap;
24  import java.util.List;
25  import java.util.Map;
26  
27  /**
28   * Created by chenchulakshmig on 1/28/15.
29   */
30  public class OLEDeliverItemSearchServiceImpl implements OLEDeliverItemSearchService {
31  
32      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OLEDeliverItemSearchServiceImpl.class);
33  
34      private LoanProcessor loanProcessor;
35      private DocstoreClientLocator docstoreClientLocator;
36  
37      private LoanProcessor getLoanProcessor() {
38          if (loanProcessor == null) {
39              loanProcessor = SpringContext.getBean(LoanProcessor.class);
40          }
41          return loanProcessor;
42      }
43  
44      public DocstoreClientLocator getDocstoreClientLocator() {
45          if (docstoreClientLocator == null) {
46              docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
47          }
48          return docstoreClientLocator;
49      }
50  
51      public void setDeliverRequestInfo(Map itemIdMap, OLESingleItemResultDisplayRow singleItemResultDisplayRow) {
52          List<OleDeliverRequestBo> oleDeliverRequestBos = (List<OleDeliverRequestBo>) KRADServiceLocator.getBusinessObjectService().findMatching(OleDeliverRequestBo.class, itemIdMap);
53          if (CollectionUtils.isNotEmpty(oleDeliverRequestBos)) {
54              List<OLEDeliverRequestResultDisplayRow> deliverRequestResultDisplayRowList = new ArrayList<>();
55              for (OleDeliverRequestBo oleDeliverRequestBo : oleDeliverRequestBos) {
56                  OLEDeliverRequestResultDisplayRow deliverRequestResultDisplayRow = new OLEDeliverRequestResultDisplayRow();
57                  deliverRequestResultDisplayRow.setBorrowerQueuePosition(oleDeliverRequestBo.getBorrowerQueuePosition());
58                  deliverRequestResultDisplayRow.setRequestId(oleDeliverRequestBo.getRequestId());
59                  deliverRequestResultDisplayRow.setRequestTypeCode(oleDeliverRequestBo.getRequestTypeCode());
60                  deliverRequestResultDisplayRow.setBorrowerFirstName(oleDeliverRequestBo.getFirstName());
61                  deliverRequestResultDisplayRow.setBorrowerLastName(oleDeliverRequestBo.getLastName());
62                  deliverRequestResultDisplayRow.setBorrowerBarcode(oleDeliverRequestBo.getBorrowerBarcode());
63                  deliverRequestResultDisplayRow.setCreateDate(oleDeliverRequestBo.getCreateDate());
64                  deliverRequestResultDisplayRow.setExpiryDate(oleDeliverRequestBo.getRequestExpiryDate());
65                  deliverRequestResultDisplayRowList.add(deliverRequestResultDisplayRow);
66              }
67              singleItemResultDisplayRow.setOleDeliverRequestResultDisplayRowList(deliverRequestResultDisplayRowList);
68          }
69      }
70  
71      public void setOutstandingFineInfo(Map itemIdMap, OLESingleItemResultDisplayRow singleItemResultDisplayRow) {
72          List<FeeType> feeTypes = (List<FeeType>) KRADServiceLocator.getBusinessObjectService().findMatching(FeeType.class, itemIdMap);
73          if (CollectionUtils.isNotEmpty(feeTypes)) {
74              PatronBillHelperService patronBillHelperService = new PatronBillHelperService();
75              List<OLEFeeTypeResultDisplayRow> feeTypeResultDisplayRowList = new ArrayList<>();
76              for (FeeType feeType : feeTypes) {
77                  OLEFeeTypeResultDisplayRow feeTypeResultDisplayRow = new OLEFeeTypeResultDisplayRow();
78                  feeTypeResultDisplayRow.setFeeType(feeType.getFeeTypeName());
79                  feeTypeResultDisplayRow.setFeeAmount(feeType.getFeeAmount());
80                  feeTypeResultDisplayRow.setBorrowerId(feeType.getPatronBillPayment().getPatronId());
81                  OlePatronDocument olePatronDocument = patronBillHelperService.getPatronDetails(feeType.getPatronBillPayment().getPatronId());
82                  if (olePatronDocument != null) {
83                      feeTypeResultDisplayRow.setBorrowerBarcode(olePatronDocument.getBarcode());
84                      feeTypeResultDisplayRow.setBorrowerFirstName(olePatronDocument.getFirstName());
85                      feeTypeResultDisplayRow.setBorrowerLastName(olePatronDocument.getLastName());
86                  }
87                  feeTypeResultDisplayRowList.add(feeTypeResultDisplayRow);
88              }
89              singleItemResultDisplayRow.setOleFeeTypeResultDisplayRowList(feeTypeResultDisplayRowList);
90          }
91      }
92  
93      public void setNoteInfo(OLESingleItemResultDisplayRow singleItemResultDisplayRow) {
94          if (singleItemResultDisplayRow.getItemNoteType() != null) {
95              List<OLEItemNoteResultDisplayRow> itemNoteResultDisplayRowList = new ArrayList<>();
96              String[] itemNoteTypes = singleItemResultDisplayRow.getItemNoteType().split(",");
97              String[] itemNoteValues = singleItemResultDisplayRow.getItemNoteValue() != null ? singleItemResultDisplayRow.getItemNoteValue().split(",") : new String[itemNoteTypes.length];
98              for (int noteCount = 0; noteCount < itemNoteTypes.length; noteCount++) {
99                  OLEItemNoteResultDisplayRow itemNoteResultDisplayRow = new OLEItemNoteResultDisplayRow();
100                 itemNoteResultDisplayRow.setNoteType(itemNoteTypes[noteCount]);
101                 itemNoteResultDisplayRow.setNoteValue(itemNoteValues[noteCount]);
102                 itemNoteResultDisplayRowList.add(itemNoteResultDisplayRow);
103             }
104             singleItemResultDisplayRow.setOleItemNoteResultDisplayRowList(itemNoteResultDisplayRowList);
105         }
106     }
107 
108     public void setBorrowerInfo(OLESingleItemResultDisplayRow singleItemResultDisplayRow) {
109         if (StringUtils.isNotBlank(singleItemResultDisplayRow.getCurrentBorrowerId())) {
110             OlePatronDocument olePatronDocument = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(OlePatronDocument.class, singleItemResultDisplayRow.getCurrentBorrowerId());
111             if (olePatronDocument != null) {
112                 singleItemResultDisplayRow.setPatronURL(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), singleItemResultDisplayRow.getCurrentBorrowerId()));
113                 singleItemResultDisplayRow.setPatronBarcode(olePatronDocument.getBarcode());
114                 if (StringUtils.isNotBlank(olePatronDocument.getBorrowerType())) {
115                     OleBorrowerType oleBorrowerType = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(OleBorrowerType.class, olePatronDocument.getBorrowerType());
116                     if (oleBorrowerType != null) {
117                         singleItemResultDisplayRow.setPatronType(oleBorrowerType.getBorrowerTypeName());
118                     }
119                 }
120                 if(olePatronDocument.getExpirationDate()!=null){
121                     singleItemResultDisplayRow.setPatronExpDate(olePatronDocument.getExpirationDate().toString());
122                 }
123                 olePatronDocument = OLEDeliverService.populatePatronName(olePatronDocument);
124                 singleItemResultDisplayRow.setPatronLastName(olePatronDocument.getLastName());
125                 singleItemResultDisplayRow.setPatronFirstName(olePatronDocument.getFirstName());
126                 singleItemResultDisplayRow.setPatronMiddleName(olePatronDocument.getMiddleName());
127                 if (StringUtils.isBlank(singleItemResultDisplayRow.getDueDate())) {
128                     singleItemResultDisplayRow.setDueDate(OLEConstants.INDEFINITE);
129                 }
130             }
131             if (StringUtils.isNotBlank(singleItemResultDisplayRow.getProxyBorrowerId())) {
132                 singleItemResultDisplayRow.setProxyPatronURL(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), singleItemResultDisplayRow.getProxyBorrowerId()));
133                 olePatronDocument = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(OlePatronDocument.class, singleItemResultDisplayRow.getProxyBorrowerId());
134                 singleItemResultDisplayRow.setProxyPatronBarcode(olePatronDocument.getBarcode());
135                 olePatronDocument = OLEDeliverService.populatePatronName(olePatronDocument);
136                 singleItemResultDisplayRow.setProxyPatronName(olePatronDocument.getLastName() + ", "+ olePatronDocument.getFirstName());
137             }
138         }
139     }
140 
141     public void setAdditionalCopiesInfo(OLESingleItemResultDisplayRow singleItemResultDisplayRow) {
142         List<OLEHoldingsSearchResultDisplayRow> oleHoldingsSearchResultDisplayRowList = new ArrayList<>();
143         if (StringUtils.isNotBlank(singleItemResultDisplayRow.getBibIdentifier())) {
144             try {
145                 BibTree bibTree = getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(singleItemResultDisplayRow.getBibIdentifier());
146                 for (HoldingsTree holdingsTree : bibTree.getHoldingsTrees()) {
147                     OLEHoldingsSearchResultDisplayRow holdingsSearchResultDisplayRow = new OLEHoldingsSearchResultDisplayRow();
148                     holdingsSearchResultDisplayRow.setId(holdingsTree.getHoldings().getId());
149                     holdingsSearchResultDisplayRow.setBibIdentifier(bibTree.getBib().getId());
150                     holdingsSearchResultDisplayRow.setLocation(holdingsTree.getHoldings().getLocationName());
151                     if (holdingsTree.getHoldings().getContentObject() != null) {
152                         if (holdingsTree.getHoldings().getContentObject().getCallNumber() != null)
153                             holdingsSearchResultDisplayRow.setCallNumber(holdingsTree.getHoldings().getContentObject().getCallNumber().getNumber());
154                     }
155                     if (holdingsTree.getItems().size() > 0) {
156                         List<OLEItemSearchResultDisplayRow> itemSearchResultDisplayRowList = new ArrayList<>();
157                         for (Item item : holdingsTree.getItems()) {
158                             if (!item.getId().equals(singleItemResultDisplayRow.getId())) {
159                                 OLEItemSearchResultDisplayRow oleItemSearchResultDisplayRow = new OLEItemSearchResultDisplayRow();
160                                 oleItemSearchResultDisplayRow.setId(item.getId());
161                                 oleItemSearchResultDisplayRow.setHoldingsIdentifier(holdingsTree.getHoldings().getId());
162                                 oleItemSearchResultDisplayRow.setBibIdentifier(bibTree.getBib().getId());
163                                 oleItemSearchResultDisplayRow.setLocation(item.getLocation());
164                                 Object itemContent = item.getContentObject();
165                                 if (itemContent != null) {
166                                     org.kuali.ole.docstore.common.document.content.instance.Item itemPojo = (org.kuali.ole.docstore.common.document.content.instance.Item) itemContent;
167                                     oleItemSearchResultDisplayRow.setEnumeration(itemPojo.getEnumeration());
168                                     oleItemSearchResultDisplayRow.setChronology(itemPojo.getChronology());
169                                     if (itemPojo.getItemType() != null)
170                                         oleItemSearchResultDisplayRow.setItemType(itemPojo.getItemType().getCodeValue());
171                                     if (itemPojo.getItemStatus() != null)
172                                         oleItemSearchResultDisplayRow.setItemStatus(itemPojo.getItemStatus().getCodeValue());
173                                     if (itemPojo.getAccessInformation() != null)
174                                         oleItemSearchResultDisplayRow.setItemBarCode(itemPojo.getAccessInformation().getBarcode());
175                                     Map itemMap = new HashMap();
176                                     itemMap.put(OLEConstants.OleDeliverRequest.ITEM_ID, oleItemSearchResultDisplayRow.getItemBarCode());
177                                     List<OleDeliverRequestBo> deliverRequestBos = (List<OleDeliverRequestBo>) KRADServiceLocator.getBusinessObjectService().findMatching(OleDeliverRequestBo.class, itemMap);
178                                     if (CollectionUtils.isNotEmpty(deliverRequestBos)) {
179                                         oleItemSearchResultDisplayRow.setRequestExists(true);
180                                     }
181                                     oleItemSearchResultDisplayRow.setPlaceRequest(validateItemStatusForPlaceRequest(oleItemSearchResultDisplayRow.getItemStatus()));
182                                 }
183                                 itemSearchResultDisplayRowList.add(oleItemSearchResultDisplayRow);
184                             }
185                         }
186                         if (itemSearchResultDisplayRowList.size() > 0) {
187                             if (itemSearchResultDisplayRowList.size() == 1) {
188                                 holdingsSearchResultDisplayRow.setItemLocation(itemSearchResultDisplayRowList.get(0).getLocation());
189                             } else {
190                                 holdingsSearchResultDisplayRow.setItemLocation(OLEConstants.MULTIPLE);
191                             }
192                             holdingsSearchResultDisplayRow.setOleItemSearchResultDisplayRowList(itemSearchResultDisplayRowList);
193                             oleHoldingsSearchResultDisplayRowList.add(holdingsSearchResultDisplayRow);
194                         }
195                     }
196                 }
197             } catch (Exception e) {
198                 LOG.error("Exception " + e);
199             }
200         }
201         singleItemResultDisplayRow.setOleHoldingsSearchResultDisplayRowList(oleHoldingsSearchResultDisplayRowList);
202     }
203 
204     public void setRequestHistoryInfo(OLESingleItemResultDisplayRow singleItemResultDisplayRow) {
205         if (StringUtils.isNotBlank(singleItemResultDisplayRow.getItemBarCode())) {
206             List<OleDeliverRequestHistoryRecord> deliverRequestHistoryRecordList = (List<OleDeliverRequestHistoryRecord>) ((OleLoanDocumentDaoOjb) SpringContext.getBean("oleLoanDao")).getDeliverRequestHistoryRecords(singleItemResultDisplayRow.getItemBarCode());
207             if (deliverRequestHistoryRecordList != null && deliverRequestHistoryRecordList.size() > 0) {
208                 singleItemResultDisplayRow.setRequestTypeCode(deliverRequestHistoryRecordList.get(0).getDeliverRequestTypeCode());
209                 singleItemResultDisplayRow.setPickUpLocationCode(deliverRequestHistoryRecordList.get(0).getPickUpLocationCode());
210                 singleItemResultDisplayRow.setFinalStatus("Filed");
211                 singleItemResultDisplayRow.setFinalStatusDate(deliverRequestHistoryRecordList.get(0).getArchiveDate());
212             }
213         }
214     }
215 
216     public void setInTransitHistoryInfo(OLESingleItemResultDisplayRow singleItemResultDisplayRow) {
217         if (StringUtils.isNotBlank(singleItemResultDisplayRow.getId())) {
218             Map map = new HashMap();
219             map.put(OLEConstants.OVERLAY_ITEMUUID, singleItemResultDisplayRow.getId());
220             List<OLELoanIntransitRecordHistory> oleIntransitRecordHistories = (List<OLELoanIntransitRecordHistory>) KRADServiceLocator.getBusinessObjectService().findMatching(OLELoanIntransitRecordHistory.class, map);
221             if (CollectionUtils.isNotEmpty(oleIntransitRecordHistories)) {
222                 singleItemResultDisplayRow.setOleIntransitRecordHistories(oleIntransitRecordHistories);
223             }
224         }
225     }
226 
227     public void setClaimsReturnedInfo(OLESingleItemResultDisplayRow singleItemResultDisplayRow) {
228         if(StringUtils.isNotBlank(singleItemResultDisplayRow.getId())) {
229             Map map = new HashMap();
230             map.put("itemId", DocumentUniqueIDPrefix.getDocumentId(singleItemResultDisplayRow.getId()));
231             List<ItemClaimsReturnedRecord> itemClaimsReturnedRecords = (List<ItemClaimsReturnedRecord>) KRADServiceLocator.getBusinessObjectService().findMatching(ItemClaimsReturnedRecord.class,map);
232             if(CollectionUtils.isNotEmpty(itemClaimsReturnedRecords)) {
233                 for(int index=0 ; index < itemClaimsReturnedRecords.size() ; index++){
234                     if(itemClaimsReturnedRecords.get(index).getClaimsReturnedPatronId() != null && !itemClaimsReturnedRecords.get(index).getClaimsReturnedPatronId().isEmpty()){
235                         OlePatronDocument olePatronDocument = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(OlePatronDocument.class, itemClaimsReturnedRecords.get(index).getClaimsReturnedPatronId());
236                         if(olePatronDocument != null){
237                             itemClaimsReturnedRecords.get(index).setClaimsReturnedPatronBarcode(olePatronDocument.getBarcode());
238                             itemClaimsReturnedRecords.get(index).setClaimsReturnedPatronUrl(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), itemClaimsReturnedRecords.get(index).getClaimsReturnedPatronId()));
239                         }
240                     } else if(itemClaimsReturnedRecords.get(index).getClaimsReturnedPatronBarcode() != null && !itemClaimsReturnedRecords.get(index).getClaimsReturnedPatronBarcode().isEmpty()) {
241                         Map criteria = new HashMap();
242                         criteria.put("barcode",itemClaimsReturnedRecords.get(index).getClaimsReturnedPatronBarcode());
243                         List<OlePatronDocument> olePatronDocumentList = (List<OlePatronDocument>)KRADServiceLocator.getBusinessObjectService().findMatching(OlePatronDocument.class,criteria);
244                         if(CollectionUtils.isNotEmpty(olePatronDocumentList)) {
245                             for(OlePatronDocument olePatronDocument : olePatronDocumentList) {
246                                 itemClaimsReturnedRecords.get(index).setClaimsReturnedPatronUrl(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), olePatronDocument.getOlePatronId()));
247                             }
248                         } else {
249                             criteria = new HashMap();
250                             criteria.put("invalidOrLostBarcodeNumber", itemClaimsReturnedRecords.get(index).getClaimsReturnedPatronBarcode());
251                             List<OlePatronLostBarcode> olePatronLostBarcodeList = (List<OlePatronLostBarcode>) KRADServiceLocator.getBusinessObjectService().findMatching(OlePatronLostBarcode.class, criteria);
252                             if(CollectionUtils.isNotEmpty(olePatronLostBarcodeList)){
253                                 for(OlePatronLostBarcode olePatronLostBarcode : olePatronLostBarcodeList) {
254                                     itemClaimsReturnedRecords.get(index).setClaimsReturnedPatronUrl(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), olePatronLostBarcode.getOlePatronId()));
255                                 }
256                             }
257                         }
258                     }
259                 }
260                 singleItemResultDisplayRow.setItemClaimsReturnedRecords(itemClaimsReturnedRecords);
261             }
262         }
263     }
264 
265     public void setDamagedInfo(OLESingleItemResultDisplayRow singleItemResultDisplayRow){
266         if(StringUtils.isNotBlank(singleItemResultDisplayRow.getId())) {
267             Map map = new HashMap();
268             map.put("itemId",DocumentUniqueIDPrefix.getDocumentId(singleItemResultDisplayRow.getId()));
269             List<ItemDamagedRecord> itemDamagedRecords = (List<ItemDamagedRecord>) KRADServiceLocator.getBusinessObjectService().findMatching(ItemDamagedRecord.class,map);
270             if(CollectionUtils.isNotEmpty(itemDamagedRecords)){
271                 for(int index=0 ; index < itemDamagedRecords.size() ; index++){
272                     if(itemDamagedRecords.get(index).getDamagedPatronId() != null && !itemDamagedRecords.get(index).getDamagedPatronId().isEmpty()){
273                         OlePatronDocument olePatronDocument = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(OlePatronDocument.class,itemDamagedRecords.get(index).getDamagedPatronId());
274                         if(olePatronDocument != null){
275                             itemDamagedRecords.get(index).setPatronBarcode(olePatronDocument.getBarcode());
276                             itemDamagedRecords.get(index).setDamagedPatronUrl(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), itemDamagedRecords.get(index).getDamagedPatronId()));
277                         }
278                     } else if(itemDamagedRecords.get(index).getPatronBarcode() != null && !itemDamagedRecords.get(index).getPatronBarcode().isEmpty()) {
279                         Map criteria = new HashMap();
280                         criteria.put("barcode",itemDamagedRecords.get(index).getPatronBarcode());
281                         List<OlePatronDocument> olePatronDocumentList = (List<OlePatronDocument>) KRADServiceLocator.getBusinessObjectService().findMatching(OlePatronDocument.class, criteria);
282                         if(olePatronDocumentList != null && olePatronDocumentList.size() > 0) {
283                             for(OlePatronDocument olePatronDocument : olePatronDocumentList) {
284                                 itemDamagedRecords.get(index).setDamagedPatronUrl(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), olePatronDocument.getOlePatronId()));
285                             }
286                         } else {
287                             criteria = new HashMap();
288                             criteria.put("invalidOrLostBarcodeNumber", itemDamagedRecords.get(index).getPatronBarcode());
289                             List<OlePatronLostBarcode> olePatronLostBarcodeList = (List<OlePatronLostBarcode>) KRADServiceLocator.getBusinessObjectService().findMatching(OlePatronLostBarcode.class, criteria);
290                             if(CollectionUtils.isNotEmpty(olePatronLostBarcodeList)){
291                                 for(OlePatronLostBarcode olePatronLostBarcode : olePatronLostBarcodeList) {
292                                     itemDamagedRecords.get(index).setDamagedPatronUrl(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), olePatronLostBarcode.getOlePatronId()));
293                                 }
294                             }
295                         }
296                     }
297                 }
298                 singleItemResultDisplayRow.setItemDamagedRecords(itemDamagedRecords);
299             }
300         }
301     }
302 
303 
304     public void setMissingPieceItemInfo(OLESingleItemResultDisplayRow singleItemResultDisplayRow){
305         if(StringUtils.isNotBlank(singleItemResultDisplayRow.getId())){
306             Map map = new HashMap();
307             map.put("itemId", DocumentUniqueIDPrefix.getDocumentId(singleItemResultDisplayRow.getId()));
308             List<org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.MissingPieceItemRecord> missingPieceItemRecordHistories = (List<org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.MissingPieceItemRecord>)KRADServiceLocator.getBusinessObjectService().findMatching(org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.MissingPieceItemRecord.class, map);
309             if(CollectionUtils.isNotEmpty(missingPieceItemRecordHistories)){
310                 for(int index=0 ; index < missingPieceItemRecordHistories.size() ; index++){
311                     if(missingPieceItemRecordHistories.get(index).getPatronId() != null && !missingPieceItemRecordHistories.get(index).getPatronId().isEmpty()){
312                         OlePatronDocument olePatronDocument = KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(OlePatronDocument.class,missingPieceItemRecordHistories.get(index).getPatronId());
313                         if(olePatronDocument != null){
314                             missingPieceItemRecordHistories.get(index).setPatronBarcode(olePatronDocument.getBarcode());
315                             missingPieceItemRecordHistories.get(index).setPatronURL(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), missingPieceItemRecordHistories.get(index).getPatronId()));
316                         }
317                     }else if(missingPieceItemRecordHistories.get(index).getPatronBarcode() != null && !missingPieceItemRecordHistories.get(index).getPatronBarcode().isEmpty()){
318                         Map criteria = new HashMap();
319                         criteria.put("barcode" , missingPieceItemRecordHistories.get(index).getPatronBarcode());
320                         List<OlePatronDocument> olePatronDocumentList = (List<OlePatronDocument>)KRADServiceLocator.getBusinessObjectService().findMatching(OlePatronDocument.class ,criteria );
321                         if(olePatronDocumentList != null && olePatronDocumentList.size()>0){
322                             for(OlePatronDocument olePatronDocument : olePatronDocumentList){
323                                 missingPieceItemRecordHistories.get(index).setPatronURL(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), missingPieceItemRecordHistories.get(index).getPatronId()));
324                             }
325                         }else{
326                             Map criteria1 = new HashMap();
327                             criteria1.put("invalidOrLostBarcodeNumber" ,missingPieceItemRecordHistories.get(index).getPatronBarcode() );
328                             List<OlePatronLostBarcode> olePatronLostBarcodeList = (List<OlePatronLostBarcode>)KRADServiceLocator.getBusinessObjectService().findMatching(OlePatronLostBarcode.class , criteria1);
329                             if(olePatronLostBarcodeList != null && olePatronLostBarcodeList.size()>0){
330                                 for(OlePatronLostBarcode olePatronLostBarcode : olePatronLostBarcodeList){
331                                     missingPieceItemRecordHistories.get(index).setPatronURL(getLoanProcessor().patronNameURL(GlobalVariables.getUserSession().getPrincipalId(), missingPieceItemRecordHistories.get(index).getPatronId()));
332                                 }
333                             }
334                         }
335                     }
336                 }
337                 singleItemResultDisplayRow.setMissingPieceItemRecordList(missingPieceItemRecordHistories);
338             }
339 
340         }
341     }
342 
343     public boolean validateItemStatusForPlaceRequest(String oleItemStatus) {
344         boolean valid = false;
345         if (StringUtils.isNotBlank(oleItemStatus)){
346             String copyRequestItemStatus = getLoanProcessor().getParameter(OLEConstants.COPY_REQUEST_ITEM_STATUS);
347             if (org.apache.commons.lang.StringUtils.isNotBlank(copyRequestItemStatus)) {
348                 String[] itemStatusArray = copyRequestItemStatus.split(";");
349                 for(String itemStatus : itemStatusArray){
350                     if(itemStatus.trim().equalsIgnoreCase(oleItemStatus)){
351                         valid = true;
352                         return valid;
353                     }
354                 }
355             }
356 
357             String holdDeliveryItemStatus = getLoanProcessor().getParameter(OLEConstants.HOLD_DELIVERY_ITEM_STATUS);
358             if (org.apache.commons.lang.StringUtils.isNotBlank(holdDeliveryItemStatus)) {
359                 String[] itemStatusArray = holdDeliveryItemStatus.split(";");
360                 for(String itemStatus : itemStatusArray){
361                     if(itemStatus.trim().equalsIgnoreCase(oleItemStatus)){
362                         valid = true;
363                         return valid;
364                     }
365                 }
366             }
367             String holdHoldItemStatus = getLoanProcessor().getParameter(OLEConstants.HOLD_HOLD_ITEM_STATUS);
368             if (org.apache.commons.lang.StringUtils.isNotBlank(holdHoldItemStatus)) {
369                 String[] itemStatusArray = holdHoldItemStatus.split(";");
370                 for(String itemStatus : itemStatusArray){
371                     if(itemStatus.trim().equalsIgnoreCase(oleItemStatus)){
372                         valid = true;
373                         return valid;
374                     }
375                 }
376             }
377             String pageDeliveryItemStatus = getLoanProcessor().getParameter(OLEConstants.PAGE_DELIVERY_ITEM_STATUS);
378             if (org.apache.commons.lang.StringUtils.isNotBlank(pageDeliveryItemStatus)) {
379                 String[] itemStatusArray = pageDeliveryItemStatus.split(";");
380                 for(String itemStatus : itemStatusArray){
381                     if(itemStatus.trim().equalsIgnoreCase(oleItemStatus)){
382                         valid = true;
383                         return valid;
384                     }
385                 }
386             }
387             String pageHoldItemStatus = getLoanProcessor().getParameter(OLEConstants.PAGE_HOLD_ITEM_STATUS);
388             if (org.apache.commons.lang.StringUtils.isNotBlank(pageHoldItemStatus)) {
389                 String[] itemStatusArray = pageHoldItemStatus.split(";");
390                 for(String itemStatus : itemStatusArray){
391                     if(itemStatus.trim().equalsIgnoreCase(oleItemStatus)){
392                         valid = true;
393                         return valid;
394                     }
395                 }
396             }
397             String recallDeliveryItemStatus = getLoanProcessor().getParameter(OLEConstants.RECALL_DELIVERY_ITEM_STATUS);
398             if (org.apache.commons.lang.StringUtils.isNotBlank(recallDeliveryItemStatus)) {
399                 String[] itemStatusArray = recallDeliveryItemStatus.split(";");
400                 for(String itemStatus : itemStatusArray){
401                     if(itemStatus.trim().equalsIgnoreCase(oleItemStatus)){
402                         valid = true;
403                         return valid;
404                     }
405                 }
406             }
407             String recallHoldItemStatus = getLoanProcessor().getParameter(OLEConstants.RECALL_HOLD_ITEM_STATUS);
408             if (org.apache.commons.lang.StringUtils.isNotBlank(recallHoldItemStatus)) {
409                 String[] itemStatusArray = recallHoldItemStatus.split(";");
410                 for(String itemStatus : itemStatusArray){
411                     if(itemStatus.trim().equalsIgnoreCase(oleItemStatus)){
412                         valid = true;
413                         return valid;
414                     }
415                 }
416             }
417         }
418         return valid;
419     }
420 }