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.uif.control.UifKeyValuesFinderBase;
27 import org.kuali.rice.krad.uif.view.ViewModel;
28 import org.kuali.rice.kew.actionlist.ActionListForm;
29
30 public class UserWorkgroupsKeyValues extends UifKeyValuesFinderBase {
31
32 private boolean blankOption;
33
34
35 @Override
36 public List<KeyValue> getKeyValues(ViewModel model) {
37 ActionListForm actionListForm = (ActionListForm)model;
38 List<String> userWorkgroups =
39 KimApiServiceLocator.getGroupService().getGroupIdsByPrincipalId(actionListForm.getUser());
40
41
42 List<String> userGroupsToSort = new ArrayList<String>(userWorkgroups);
43
44 List<KeyValue> sortedUserWorkgroups = new ArrayList<KeyValue>();
45 KeyValue keyValue = null;
46 keyValue = new ConcreteKeyValue(KewApiConstants.NO_FILTERING, KewApiConstants.NO_FILTERING);
47 sortedUserWorkgroups.add(keyValue);
48
49 if (userGroupsToSort != null && userGroupsToSort.size() > 0) {
50 Collections.sort(userGroupsToSort);
51 Group group;
52
53 for (String groupId : userGroupsToSort)
54 {
55 group = KimApiServiceLocator.getGroupService().getGroup(groupId);
56 keyValue = new ConcreteKeyValue(groupId, group.getName());
57 sortedUserWorkgroups.add(keyValue);
58 }
59 }
60
61 return sortedUserWorkgroups;
62 }
63
64
65
66
67 public boolean isBlankOption() {
68 return this.blankOption;
69 }
70
71
72
73
74 public void setBlankOption(boolean blankOption) {
75 this.blankOption = blankOption;
76 }
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 }