Coverage Report - org.kuali.rice.kns.lookup.keyvalues.CampusTypeValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
CampusTypeValuesFinder
0%
0/14
0%
0/4
3
 
 1  
 /*
 2  
  * Copyright 2006-2007 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.lookup.keyvalues;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.Collections;
 20  
 import java.util.Iterator;
 21  
 import java.util.List;
 22  
 
 23  
 import org.kuali.rice.core.util.KeyLabelPair;
 24  
 import org.kuali.rice.kns.bo.CampusType;
 25  
 import org.kuali.rice.kns.bo.CampusTypeImpl;
 26  
 import org.kuali.rice.kns.service.KNSServiceLocator;
 27  
 import org.kuali.rice.kns.service.KeyValuesService;
 28  
 
 29  
 /**
 30  
  * This class...
 31  
  * 
 32  
  * 
 33  
  */
 34  0
 public class CampusTypeValuesFinder extends KeyValuesBase {
 35  
 
 36  
     public List getKeyValues() {
 37  
 
 38  
         // get a list of all CampusTypes
 39  0
         KeyValuesService boService = KNSServiceLocator.getKeyValuesService();
 40  0
         List campusTypes = (List) boService.findAll(CampusTypeImpl.class);
 41  
         // copy the list of codes before sorting, since we can't modify the results from this method
 42  0
         if ( campusTypes == null ) {
 43  0
                 campusTypes = new ArrayList<CampusTypeImpl>(0);
 44  
         } else {
 45  0
                 campusTypes = new ArrayList<CampusTypeImpl>( campusTypes );
 46  
         }
 47  
         // calling comparator.
 48  0
         CampusTypeComparator campusTypeComparator = new CampusTypeComparator();
 49  
 
 50  
         // sort using comparator.
 51  0
         Collections.sort(campusTypes, campusTypeComparator);
 52  
 
 53  
         // create a new list (code, descriptive-name)
 54  0
         List labels = new ArrayList();
 55  
 
 56  0
         for (Iterator iter = campusTypes.iterator(); iter.hasNext();) {
 57  0
             CampusType campusType = (CampusType) iter.next();
 58  0
             labels.add(new KeyLabelPair(campusType.getCampusTypeCode(), campusType.getCampusTypeCode() + " - " + campusType.getCampusTypeName()));
 59  0
         }
 60  
 
 61  0
         return labels;
 62  
     }
 63  
 }