1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.cg.businessobject.lookup;
17
18 import java.util.ArrayList;
19 import java.util.Collections;
20 import java.util.List;
21 import java.util.Map;
22
23 import org.apache.commons.lang.StringUtils;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.rice.kim.api.identity.Person;
26 import org.kuali.rice.kim.api.identity.PersonService;
27 import org.kuali.rice.kns.lookup.HtmlData;
28 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
29 import org.kuali.rice.krad.bo.BusinessObject;
30 import org.kuali.rice.krad.util.KRADConstants;
31
32
33
34
35 public class AwardLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
36
37 private static final String LOOKUP_USER_ID_FIELD = "lookupPerson.principalName";
38 private static final String LOOKUP_UNIVERSAL_USER_ID_FIELD = "awardProjectDirectors.principalId";
39
40 private PersonService personService;
41
42
43
44
45 @Override
46 protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded) {
47
48 if (!StringUtils.isBlank(fieldValues.get(LOOKUP_USER_ID_FIELD))) {
49 Person person = getPersonService().getPersonByPrincipalName(fieldValues.get(LOOKUP_USER_ID_FIELD));
50
51
52 if (person == null) {
53 return Collections.EMPTY_LIST;
54 }
55
56
57 fieldValues.put(LOOKUP_UNIVERSAL_USER_ID_FIELD, person.getPrincipalId());
58 fieldValues.remove(LOOKUP_USER_ID_FIELD);
59 }
60
61 return super.getSearchResultsHelper(fieldValues, unbounded);
62 }
63
64
65
66
67 @Override
68 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
69 List<HtmlData> anchorHtmlDataList = new ArrayList<HtmlData>();
70 anchorHtmlDataList.add(getUrlData(businessObject, KRADConstants.MAINTENANCE_EDIT_METHOD_TO_CALL, pkNames));
71 return anchorHtmlDataList;
72 }
73
74
75
76
77 protected PersonService getPersonService() {
78 if(personService==null)
79 personService = SpringContext.getBean(PersonService.class);
80 return personService;
81 }
82
83 }