View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.select.document;
17  
18  import org.apache.commons.lang.StringEscapeUtils;
19  import org.kuali.ole.docstore.common.client.*;
20  import org.kuali.ole.docstore.common.document.Bib;
21  import org.kuali.ole.docstore.common.document.BibMarc;
22  import org.kuali.ole.docstore.common.document.BibTree;
23  import org.kuali.ole.DocumentUniqueIDPrefix;
24  import org.kuali.ole.docstore.model.bo.WorkBibDocument;
25  import org.kuali.ole.docstore.model.bo.WorkInstanceDocument;
26  import org.kuali.ole.docstore.model.bo.WorkItemDocument;
27  import org.kuali.ole.docstore.model.enums.DocType;
28  import org.kuali.ole.module.purap.document.LineItemReceivingDocument;
29  import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
30  import org.kuali.ole.select.OleSelectConstant;
31  import org.kuali.ole.select.businessobject.*;
32  import org.kuali.ole.select.document.service.OleLineItemReceivingService;
33  import org.kuali.ole.select.document.service.OlePurchaseOrderDocumentHelperService;
34  import org.kuali.ole.select.service.BibInfoService;
35  import org.kuali.ole.select.service.BibInfoWrapperService;
36  import org.kuali.ole.select.service.FileProcessingService;
37  import org.kuali.ole.select.service.impl.BibInfoServiceImpl;
38  import org.kuali.ole.select.service.impl.exception.DocStoreConnectionException;
39  import org.kuali.ole.sys.OLEConstants;
40  import org.kuali.ole.sys.context.SpringContext;
41  import org.kuali.ole.sys.service.impl.OleParameterConstants;
42  import org.kuali.rice.core.api.config.property.ConfigurationService;
43  import org.kuali.rice.core.api.util.RiceKeyConstants;
44  import org.kuali.rice.core.api.util.type.KualiDecimal;
45  import org.kuali.rice.core.api.util.type.KualiInteger;
46  import org.kuali.rice.coreservice.framework.parameter.ParameterConstants.COMPONENT;
47  import org.kuali.rice.coreservice.framework.parameter.ParameterConstants.NAMESPACE;
48  import org.kuali.rice.krad.util.GlobalVariables;
49  import org.kuali.rice.krad.util.ObjectUtils;
50  import java.util.*;
51  
52  /**
53   * This class is the document class for Ole Line Item Receiving
54   */
55  @NAMESPACE(namespace = OleParameterConstants.PURCHASING_NAMESPACE)
56  @COMPONENT(component = "LineItemReceivingDocument")
57  public class OleLineItemReceivingDocument extends LineItemReceivingDocument {
58  
59      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleLineItemReceivingDocument.class);
60  
61      private static transient ConfigurationService kualiConfigurationService;
62      private static transient BibInfoWrapperService bibInfoWrapperService;
63      private static transient FileProcessingService fileProcessingService;
64      private static transient OleLineItemReceivingService oleLineItemReceivingService;
65      //private static transient OleLineItemReceivingDocumentHelperService oleLineItemReceivingDocumentHelperService;
66      private static transient BibInfoService bibInfoService;
67      private DocstoreClientLocator docstoreClientLocator;
68  
69      public DocstoreClientLocator getDocstoreClientLocator() {
70          if (docstoreClientLocator == null) {
71              docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
72          }
73          return docstoreClientLocator;
74      }
75  
76      public static BibInfoService getBibInfoService() {
77          if (bibInfoService == null) {
78              bibInfoService = SpringContext.getBean(BibInfoServiceImpl.class);
79          }
80          return bibInfoService;
81      }
82  
83      public static OleLineItemReceivingService getOleLineItemReceivingService() {
84          if (oleLineItemReceivingService == null) {
85              oleLineItemReceivingService = SpringContext.getBean(OleLineItemReceivingService.class);
86          }
87          return oleLineItemReceivingService;
88      }
89  
90      public static void setOleLineItemReceivingService(OleLineItemReceivingService oleLineItemReceivingService) {
91          OleLineItemReceivingDocument.oleLineItemReceivingService = oleLineItemReceivingService;
92      }
93  
94  
95      public static ConfigurationService getConfigurationService() {
96          if (kualiConfigurationService == null) {
97              kualiConfigurationService = SpringContext.getBean(ConfigurationService.class);
98          }
99          return kualiConfigurationService;
100     }
101 
102     public static void setConfigurationService(ConfigurationService kualiConfigurationService) {
103         OleLineItemReceivingDocument.kualiConfigurationService = kualiConfigurationService;
104     }
105 
106     public static BibInfoWrapperService getBibInfoWrapperService() {
107         if (bibInfoWrapperService == null) {
108             bibInfoWrapperService = SpringContext.getBean(BibInfoWrapperService.class);
109         }
110         return bibInfoWrapperService;
111     }
112 
113     public static void setBibInfoWrapperService(BibInfoWrapperService bibInfoWrapperService) {
114         OleLineItemReceivingDocument.bibInfoWrapperService = bibInfoWrapperService;
115     }
116 
117     public static FileProcessingService getFileProcessingService() {
118         if (fileProcessingService == null) {
119             fileProcessingService = SpringContext.getBean(FileProcessingService.class);
120         }
121         return fileProcessingService;
122     }
123 
124     public static void setFileProcessingService(FileProcessingService fileProcessingService) {
125         OleLineItemReceivingDocument.fileProcessingService = fileProcessingService;
126     }
127 
128     public boolean getIsFinalReqs() {
129         if (this.getDocumentHeader().getWorkflowDocument().isFinal()) {
130             return true;
131         }
132         return false;
133     }
134 
135     /**
136      * This method sets the intial values for the document
137      */
138     public void initiateDocument() {
139         super.initiateDocument();
140         getOleLineItemReceivingService().getInitialCollapseSections(this);
141     }
142 
143     /**
144      * This method is overridden to populate OleLineItemReceivingItem from PurchaseOrderDocument.
145      *
146      * @param PurchaseOrderDocument
147      */
148     @Override
149     public void populateReceivingLineFromPurchaseOrder(PurchaseOrderDocument po) {
150         LOG.debug("Inside populateReceivingLineFromPurchaseOrder of OleLineItemReceivingDocument");
151         // populate receiving line document from purchase order
152         this.setPurchaseOrderIdentifier(po.getPurapDocumentIdentifier());
153         this.getDocumentHeader().setOrganizationDocumentNumber(po.getDocumentHeader().getOrganizationDocumentNumber());
154         this.setAccountsPayablePurchasingDocumentLinkIdentifier(po.getAccountsPayablePurchasingDocumentLinkIdentifier());
155 
156         // copy vendor
157         this.setVendorHeaderGeneratedIdentifier(po.getVendorHeaderGeneratedIdentifier());
158         this.setVendorDetailAssignedIdentifier(po.getVendorDetailAssignedIdentifier());
159         this.setVendorName(po.getVendorName());
160         this.setVendorNumber(po.getVendorNumber());
161         this.setVendorAddressGeneratedIdentifier(po.getVendorAddressGeneratedIdentifier());
162         this.setVendorLine1Address(po.getVendorLine1Address());
163         this.setVendorLine2Address(po.getVendorLine2Address());
164         this.setVendorCityName(po.getVendorCityName());
165         this.setVendorStateCode(po.getVendorStateCode());
166         this.setVendorPostalCode(po.getVendorPostalCode());
167         this.setVendorCountryCode(po.getVendorCountryCode());
168 
169         // copy alternate vendor
170         this.setAlternateVendorName(po.getAlternateVendorName());
171         this.setAlternateVendorNumber(po.getAlternateVendorNumber());
172         this.setAlternateVendorDetailAssignedIdentifier(po.getAlternateVendorDetailAssignedIdentifier());
173         this.setAlternateVendorHeaderGeneratedIdentifier(po.getAlternateVendorHeaderGeneratedIdentifier());
174 
175         // copy delivery
176         this.setDeliveryBuildingCode(po.getDeliveryBuildingCode());
177         this.setDeliveryBuildingLine1Address(po.getDeliveryBuildingLine1Address());
178         this.setDeliveryBuildingLine2Address(po.getDeliveryBuildingLine2Address());
179         this.setDeliveryBuildingName(po.getDeliveryBuildingName());
180         this.setDeliveryBuildingRoomNumber(po.getDeliveryBuildingRoomNumber());
181         this.setDeliveryCampusCode(po.getDeliveryCampusCode());
182         this.setDeliveryCityName(po.getDeliveryCityName());
183         this.setDeliveryCountryCode(po.getDeliveryCountryCode());
184         this.setDeliveryInstructionText(po.getDeliveryInstructionText());
185         this.setDeliveryPostalCode(po.getDeliveryPostalCode());
186         this.setDeliveryRequiredDate(po.getDeliveryRequiredDate());
187         this.setDeliveryRequiredDateReasonCode(po.getDeliveryRequiredDateReasonCode());
188         this.setDeliveryStateCode(po.getDeliveryStateCode());
189         this.setDeliveryToEmailAddress(po.getDeliveryToEmailAddress());
190         this.setDeliveryToName(po.getDeliveryToName());
191         this.setDeliveryToPhoneNumber(po.getDeliveryToPhoneNumber());
192 
193         // copy purchase order items
194         for (OlePurchaseOrderItem poi : (List<OlePurchaseOrderItem>) po.getItems()) {
195             // TODO: Refactor this check into a service call. route FYI during submit
196             if (poi.isItemActiveIndicator() && poi.getItemType().isQuantityBasedGeneralLedgerIndicator() && poi.getItemType().isLineItemIndicator()) {
197                 this.getItems().add(new OleLineItemReceivingItem(poi, this));
198             }
199         }
200 
201         populateDocumentDescription(po);
202         LOG.debug("Leaving populateReceivingLineFromPurchaseOrder of OleLineItemReceivingDocument");
203     }
204 
205     @Override
206     public void prepareForSave() {
207         try {
208             String titleId = null;
209             List<OleLineItemReceivingItem> items = new ArrayList<OleLineItemReceivingItem>();
210             items = this.getItems();
211 
212             Iterator iterator = items.iterator();
213             HashMap dataMap = new HashMap();
214             int itemCount = 0;
215             while (iterator.hasNext()) {
216                 LOG.debug("###########inside prepareForSave item loop###########");
217                 Object object = iterator.next();
218                 if (object instanceof OleLineItemReceivingItem) {
219                     LOG.debug("###########inside prepareForSave ole requisition item###########");
220                     OleLineItemReceivingItem singleItem = (OleLineItemReceivingItem) object;
221                     if (singleItem.getItemTitleId() != null) {
222                         titleId = singleItem.getItemTitleId();
223                     } else if (singleItem.getBibInfoBean() != null) {
224                         titleId = singleItem.getBibInfoBean().getTitleId();
225                     }
226                     if (ObjectUtils.isNull(singleItem.getItemReceivedTotalParts())) {
227                         singleItem.setItemReceivedTotalParts(KualiDecimal.ZERO);
228                     } else if (ObjectUtils.isNull(singleItem.getItemReceivedTotalQuantity())) {
229                         singleItem.setItemReceivedTotalQuantity(KualiDecimal.ZERO);
230                     } else if (ObjectUtils.isNull(singleItem.getItemReturnedTotalParts())) {
231                         singleItem.setItemReturnedTotalParts(KualiDecimal.ZERO);
232                     } else if (ObjectUtils.isNull(singleItem.getItemReturnedTotalQuantity())) {
233                         singleItem.setItemReturnedTotalQuantity(KualiDecimal.ZERO);
234                     } else if (ObjectUtils.isNull(singleItem.getItemDamagedTotalParts())) {
235                         singleItem.setItemDamagedTotalParts(KualiDecimal.ZERO);
236                     } else if (ObjectUtils.isNull(singleItem.getItemDamagedTotalQuantity())) {
237                         singleItem.setItemDamagedTotalQuantity(KualiDecimal.ZERO);
238                     }
239                 }
240             }
241             super.prepareForSave();
242         } catch (DocStoreConnectionException dsce) {
243             GlobalVariables.getMessageMap().putError("error.requisition.docstore.connectionError", RiceKeyConstants.ERROR_CUSTOM, "Error while connecting to document storage server, contact system administrator.");
244         } catch (Exception e) {
245             LOG.error("Exception during prepareForSave() in OleLineItemReceivingDocument"+e);
246             throw new RuntimeException(e);
247         }
248     }
249 
250     /**
251      * This method is overridden to set special processing notes and other types of receipt notes in two different lists to be
252      * displayed under Special Processing Notes Tab and Receipt Notes tab respectively.
253      */
254     @Override
255     public void processAfterRetrieve() {
256         try {
257             LOG.debug("Inside processAfterRetrieve of OleLineItemReceivingDocument");
258 
259             String itemDescription = "";
260             List<OleLineItemReceivingItem> items = new ArrayList<OleLineItemReceivingItem>();
261             items = this.getItems();
262             Iterator iterator = items.iterator();
263             String titleId = null;
264             int itemCount = 0;
265             boolean isBibFileExist = false;
266             boolean isBibEdit = false;
267             List receiptNoteList;
268             List specialHandlingNoteList;
269             for (OleLineItemReceivingItem item : items) {
270                 receiptNoteList = new ArrayList();
271                 specialHandlingNoteList = new ArrayList();
272                 List<OleLineItemReceivingReceiptNotes> notes = new ArrayList<OleLineItemReceivingReceiptNotes>();
273                 notes = item.getNoteList();
274                 for (OleLineItemReceivingReceiptNotes note : notes) {
275                     String noteType = note.getNoteType().getNoteType();
276                     if (noteType.equalsIgnoreCase(OLEConstants.SPECIAL_PROCESSING_INSTRUCTION_NOTE)) {
277                         specialHandlingNoteList.add(note);
278                     } else {
279                         receiptNoteList.add(note);
280                     }
281                     item.setSpecialHandlingNoteList(specialHandlingNoteList);
282                     item.setReceiptNoteList(receiptNoteList);
283                     item.setReceiptNoteListSize(receiptNoteList.size());
284                 }
285             }
286             while (iterator.hasNext()) {
287                 LOG.debug("###########inside processAfterRetrieve item loop###########");
288                 Object object = iterator.next();
289                 if (object instanceof OleLineItemReceivingItem) {
290                     LOG.debug("###########inside processAfterRetrieve ole requisition item###########");
291                     OleLineItemReceivingItem singleItem = (OleLineItemReceivingItem) object;
292                     if (LOG.isDebugEnabled()) {
293                         LOG.debug("Title id while retriving ------>" + singleItem.getItemTitleId());
294                     }
295                     BibInfoBean xmlBibInfoBean = new BibInfoBean();
296                     HashMap<String, String> dataMap = new HashMap<String, String>();
297                     // Modified for Jira OLE-2515
298 /*                    if (!StringUtils.equalsIgnoreCase(singleItem.getItemTypeCode(), PurapConstants.ItemTypeCodes.ITEM_TYPE_UNORDERED_ITEM_CODE)) {
299                         OlePurchaseOrderItem olePurchaseOrderItem = getOleLineItemReceivingService().getOlePurchaseOrderItem(singleItem.getPurchaseOrderIdentifier());
300                         singleItem.setItemTitleId(olePurchaseOrderItem.getItemTitleId());
301                     }*/
302                     if (singleItem.getItemTitleId() == null) {
303                         singleItem.setItemTitleId(getOleLineItemReceivingService().getLineItemDocItemTitleId(singleItem));
304                     }
305 
306                     if (singleItem.getItemTitleId() != null) {
307                         Bib bib = new BibMarc();
308                         if (singleItem.getItemTitleId() != null && singleItem.getItemTitleId() != "") {
309                             bib = getDocstoreClientLocator().getDocstoreClient().retrieveBib(singleItem.getItemTitleId());
310                             singleItem.setBibUUID(bib.getId());
311                         }
312                         singleItem.setDocFormat(DocumentUniqueIDPrefix.getBibFormatType(singleItem.getItemTitleId()));
313                         itemDescription = ((bib.getTitle() != null && !bib.getTitle().isEmpty()) ? bib.getTitle().trim() + ", " : "") +
314                                 ((bib.getAuthor() != null && !bib.getAuthor().isEmpty()) ? bib.getAuthor().trim() + ", " : "") +
315                                 ((bib.getPublisher() != null && !bib.getPublisher().isEmpty()) ? bib.getPublisher().trim() + ", " : "") +
316                                 ((bib.getIsbn() != null && !bib.getIsbn().isEmpty()) ? bib.getIsbn().trim() + ", " : "");
317                         if (itemDescription != null && !(itemDescription.equals(""))) {
318                             itemDescription = itemDescription.lastIndexOf(",") < 0 ? itemDescription :
319                                     itemDescription.substring(0, itemDescription.lastIndexOf(","));
320                             StringEscapeUtils stringEscapeUtils = new StringEscapeUtils();
321                             itemDescription = stringEscapeUtils.unescapeXml(itemDescription);
322                             singleItem.setItemDescription(itemDescription);
323                         }
324                     }
325                     Map cpySection = new HashMap();
326                     cpySection.put("itemIdentifier", singleItem.getPurchaseOrderIdentifier());
327 
328                     List<OlePurchaseOrderItem> olePurchaseOrderItems = (List<OlePurchaseOrderItem>) getBusinessObjectService().findMatching(OlePurchaseOrderItem.class, cpySection);
329                     if (olePurchaseOrderItems.size() > 0) {
330                         for (OlePurchaseOrderItem item : olePurchaseOrderItems) {
331                             singleItem.setCopyList(item.getCopyList());
332                         }
333                     }
334                 }
335             }
336             LOG.debug("Leaving processAfterRetrieve of OleLineItemReceivingDocument");
337         } catch (Exception e) {
338             LOG.error("Exception during processAfterRetrieve() in OleLineItemReceivingDocument"+e);
339             throw new RuntimeException(e);
340         }
341     }
342 
343     // Added for Jira OLE-1900 Starts
344 
345 
346     public void setEnumerationToCopies(OleLineItemReceivingItem singleItem) {
347         String partEnumerationCopy = getConfigurationService().getPropertyValueAsString(
348                 OLEConstants.PART_ENUMERATION_COPY);
349         String partEnumerationVolume = getConfigurationService().getPropertyValueAsString(
350                 OLEConstants.PART_ENUMERATION_VOLUME);
351         List<OleCopies> itemCopies = singleItem.getCopies();
352         List<OleCopies> copiesList = new ArrayList<OleCopies>();
353         for (int copies = 0; copies < itemCopies.size(); copies++) {
354             itemCopies.get(copies).setParts(new KualiInteger(singleItem.getItemReceivedTotalParts().intValue()));
355             int startingCopyNumber = itemCopies.get(copies).getStartingCopyNumber().intValue();
356             StringBuffer enumeration = new StringBuffer();
357             for (int noOfCopies = 0; noOfCopies < singleItem.getItemCopies().intValue(); noOfCopies++) {
358                 for (int noOfParts = 0; noOfParts < singleItem.getItemReceivedTotalParts().intValue(); noOfParts++) {
359                     int newNoOfCopies = startingCopyNumber + noOfCopies;
360                     int newNoOfParts = noOfParts + 1;
361                     if (noOfCopies + 1 == singleItem.getItemCopies().intValue()
362                             && newNoOfParts == singleItem.getItemReceivedTotalParts().intValue()) {
363                         enumeration = enumeration.append(
364                                 partEnumerationCopy + newNoOfCopies + OLEConstants.DOT_TO_SEPARATE_COPIES_PARTS)
365                                 .append(
366                                         partEnumerationVolume + newNoOfParts);
367                     } else {
368                         enumeration = enumeration.append(
369                                 partEnumerationCopy + newNoOfCopies + OLEConstants.DOT_TO_SEPARATE_COPIES_PARTS)
370                                 .append(partEnumerationVolume + newNoOfParts
371                                         + OLEConstants.COMMA_TO_SEPARATE_ENUMERATION);
372                     }
373                 }
374             }
375             itemCopies.get(copies).setPartEnumeration(enumeration.toString());
376         }
377     }
378 
379     /**
380      * This method will set copies into list of copies for LineItem.
381      *
382      * @param singleItem
383      * @param workBibDocument
384      * @return
385      */
386     public List<OleCopies> setCopiesToLineItem(OleLineItemReceivingItem singleItem, WorkBibDocument workBibDocument) {
387         List<WorkInstanceDocument> instanceDocuments = workBibDocument.getWorkInstanceDocumentList();
388         List<OleCopies> copies = new ArrayList<OleCopies>();
389         for (WorkInstanceDocument workInstanceDocument : instanceDocuments) {
390             List<WorkItemDocument> itemDocuments = workInstanceDocument.getItemDocumentList();
391             StringBuffer enumeration = new StringBuffer();
392             for (int itemDocs = 0; itemDocs < itemDocuments.size(); itemDocs++) {
393                 if (itemDocs + 1 == itemDocuments.size()) {
394                     enumeration = enumeration.append(itemDocuments.get(itemDocs).getEnumeration());
395                 } else {
396                     enumeration = enumeration.append(itemDocuments.get(itemDocs).getEnumeration() + ",");
397                 }
398 
399             }
400             int startingCopy = 0;
401             if (singleItem.getItemReceivedTotalParts().intValue() != 0 && null != enumeration) {
402                 String enumerationSplit = enumeration.substring(1, 2);
403                 boolean isint = checkIsEnumerationSplitIsIntegerOrNot(enumerationSplit);
404                 if (isint) {
405                     startingCopy = Integer.parseInt(enumerationSplit);
406                 }
407             }
408 
409             /*
410              * if (singleItem.getItemReceivedTotalQuantity().isGreaterThan(new KualiDecimal(1)) ||
411              * singleItem.getItemReceivedTotalParts().isGreaterThan(new KualiDecimal(1))) {
412              */
413             boolean isValid = checkForEnumeration(enumeration);
414             if (isValid) {
415                 OleRequisitionCopies copy = new OleRequisitionCopies();
416                 int noOfCopies = 0;
417                 if (null != singleItem.getItemOrderedQuantity() && null != singleItem.getItemOrderedParts()) {
418                     noOfCopies = workInstanceDocument.getItemDocumentList().size()
419                             / singleItem.getItemOrderedParts().intValue();
420                     copy.setParts(new KualiInteger(singleItem.getItemOrderedParts().intValue()));
421                 } else {
422                     noOfCopies = workInstanceDocument.getItemDocumentList().size()
423                             / singleItem.getItemReceivedTotalParts().intValue();
424                     copy.setParts(new KualiInteger(singleItem.getItemReceivedTotalParts().intValue()));
425                 }
426 
427                 copy.setLocationCopies(workInstanceDocument.getHoldingsDocument().getLocationName());
428                 copy.setItemCopies(new KualiDecimal(noOfCopies));
429                 copy.setPartEnumeration(enumeration.toString());
430                 copy.setStartingCopyNumber(new KualiInteger(startingCopy));
431                 copies.add(copy);
432                 // }
433             }
434         }
435         return copies;
436     }
437 
438     public boolean checkForEnumeration(StringBuffer enumeration) {
439         if (null != enumeration && !(enumeration.equals("")) && !(enumeration.toString().equals("null"))) {
440             return true;
441         } else {
442             return false;
443         }
444     }
445 
446     public boolean checkIsEnumerationSplitIsIntegerOrNot(String enumerationSplit) {
447         try {
448             int startingCopy = Integer.parseInt(enumerationSplit);
449         } catch (NumberFormatException e) {
450             return false;
451         }
452         return true;
453     }
454 
455     /**
456      * This method takes List of UUids as parameter and creates a LinkedHashMap with instance as key and id as value. and calls
457      * Docstore's QueryServiceImpl class getWorkBibRecords method and return workBibDocument for passed instance Id.
458      *
459      * @param instanceIdsList
460      * @return List<WorkBibDocument>
461      */
462 //    private List<WorkBibDocument> getWorkBibDocuments(List<String> instanceIdsList) {
463 //        List<LinkedHashMap<String, String>> instanceIdMapList = new ArrayList<LinkedHashMap<String, String>>();
464 //        for (String instanceId : instanceIdsList) {
465 //            LinkedHashMap<String, String> instanceIdMap = new LinkedHashMap<String, String>();
466 //            instanceIdMap.put(DocType.BIB.getDescription(), instanceId);
467 //            instanceIdMapList.add(instanceIdMap);
468 //        }
469 //
470 //        QueryService queryService = QueryServiceImpl.getInstance();
471 //        List<WorkBibDocument> workBibDocuments = new ArrayList<WorkBibDocument>();
472 //        try {
473 //            workBibDocuments = queryService.getWorkBibRecords(instanceIdMapList);
474 //        } catch (Exception ex) {
475 //            // TODO Auto-generated catch block
476 //            ex.printStackTrace();
477 //        }
478 //        return workBibDocuments;
479 //    }
480 
481     // Added for Jira OLE-1900 Ends
482 
483 
484     /**
485      * This method is used to get the bibedtior creat url from propertie file
486      *
487      * @return Bibeditor creat url string
488      */
489     public String getBibeditorCreateURL() {
490         String bibeditorCreateURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_CREATE_URL_KEY);
491         return bibeditorCreateURL;
492     }
493 
494     public String getBibSearchURL() {
495         String bibSearchURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_SEARCH_URL_KEY);
496         return bibSearchURL;
497     }
498 
499     /**
500      * This method is used to get the bibedtior edit url from propertie file
501      *
502      * @return Bibeditor edit url string
503      */
504     public String getBibeditorEditURL() {
505         String bibeditorEditURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_URL_KEY);
506         return bibeditorEditURL;
507     }
508     /**
509      * This method is used to get the dublinedtior edit url from propertie file
510      *
511      * @return Dublineditor edit url string
512      */
513     public String getDublinEditorEditURL() {
514         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorEditURL();
515     }
516 
517     /**
518      * This method is used to get the bibedtior view url from propertie file
519      *
520      * @return Bibeditor view url string
521      */
522     public String getBibeditorViewURL() {
523         String bibeditorViewURL = getConfigurationService().getPropertyValueAsString(OLEConstants.DOCSTORE_APP_URL_KEY);
524         return bibeditorViewURL;
525     }
526     /**
527      * This method is used to get the dublinedtior view url from propertie file
528      *
529      * @return dublineditor view url string
530      */
531     public String getDublinEditorViewURL() {
532         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorViewURL();
533 
534     }
535     /**
536      * This method is used to get the directory path where the marc xml files need to be created
537      *
538      * @return Directory path string
539      */
540     public String getMarcXMLFileDirLocation() throws Exception {
541         String externaleDirectory = getFileProcessingService().getMarcXMLFileDirLocation();
542         return externaleDirectory;
543     }
544 
545 
546     /**
547      * This method is used to check the status of the document for displaying view and edit buttons in line item
548      *
549      * @return boolean
550      */
551     public boolean getIsSaved() {
552         if (this.getDocumentHeader().getWorkflowDocument().isSaved() || this.getDocumentHeader().getWorkflowDocument().isInitiated()) {
553             return true;
554         }
555         return false;
556     }
557 
558     private void setItemDescription(OleLineItemReceivingItem singleItem) throws Exception {
559         if (singleItem.getOleOrderRecord() != null) {
560             Map<String, ?> bibAssociatedFieldValuesMap = singleItem.getOleOrderRecord().getOleBibRecord().getBibAssociatedFieldsValueMap();
561             List titleList = (List) bibAssociatedFieldValuesMap.get("Title_search");
562             String title = titleList != null && !titleList.isEmpty() ? (String) (titleList).get(0) : null;
563             List authorList = (List) bibAssociatedFieldValuesMap.get("Author_search");
564             String author = authorList != null && !authorList.isEmpty() ? (String) (authorList).get(0) : null;
565             List publisherList = (List) bibAssociatedFieldValuesMap.get("Publisher_search");
566             String publisher = publisherList != null && !publisherList.isEmpty() ? (String) (publisherList).get(0) : null;
567             List isbnList = (List) bibAssociatedFieldValuesMap.get("020a");
568             String isbn = isbnList != null && !isbnList.isEmpty() ? (String) (isbnList).get(0) : null;
569 
570             singleItem.setBibUUID(singleItem.getOleOrderRecord().getOleBibRecord().getBibUUID());
571             singleItem.setItemDescription(title + "," + author + "," + publisher + "," + isbn);
572         }
573     }
574 
575     public boolean getIsATypeOfRCVGDoc() {
576         return true;
577     }
578 
579     public boolean getIsATypeOfCORRDoc() {
580         return false;
581     }
582 
583 }