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.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.context.SpringContext;
24 import org.kuali.rice.kim.api.identity.Person;
25 import org.kuali.rice.kim.api.identity.PersonService;
26 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
27 import org.kuali.rice.krad.bo.BusinessObject;
28
29
30
31
32 public class ProposalLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
33
34 private static final String LOOKUP_USER_ID_FIELD = "lookupPerson.principalName";
35 private static final String LOOKUP_UNIVERSAL_USER_ID_FIELD = "proposalProjectDirectors.principalId";
36
37 private PersonService personService;
38
39
40
41
42 @Override
43 protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded) {
44
45 if (!StringUtils.isBlank(fieldValues.get(LOOKUP_USER_ID_FIELD))) {
46 Person person = getPersonService().getPersonByPrincipalName(fieldValues.get(LOOKUP_USER_ID_FIELD));
47
48
49 if (person == null) {
50 return Collections.EMPTY_LIST;
51 }
52
53
54 fieldValues.put(LOOKUP_UNIVERSAL_USER_ID_FIELD, person.getPrincipalId());
55 fieldValues.remove(LOOKUP_USER_ID_FIELD);
56 }
57
58 return super.getSearchResultsHelper(fieldValues, unbounded);
59 }
60
61
62
63
64 protected PersonService getPersonService() {
65 if(personService==null)
66 personService = SpringContext.getBean(PersonService.class);
67 return personService;
68 }
69
70 }