1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.lookup.valuefinder;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.util.ConcreteKeyValue;
20 import org.kuali.rice.core.api.util.KeyValue;
21 import org.kuali.rice.kew.service.KEWServiceLocator;
22 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
23 import org.kuali.rice.krad.util.GlobalVariables;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28
29
30
31
32
33
34 public class SavedSearchValuesFinder extends KeyValuesBase {
35
36
37
38
39 @Override
40 public List<KeyValue> getKeyValues() {
41 List<KeyValue> savedSearchValues = new ArrayList<KeyValue>();
42 savedSearchValues.add(new ConcreteKeyValue("", "Searches"));
43 savedSearchValues.add(new ConcreteKeyValue("*ignore*", "-----"));
44 savedSearchValues.add(new ConcreteKeyValue("*ignore*", "-Named Searches"));
45 List<KeyValue> namedSearches = KEWServiceLocator.getDocumentSearchService().getNamedSearches(GlobalVariables.getUserSession().getPrincipalId());
46 for (KeyValue keyValue : namedSearches) {
47 String label = StringUtils.abbreviate(keyValue.getValue(), 75);
48 KeyValue keyLabel = new ConcreteKeyValue(keyValue.getKey(),label);
49 savedSearchValues.add(keyLabel);
50 }
51 savedSearchValues.add(new ConcreteKeyValue("*ignore*", "-----"));
52 savedSearchValues.add(new ConcreteKeyValue("*ignore*", "-Recent Searches"));
53 List<KeyValue> mostRecentSearches = KEWServiceLocator.getDocumentSearchService().getMostRecentSearches(GlobalVariables.getUserSession().getPrincipalId());
54 for (KeyValue keyValue : mostRecentSearches) {
55 String label = StringUtils.abbreviate(keyValue.getValue(), 75);
56 KeyValue keyLabel = new ConcreteKeyValue(keyValue.getKey(),label);
57 savedSearchValues.add(keyLabel);
58 }
59 return savedSearchValues;
60 }
61
62 }