View Javadoc
1   /*
2    * Copyright 2012 The Kuali Foundation.
3    *
4    * Licensed under the Educational Community License, Version 1.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/ecl1.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.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;
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              defaultAddress = vendorService.getVendorDefaultAddress(vendor.getVendorAddresses(), vendor.getVendorHeader().getVendorType().getAddressType().getVendorAddressTypeCode(), "");
54              if (defaultAddress != null ) {
55                  vendor.setDefaultAddressLine1(defaultAddress.getVendorLine1Address());
56                  vendor.setDefaultAddressCity(defaultAddress.getVendorCityName());
57                  vendor.setDefaultAddressStateCode(defaultAddress.getVendorStateCode());
58                  vendor.setDefaultAddressCountryCode(defaultAddress.getVendorCountryCode());
59              }
60              filteredVendorList.add(vendor);
61          }
62          return filteredVendorList;
63      }
64  
65      /**
66       * Gets the vendorExcludeService attribute.
67       * @return Returns the vendorExcludeService.
68       */
69      public VendorExcludeService getVendorExcludeService() {
70          return vendorExcludeService;
71      }
72  
73      /**
74       * Sets the vendorExcludeService attribute value.
75       * @param vendorExcludeService The vendorExcludeService to set.
76       */
77      public void setVendorExcludeService(VendorExcludeService vendorExcludeService) {
78          this.vendorExcludeService = vendorExcludeService;
79      }
80  
81      /**
82       * Gets the vendorService attribute.
83       * @return Returns the vendorService.
84       */
85      public VendorService getVendorService() {
86          return vendorService;
87      }
88  
89      /**
90       * Sets the vendorService attribute value.
91       * @param vendorService The vendorService to set.
92       */
93      public void setVendorService(VendorService vendorService) {
94          this.vendorService = vendorService;
95      }
96  }