1 /**
2 * Copyright 2005-2014 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 * @deprecated Use {@link org.kuali.rice.krad.util.RouteToCompletionUtil}.
28 */
29 //Adhoc Document Complete functionality utility
30 @Deprecated
31 public class RouteToCompletionUtil {
32
33 /***
34 * Checks if there is atleast one Ad-Hoc Completion request for the document and based on that returns a boolean value.
35 */
36 public static boolean checkIfAtleastOneAdHocCompleteRequestExist(Document document) {
37 boolean foundAtleastOneCompleteReq = false;
38 // iterating the adhoc recpients list to check if there is atleast on complete request for the document.
39 foundAtleastOneCompleteReq = loopAndCheckValue(document.getAdHocRouteWorkgroups()) || loopAndCheckValue(document.getAdHocRoutePersons());
40 return foundAtleastOneCompleteReq;
41 }
42
43 /***
44 * Loops and checks if the required value is present in the loop used for checking if there is atleast one adhoc completion
45 * request present for a person or work group
46 */
47 public static boolean loopAndCheckValue(List adhoc) {
48 if (adhoc == null) {
49 return false;
50 }
51 ListIterator<AdHocRouteRecipient> groupIter = adhoc.listIterator();
52 String valueToCheck = null;
53 AdHocRouteRecipient recipient = null;
54 boolean foundAtleastOneCompleteReq = false;
55 while (groupIter.hasNext()) {
56 recipient = groupIter.next();
57 valueToCheck = recipient.getActionRequested();
58 if (StringUtils.isNotEmpty(valueToCheck)) {
59 if (KewApiConstants.ACTION_REQUEST_COMPLETE_REQ.equals(valueToCheck)) {
60 foundAtleastOneCompleteReq = true;
61 break;
62 }
63 }
64 }
65 return foundAtleastOneCompleteReq;
66 }
67 }