Coverage Report - org.kuali.rice.kew.rule.bo.DelegationTypeValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegationTypeValuesFinder
0%
0/11
0%
0/2
2
 
 1  
 /*
 2  
  * Copyright 2007-2009 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.kew.rule.bo;
 17  
 
 18  
 import org.kuali.rice.core.api.util.ConcreteKeyValue;
 19  
 import org.kuali.rice.core.api.util.KeyValue;
 20  
 import org.kuali.rice.kew.api.action.DelegationType;
 21  
 import org.kuali.rice.kew.util.KEWConstants;
 22  
 import org.kuali.rice.kns.util.KNSGlobalVariables;
 23  
 import org.kuali.rice.kns.web.struts.form.KualiMaintenanceForm;
 24  
 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
 25  
 
 26  
 import java.util.ArrayList;
 27  
 import java.util.Collections;
 28  
 import java.util.List;
 29  
 
 30  
 /**
 31  
  * A values finder for returning KEW rule delegation type codes.
 32  
  * 
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  */
 35  0
 public class DelegationTypeValuesFinder extends KeyValuesBase {
 36  
 
 37  
         private static final List<KeyValue> C_DELEGATION_TYPES;
 38  
         private static final List<KeyValue> C_DELEGATION_TYPES_FOR_MAIN_DOCS;
 39  
         static {
 40  
                 
 41  0
                 final List<KeyValue> delegationTypes = new ArrayList<KeyValue>();
 42  0
                 final List<KeyValue> delegationTypesForMaintDocs = new ArrayList<KeyValue>();
 43  
                 
 44  0
                 for (DelegationType delegationType : DelegationType.values()) {
 45  0
                         delegationTypes.add(new ConcreteKeyValue(delegationType.getCode(), delegationType.getLabel()));
 46  0
                         delegationTypesForMaintDocs.add(new ConcreteKeyValue(delegationType.getCode(), delegationType.getLabel()));
 47  
                 }
 48  
                 // for non maintenance documents, add a "both" option
 49  0
                 delegationTypes.add(new ConcreteKeyValue(KEWConstants.DELEGATION_BOTH, KEWConstants.DELEGATION_BOTH_LABEL));
 50  
                 
 51  0
                 C_DELEGATION_TYPES = Collections.unmodifiableList(delegationTypes);
 52  0
                 C_DELEGATION_TYPES_FOR_MAIN_DOCS = Collections.unmodifiableList(delegationTypesForMaintDocs);
 53  0
         }
 54  
         
 55  
         @Override
 56  
         public List<KeyValue> getKeyValues() {
 57  
                 // Return the appropriate delegation types list, depending on whether or not it is needed for a maintenance doc.
 58  0
                 return (KNSGlobalVariables.getKualiForm() instanceof KualiMaintenanceForm) ? C_DELEGATION_TYPES_FOR_MAIN_DOCS : C_DELEGATION_TYPES;
 59  
         }
 60  
 
 61  
 }