1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.actionlist;
17
18 import java.util.ArrayList;
19 import java.util.Collections;
20 import java.util.List;
21 import org.kuali.rice.core.api.util.ConcreteKeyValue;
22 import org.kuali.rice.core.api.util.KeyValue;
23 import org.kuali.rice.kew.api.KewApiConstants;
24 import org.kuali.rice.kim.api.group.Group;
25 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
26 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
27 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
28 import org.kuali.rice.krad.uif.view.ViewModel;
29 import org.kuali.rice.kew.actionlist.ActionListForm;
30
31 public class UserWorkgroupsKeyValues extends UifKeyValuesFinderBase {
32
33 private boolean blankOption;
34
35
36 @Override
37 public List<KeyValue> getKeyValues(ViewModel model) {
38 ActionListForm actionListForm = (ActionListForm)model;
39 List<String> userWorkgroups =
40 KimApiServiceLocator.getGroupService().getGroupIdsByPrincipalId(actionListForm.getUser());
41
42
43 List<String> userGroupsToSort = new ArrayList<String>(userWorkgroups);
44
45 List<KeyValue> sortedUserWorkgroups = new ArrayList<KeyValue>();
46 KeyValue keyValue = null;
47 keyValue = new ConcreteKeyValue(KewApiConstants.NO_FILTERING, KewApiConstants.NO_FILTERING);
48 sortedUserWorkgroups.add(keyValue);
49
50 if (userGroupsToSort != null && userGroupsToSort.size() > 0) {
51 Collections.sort(userGroupsToSort);
52 Group group;
53
54 for (String groupId : userGroupsToSort)
55 {
56 group = KimApiServiceLocator.getGroupService().getGroup(groupId);
57 keyValue = new ConcreteKeyValue(groupId, group.getName());
58 sortedUserWorkgroups.add(keyValue);
59 }
60 }
61
62 return sortedUserWorkgroups;
63 }
64
65
66
67
68 public boolean isBlankOption() {
69 return this.blankOption;
70 }
71
72
73
74
75 public void setBlankOption(boolean blankOption) {
76 this.blankOption = blankOption;
77 }
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 }