1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.impl.actionlist; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; |
20 | |
import org.kuali.rice.kew.api.action.ActionItem; |
21 | |
import org.kuali.rice.kew.api.actionlist.ActionListService; |
22 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
23 | |
|
24 | |
import java.util.ArrayList; |
25 | |
import java.util.Collection; |
26 | |
import java.util.List; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public class ActionListServiceNewImpl implements ActionListService { |
35 | |
|
36 | |
@Override |
37 | |
public Integer getUserActionItemCount(String principalId) { |
38 | 0 | incomingParamCheck(principalId, "principalId"); |
39 | 0 | return Integer.valueOf(KEWServiceLocator.getActionListService().getCount(principalId)); |
40 | |
} |
41 | |
|
42 | |
@Override |
43 | |
public List<ActionItem> getActionItemsForPrincipal(String principalId) { |
44 | 0 | incomingParamCheck(principalId, "principalId"); |
45 | 0 | Collection<org.kuali.rice.kew.actionitem.ActionItem> actionItems |
46 | |
= KEWServiceLocator.getActionListService().getActionList(principalId, null); |
47 | 0 | List<ActionItem> actionItemVOs = new ArrayList<ActionItem>(actionItems.size()); |
48 | 0 | for (org.kuali.rice.kew.actionitem.ActionItem actionItem : actionItems) { |
49 | 0 | actionItemVOs.add(org.kuali.rice.kew.actionitem.ActionItem.to(actionItem)); |
50 | |
} |
51 | 0 | return actionItemVOs; |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public List<ActionItem> getAllActionItems(String documentId) { |
56 | 0 | incomingParamCheck(documentId, "documentId"); |
57 | 0 | Collection<org.kuali.rice.kew.actionitem.ActionItem> actionItems |
58 | |
= KEWServiceLocator.getActionListService().getActionListForSingleDocument(documentId); |
59 | 0 | List<ActionItem> actionItemVOs = new ArrayList<ActionItem>(actionItems.size()); |
60 | 0 | for (org.kuali.rice.kew.actionitem.ActionItem actionItem : actionItems) { |
61 | 0 | actionItemVOs.add(org.kuali.rice.kew.actionitem.ActionItem.to(actionItem)); |
62 | |
} |
63 | 0 | return actionItemVOs; |
64 | |
} |
65 | |
|
66 | |
@Override |
67 | |
public List<ActionItem> getActionItems(String documentId, List<String> actionRequestedCodes) { |
68 | 0 | incomingParamCheck(documentId, "documentId"); |
69 | 0 | List<ActionItem> actionItems = getAllActionItems(documentId); |
70 | 0 | List<ActionItem> matchingActionitems = new ArrayList<ActionItem>(); |
71 | 0 | for (ActionItem actionItemVO : actionItems) { |
72 | 0 | if (actionRequestedCodes.contains(actionItemVO.getActionRequestCd())) { |
73 | 0 | matchingActionitems.add(actionItemVO); |
74 | |
} |
75 | |
} |
76 | 0 | return matchingActionitems; |
77 | |
} |
78 | |
|
79 | |
private void incomingParamCheck(Object object, String name) { |
80 | 0 | if (object == null) { |
81 | 0 | throw new RiceIllegalArgumentException(name + " was null"); |
82 | 0 | } else if (object instanceof String |
83 | |
&& StringUtils.isBlank((String) object)) { |
84 | 0 | throw new RiceIllegalArgumentException(name + " was blank"); |
85 | |
} |
86 | 0 | } |
87 | |
} |