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