1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.ole.select.lookup;
18
19 import org.apache.commons.lang3.StringUtils;
20 import org.kuali.ole.select.OleSelectConstant;
21 import org.kuali.ole.select.bo.OLEInvoiceSearchDocument;
22 import org.kuali.ole.select.businessobject.OleInvoiceItem;
23 import org.kuali.ole.select.document.OleInvoiceDocument;
24 import org.kuali.ole.select.service.OLEInvoiceSearchService;
25 import org.kuali.rice.krad.lookup.LookupableImpl;
26 import org.kuali.rice.krad.service.KRADServiceLocator;
27 import org.kuali.rice.krad.web.form.LookupForm;
28
29 import java.text.DateFormat;
30 import java.text.ParseException;
31 import java.text.SimpleDateFormat;
32 import java.util.*;
33
34 public class OLEInvoiceSearchDocumentLookupableImpl extends LookupableImpl {
35 @Override
36 public Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded) {
37 List<OLEInvoiceSearchDocument> oleInvoiceSearchDocuments=new ArrayList<OLEInvoiceSearchDocument>();
38 List<OLEInvoiceSearchDocument> oleInvoiceDocuments=new ArrayList<OLEInvoiceSearchDocument>();
39 List<OLEInvoiceSearchDocument> oleInvoiceDocumentsForTitle=new ArrayList<OLEInvoiceSearchDocument>();
40 Map<String, String> searchDocumentMap = new HashMap<String, String>();
41 Map<String, String> fieldConversion=form.getFieldConversions();
42 boolean isAddTitleScreen=false;
43 if (fieldConversion.containsKey("invoiceNbr")) {
44 isAddTitleScreen=true;
45 for (Map.Entry<String, String> mapEntry : searchCriteria.entrySet()) {
46 if (StringUtils.isNotEmpty(mapEntry.getValue())) {
47 if (mapEntry.getKey().equalsIgnoreCase("invoiceNbr")) {
48 searchDocumentMap.put(OleSelectConstant.InvoiceSearch.INV_NUMBER, mapEntry.getValue());
49 } else {
50 searchDocumentMap.put(mapEntry.getKey(), mapEntry.getValue());
51 }
52 }
53 }
54 } else {
55 for (Map.Entry<String, String> mapEntry : searchCriteria.entrySet()) {
56 if (StringUtils.isNotEmpty(mapEntry.getValue())) {
57 searchDocumentMap.put(mapEntry.getKey(), mapEntry.getValue());
58 }
59 }
60 }
61 OLEInvoiceSearchService oleInvoiceSearchService=new OLEInvoiceSearchService();
62 try {
63 oleInvoiceDocuments= oleInvoiceSearchService.searchResults(searchDocumentMap);
64 } catch (Exception e) {
65 e.printStackTrace();
66 }
67 if(isAddTitleScreen){
68 for(OLEInvoiceSearchDocument oleInvoiceSearchDocument:oleInvoiceDocuments){
69 if(oleInvoiceSearchDocument.getDocumentStatus().equalsIgnoreCase("Initiated")){
70 oleInvoiceDocumentsForTitle.add(oleInvoiceSearchDocument);
71 }
72 }
73 return oleInvoiceDocumentsForTitle;
74 }
75 return oleInvoiceDocuments;
76 }
77 }