001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kns.util; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.kew.api.KewApiConstants; 020import org.kuali.rice.krad.bo.AdHocRouteRecipient; 021import org.kuali.rice.krad.document.Document; 022 023import java.util.List; 024import java.util.ListIterator; 025 026/** 027 * @deprecated Use {@link org.kuali.rice.krad.util.RouteToCompletionUtil}. 028 */ 029//Adhoc Document Complete functionality utility 030@Deprecated 031public class RouteToCompletionUtil { 032 033 /*** 034 * Checks if there is atleast one Ad-Hoc Completion request for the document and based on that returns a boolean value. 035 */ 036 public static boolean checkIfAtleastOneAdHocCompleteRequestExist(Document document) { 037 boolean foundAtleastOneCompleteReq = false; 038 // iterating the adhoc recpients list to check if there is atleast on complete request for the document. 039 foundAtleastOneCompleteReq = loopAndCheckValue(document.getAdHocRouteWorkgroups()) || loopAndCheckValue(document.getAdHocRoutePersons()); 040 return foundAtleastOneCompleteReq; 041 } 042 043 /*** 044 * Loops and checks if the required value is present in the loop used for checking if there is atleast one adhoc completion 045 * request present for a person or work group 046 */ 047 public static boolean loopAndCheckValue(List adhoc) { 048 if (adhoc == null) { 049 return false; 050 } 051 ListIterator<AdHocRouteRecipient> groupIter = adhoc.listIterator(); 052 String valueToCheck = null; 053 AdHocRouteRecipient recipient = null; 054 boolean foundAtleastOneCompleteReq = false; 055 while (groupIter.hasNext()) { 056 recipient = groupIter.next(); 057 valueToCheck = recipient.getActionRequested(); 058 if (StringUtils.isNotEmpty(valueToCheck)) { 059 if (KewApiConstants.ACTION_REQUEST_COMPLETE_REQ.equals(valueToCheck)) { 060 foundAtleastOneCompleteReq = true; 061 break; 062 } 063 } 064 } 065 return foundAtleastOneCompleteReq; 066 } 067}