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.Collections;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.ole.sys.OLEConstants;
24 import org.kuali.ole.vnd.VendorConstants;
25 import org.kuali.ole.vnd.businessobject.VendorContact;
26 import org.kuali.ole.vnd.businessobject.VendorContactPhoneNumber;
27 import org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl;
28 import org.kuali.rice.krad.bo.PersistableBusinessObject;
29 import org.kuali.rice.krad.util.BeanPropertyComparator;
30
31 public class VendorContactLookupableHelperServiceImpl extends AbstractLookupableHelperServiceImpl {
32
33
34
35
36
37
38
39 @Override
40 public List<PersistableBusinessObject> getSearchResults(Map<String, String> fieldValues) {
41 boolean unbounded = false;
42 super.setBackLocation((String) fieldValues.get(OLEConstants.BACK_LOCATION));
43 super.setDocFormKey((String) fieldValues.get(OLEConstants.DOC_FORM_KEY));
44
45 List<PersistableBusinessObject> searchResults = (List) getLookupService().findCollectionBySearchHelper(getBusinessObjectClass(), fieldValues, unbounded);
46
47
48 for (PersistableBusinessObject object : searchResults) {
49 VendorContact vendorContact = (VendorContact) object;
50
51 for (VendorContactPhoneNumber phoneNumber : vendorContact.getVendorContactPhoneNumbers()) {
52 String extension = phoneNumber.getVendorPhoneExtensionNumber();
53 if (phoneNumber.getVendorPhoneType().getVendorPhoneTypeCode().equals(VendorConstants.PhoneTypes.PHONE) && StringUtils.isEmpty(vendorContact.getPhoneNumberForLookup())) {
54 vendorContact.setPhoneNumberForLookup(phoneNumber.getVendorPhoneNumber() + ((StringUtils.isNotEmpty(extension)) ? " x " + extension : null));
55 }
56 else if (phoneNumber.getVendorPhoneType().getVendorPhoneTypeCode().equals(VendorConstants.PhoneTypes.FAX) && StringUtils.isBlank(vendorContact.getFaxForLookup())) {
57 vendorContact.setFaxForLookup(phoneNumber.getVendorPhoneNumber() + ((StringUtils.isNotEmpty(extension)) ? " x " + extension : OLEConstants.EMPTY_STRING));
58 }
59 else if (phoneNumber.getVendorPhoneType().getVendorPhoneTypeCode().equals(VendorConstants.PhoneTypes.TOLL_FREE) && StringUtils.isBlank(vendorContact.getTollFreeForLookup())) {
60 vendorContact.setTollFreeForLookup(phoneNumber.getVendorPhoneNumber() + ((StringUtils.isNotEmpty(extension)) ? " x " + extension : OLEConstants.EMPTY_STRING));
61 }
62 }
63 }
64
65
66 List<String> defaultSortColumns = getDefaultSortColumns();
67 if (defaultSortColumns.size() > 0) {
68 Collections.sort(searchResults, new BeanPropertyComparator(getDefaultSortColumns(), true));
69 }
70
71 return searchResults;
72 }
73
74 }