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.substring(0, itemDescription.lastIndexOf(","));
319                             StringEscapeUtils stringEscapeUtils = new StringEscapeUtils();
320                             itemDescription = stringEscapeUtils.unescapeXml(itemDescription);
321                             singleItem.setItemDescription(itemDescription);
322                         }
323                     }
324                     Map cpySection = new HashMap();
325                     cpySection.put("itemIdentifier", singleItem.getPurchaseOrderIdentifier());
326 
327                     List<OlePurchaseOrderItem> olePurchaseOrderItems = (List<OlePurchaseOrderItem>) getBusinessObjectService().findMatching(OlePurchaseOrderItem.class, cpySection);
328                     if (olePurchaseOrderItems.size() > 0) {
329                         for (OlePurchaseOrderItem item : olePurchaseOrderItems) {
330                             singleItem.setCopyList(item.getCopyList());
331                         }
332                     }
333                 }
334             }
335             LOG.debug("Leaving processAfterRetrieve of OleLineItemReceivingDocument");
336         } catch (Exception e) {
337             LOG.error("Exception during processAfterRetrieve() in OleLineItemReceivingDocument"+e);
338             throw new RuntimeException(e);
339         }
340     }
341 
342     // Added for Jira OLE-1900 Starts
343 
344 
345     public void setEnumerationToCopies(OleLineItemReceivingItem singleItem) {
346         String partEnumerationCopy = getConfigurationService().getPropertyValueAsString(
347                 OLEConstants.PART_ENUMERATION_COPY);
348         String partEnumerationVolume = getConfigurationService().getPropertyValueAsString(
349                 OLEConstants.PART_ENUMERATION_VOLUME);
350         List<OleCopies> itemCopies = singleItem.getCopies();
351         List<OleCopies> copiesList = new ArrayList<OleCopies>();
352         for (int copies = 0; copies < itemCopies.size(); copies++) {
353             itemCopies.get(copies).setParts(new KualiInteger(singleItem.getItemReceivedTotalParts().intValue()));
354             int startingCopyNumber = itemCopies.get(copies).getStartingCopyNumber().intValue();
355             StringBuffer enumeration = new StringBuffer();
356             for (int noOfCopies = 0; noOfCopies < singleItem.getItemCopies().intValue(); noOfCopies++) {
357                 for (int noOfParts = 0; noOfParts < singleItem.getItemReceivedTotalParts().intValue(); noOfParts++) {
358                     int newNoOfCopies = startingCopyNumber + noOfCopies;
359                     int newNoOfParts = noOfParts + 1;
360                     if (noOfCopies + 1 == singleItem.getItemCopies().intValue()
361                             && newNoOfParts == singleItem.getItemReceivedTotalParts().intValue()) {
362                         enumeration = enumeration.append(
363                                 partEnumerationCopy + newNoOfCopies + OLEConstants.DOT_TO_SEPARATE_COPIES_PARTS)
364                                 .append(
365                                         partEnumerationVolume + newNoOfParts);
366                     } else {
367                         enumeration = enumeration.append(
368                                 partEnumerationCopy + newNoOfCopies + OLEConstants.DOT_TO_SEPARATE_COPIES_PARTS)
369                                 .append(partEnumerationVolume + newNoOfParts
370                                         + OLEConstants.COMMA_TO_SEPARATE_ENUMERATION);
371                     }
372                 }
373             }
374             itemCopies.get(copies).setPartEnumeration(enumeration.toString());
375         }
376     }
377 
378     /**
379      * This method will set copies into list of copies for LineItem.
380      *
381      * @param singleItem
382      * @param workBibDocument
383      * @return
384      */
385     public List<OleCopies> setCopiesToLineItem(OleLineItemReceivingItem singleItem, WorkBibDocument workBibDocument) {
386         List<WorkInstanceDocument> instanceDocuments = workBibDocument.getWorkInstanceDocumentList();
387         List<OleCopies> copies = new ArrayList<OleCopies>();
388         for (WorkInstanceDocument workInstanceDocument : instanceDocuments) {
389             List<WorkItemDocument> itemDocuments = workInstanceDocument.getItemDocumentList();
390             StringBuffer enumeration = new StringBuffer();
391             for (int itemDocs = 0; itemDocs < itemDocuments.size(); itemDocs++) {
392                 if (itemDocs + 1 == itemDocuments.size()) {
393                     enumeration = enumeration.append(itemDocuments.get(itemDocs).getEnumeration());
394                 } else {
395                     enumeration = enumeration.append(itemDocuments.get(itemDocs).getEnumeration() + ",");
396                 }
397 
398             }
399             int startingCopy = 0;
400             if (singleItem.getItemReceivedTotalParts().intValue() != 0 && null != enumeration) {
401                 String enumerationSplit = enumeration.substring(1, 2);
402                 boolean isint = checkIsEnumerationSplitIsIntegerOrNot(enumerationSplit);
403                 if (isint) {
404                     startingCopy = Integer.parseInt(enumerationSplit);
405                 }
406             }
407 
408             /*
409              * if (singleItem.getItemReceivedTotalQuantity().isGreaterThan(new KualiDecimal(1)) ||
410              * singleItem.getItemReceivedTotalParts().isGreaterThan(new KualiDecimal(1))) {
411              */
412             boolean isValid = checkForEnumeration(enumeration);
413             if (isValid) {
414                 OleRequisitionCopies copy = new OleRequisitionCopies();
415                 int noOfCopies = 0;
416                 if (null != singleItem.getItemOrderedQuantity() && null != singleItem.getItemOrderedParts()) {
417                     noOfCopies = workInstanceDocument.getItemDocumentList().size()
418                             / singleItem.getItemOrderedParts().intValue();
419                     copy.setParts(new KualiInteger(singleItem.getItemOrderedParts().intValue()));
420                 } else {
421                     noOfCopies = workInstanceDocument.getItemDocumentList().size()
422                             / singleItem.getItemReceivedTotalParts().intValue();
423                     copy.setParts(new KualiInteger(singleItem.getItemReceivedTotalParts().intValue()));
424                 }
425 
426                 copy.setLocationCopies(workInstanceDocument.getHoldingsDocument().getLocationName());
427                 copy.setItemCopies(new KualiDecimal(noOfCopies));
428                 copy.setPartEnumeration(enumeration.toString());
429                 copy.setStartingCopyNumber(new KualiInteger(startingCopy));
430                 copies.add(copy);
431                 // }
432             }
433         }
434         return copies;
435     }
436 
437     public boolean checkForEnumeration(StringBuffer enumeration) {
438         if (null != enumeration && !(enumeration.equals("")) && !(enumeration.toString().equals("null"))) {
439             return true;
440         } else {
441             return false;
442         }
443     }
444 
445     public boolean checkIsEnumerationSplitIsIntegerOrNot(String enumerationSplit) {
446         try {
447             int startingCopy = Integer.parseInt(enumerationSplit);
448         } catch (NumberFormatException e) {
449             return false;
450         }
451         return true;
452     }
453 
454     /**
455      * This method takes List of UUids as parameter and creates a LinkedHashMap with instance as key and id as value. and calls
456      * Docstore's QueryServiceImpl class getWorkBibRecords method and return workBibDocument for passed instance Id.
457      *
458      * @param instanceIdsList
459      * @return List<WorkBibDocument>
460      */
461 //    private List<WorkBibDocument> getWorkBibDocuments(List<String> instanceIdsList) {
462 //        List<LinkedHashMap<String, String>> instanceIdMapList = new ArrayList<LinkedHashMap<String, String>>();
463 //        for (String instanceId : instanceIdsList) {
464 //            LinkedHashMap<String, String> instanceIdMap = new LinkedHashMap<String, String>();
465 //            instanceIdMap.put(DocType.BIB.getDescription(), instanceId);
466 //            instanceIdMapList.add(instanceIdMap);
467 //        }
468 //
469 //        QueryService queryService = QueryServiceImpl.getInstance();
470 //        List<WorkBibDocument> workBibDocuments = new ArrayList<WorkBibDocument>();
471 //        try {
472 //            workBibDocuments = queryService.getWorkBibRecords(instanceIdMapList);
473 //        } catch (Exception ex) {
474 //            // TODO Auto-generated catch block
475 //            ex.printStackTrace();
476 //        }
477 //        return workBibDocuments;
478 //    }
479 
480     // Added for Jira OLE-1900 Ends
481 
482 
483     /**
484      * This method is used to get the bibedtior creat url from propertie file
485      *
486      * @return Bibeditor creat url string
487      */
488     public String getBibeditorCreateURL() {
489         String bibeditorCreateURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_CREATE_URL_KEY);
490         return bibeditorCreateURL;
491     }
492 
493     public String getBibSearchURL() {
494         String bibSearchURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_SEARCH_URL_KEY);
495         return bibSearchURL;
496     }
497 
498     /**
499      * This method is used to get the bibedtior edit url from propertie file
500      *
501      * @return Bibeditor edit url string
502      */
503     public String getBibeditorEditURL() {
504         String bibeditorEditURL = getConfigurationService().getPropertyValueAsString(OLEConstants.BIBEDITOR_URL_KEY);
505         return bibeditorEditURL;
506     }
507     /**
508      * This method is used to get the dublinedtior edit url from propertie file
509      *
510      * @return Dublineditor edit url string
511      */
512     public String getDublinEditorEditURL() {
513         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorEditURL();
514     }
515 
516     /**
517      * This method is used to get the bibedtior view url from propertie file
518      *
519      * @return Bibeditor view url string
520      */
521     public String getBibeditorViewURL() {
522         String bibeditorViewURL = getConfigurationService().getPropertyValueAsString(OLEConstants.DOCSTORE_APP_URL_KEY);
523         return bibeditorViewURL;
524     }
525     /**
526      * This method is used to get the dublinedtior view url from propertie file
527      *
528      * @return dublineditor view url string
529      */
530     public String getDublinEditorViewURL() {
531         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorViewURL();
532 
533     }
534     /**
535      * This method is used to get the directory path where the marc xml files need to be created
536      *
537      * @return Directory path string
538      */
539     public String getMarcXMLFileDirLocation() throws Exception {
540         String externaleDirectory = getFileProcessingService().getMarcXMLFileDirLocation();
541         return externaleDirectory;
542     }
543 
544 
545     /**
546      * This method is used to check the status of the document for displaying view and edit buttons in line item
547      *
548      * @return boolean
549      */
550     public boolean getIsSaved() {
551         if (this.getDocumentHeader().getWorkflowDocument().isSaved() || this.getDocumentHeader().getWorkflowDocument().isInitiated()) {
552             return true;
553         }
554         return false;
555     }
556 
557     private void setItemDescription(OleLineItemReceivingItem singleItem) throws Exception {
558         if (singleItem.getOleOrderRecord() != null) {
559             Map<String, ?> bibAssociatedFieldValuesMap = singleItem.getOleOrderRecord().getOleBibRecord().getBibAssociatedFieldsValueMap();
560             List titleList = (List) bibAssociatedFieldValuesMap.get("Title_search");
561             String title = titleList != null && !titleList.isEmpty() ? (String) (titleList).get(0) : null;
562             List authorList = (List) bibAssociatedFieldValuesMap.get("Author_search");
563             String author = authorList != null && !authorList.isEmpty() ? (String) (authorList).get(0) : null;
564             List publisherList = (List) bibAssociatedFieldValuesMap.get("Publisher_search");
565             String publisher = publisherList != null && !publisherList.isEmpty() ? (String) (publisherList).get(0) : null;
566             List isbnList = (List) bibAssociatedFieldValuesMap.get("020a");
567             String isbn = isbnList != null && !isbnList.isEmpty() ? (String) (isbnList).get(0) : null;
568 
569             singleItem.setBibUUID(singleItem.getOleOrderRecord().getOleBibRecord().getBibUUID());
570             singleItem.setItemDescription(title + "," + author + "," + publisher + "," + isbn);
571         }
572     }
573 
574     public boolean getIsATypeOfRCVGDoc() {
575         return true;
576     }
577 
578     public boolean getIsATypeOfCORRDoc() {
579         return false;
580     }
581 
582 }