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