1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.vnd.businessobject.lookup;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.apache.cxf.common.util.StringUtils;
23 import org.kuali.ole.vnd.batch.service.VendorExcludeService;
24 import org.kuali.ole.vnd.businessobject.VendorAddress;
25 import org.kuali.ole.vnd.businessobject.VendorDetail;
26 import org.kuali.ole.vnd.document.service.VendorService;
27 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
28 import org.kuali.rice.krad.bo.BusinessObject;
29
30 public class DebarredVendorUnmatchedLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
31 VendorExcludeService vendorExcludeService;
32 VendorService vendorService;
33
34 @Override
35 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
36 return getDebarredVendorUnmatchedSearchResults(fieldValues);
37 }
38
39 @Override
40 public List<? extends BusinessObject> getSearchResultsUnbounded(Map<String, String> fieldValues) {
41 return getDebarredVendorUnmatchedSearchResults(fieldValues);
42 }
43
44 protected List<? extends BusinessObject> getDebarredVendorUnmatchedSearchResults(Map<String, String> fieldValues) {
45 List<VendorDetail> vendorResultList = vendorExcludeService.getDebarredVendorsUnmatched();
46 List<VendorDetail> filteredVendorList = new ArrayList<VendorDetail> ();
47 VendorAddress defaultAddress = null;
48 String vendorType = fieldValues.get("vendorTypeCode");
49 for (VendorDetail vendor : vendorResultList) {
50 if (!StringUtils.isEmpty(vendorType) && !vendor.getVendorHeader().getVendorTypeCode().equals(vendorType)) {
51 continue;
52 }
53 if(vendor.getVendorAddresses()!=null && vendor.getVendorHeader()!=null && vendor.getVendorHeader().getVendorType()!=null && vendor.getVendorHeader().getVendorType().getAddressType()!=null && vendor.getVendorHeader().getVendorType().getAddressType().getVendorAddressTypeCode()!=null){
54 defaultAddress = vendorService.getVendorDefaultAddress(vendor.getVendorAddresses(), vendor.getVendorHeader().getVendorType().getAddressType().getVendorAddressTypeCode(), "");
55 }
56 if (defaultAddress != null ) {
57 vendor.setDefaultAddressLine1(defaultAddress.getVendorLine1Address());
58 vendor.setDefaultAddressCity(defaultAddress.getVendorCityName());
59 vendor.setDefaultAddressStateCode(defaultAddress.getVendorStateCode());
60 vendor.setDefaultAddressCountryCode(defaultAddress.getVendorCountryCode());
61 }
62 filteredVendorList.add(vendor);
63 }
64 return filteredVendorList;
65 }
66
67
68
69
70
71 public VendorExcludeService getVendorExcludeService() {
72 return vendorExcludeService;
73 }
74
75
76
77
78
79 public void setVendorExcludeService(VendorExcludeService vendorExcludeService) {
80 this.vendorExcludeService = vendorExcludeService;
81 }
82
83
84
85
86
87 public VendorService getVendorService() {
88 return vendorService;
89 }
90
91
92
93
94
95 public void setVendorService(VendorService vendorService) {
96 this.vendorService = vendorService;
97 }
98 }