1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.util;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.kew.api.KewApiConstants;
20 import org.kuali.rice.krad.bo.AdHocRouteRecipient;
21 import org.kuali.rice.krad.document.Document;
22
23 import java.util.List;
24 import java.util.ListIterator;
25
26 public class RouteToCompletionUtil {
27
28
29
30
31
32 public static boolean checkIfAtleastOneAdHocCompleteRequestExist(Document document) {
33 boolean foundAtleastOneCompleteReq = false;
34
35 foundAtleastOneCompleteReq = loopAndCheckValue(document.getAdHocRouteWorkgroups()) || loopAndCheckValue(
36 document.getAdHocRoutePersons());
37
38 return foundAtleastOneCompleteReq;
39 }
40
41
42
43
44
45
46 private static boolean loopAndCheckValue(List adhoc) {
47 if (adhoc == null) {
48 return false;
49 }
50
51 ListIterator<AdHocRouteRecipient> groupIter = adhoc.listIterator();
52 String valueToCheck = null;
53 AdHocRouteRecipient recipient = null;
54
55 boolean foundAtleastOneCompleteReq = false;
56 while (groupIter.hasNext()) {
57 recipient = groupIter.next();
58 valueToCheck = recipient.getActionRequested();
59 if (StringUtils.isNotEmpty(valueToCheck)) {
60 if (KewApiConstants.ACTION_REQUEST_COMPLETE_REQ.equals(valueToCheck)) {
61 foundAtleastOneCompleteReq = true;
62 break;
63 }
64 }
65 }
66
67 return foundAtleastOneCompleteReq;
68 }
69 }