1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.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
27 public class RouteToCompletionUtil {
28
29
30
31
32 public static boolean checkIfAtleastOneAdHocCompleteRequestExist(Document document) {
33 boolean foundAtleastOneCompleteReq = false;
34
35 foundAtleastOneCompleteReq = loopAndCheckValue(document.getAdHocRouteWorkgroups()) || loopAndCheckValue(document.getAdHocRoutePersons());
36 return foundAtleastOneCompleteReq;
37 }
38
39
40
41
42
43 public static boolean loopAndCheckValue(List adhoc) {
44 if (adhoc == null) {
45 return false;
46 }
47 ListIterator<AdHocRouteRecipient> groupIter = adhoc.listIterator();
48 String valueToCheck = null;
49 AdHocRouteRecipient recipient = null;
50 boolean foundAtleastOneCompleteReq = false;
51 while (groupIter.hasNext()) {
52 recipient = groupIter.next();
53 valueToCheck = recipient.getActionRequested();
54 if (StringUtils.isNotEmpty(valueToCheck)) {
55 if (KewApiConstants.ACTION_REQUEST_COMPLETE_REQ.equals(valueToCheck)) {
56 foundAtleastOneCompleteReq = true;
57 break;
58 }
59 }
60 }
61 return foundAtleastOneCompleteReq;
62 }
63 }