Coverage Report - org.kuali.rice.kim.bo.options.AffiliationTypeValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
AffiliationTypeValuesFinder
0%
0/16
0%
0/6
4
 
 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.kim.bo.options;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import org.apache.commons.lang.StringUtils;
 22  
 import org.kuali.rice.core.util.KeyLabelPair;
 23  
 import org.kuali.rice.kns.bo.Country;
 24  
 import org.kuali.rice.kns.lookup.keyvalues.KeyValuesBase;
 25  
 import org.kuali.rice.kns.service.KNSServiceLocator;
 26  
 
 27  
 /**
 28  
  * This is a description of what this class does - shyu don't forget to fill this in. 
 29  
  * 
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  *
 32  
  */
 33  0
 public class AffiliationTypeValuesFinder extends KeyValuesBase {
 34  
 
 35  
     /*
 36  
      * @see org.kuali.keyvalues.KeyValuesFinder#getKeyValues()
 37  
      */
 38  
     public List getKeyValues() {
 39  0
         List<Country> boList = KNSServiceLocator.getCountryService().findAllCountries();
 40  0
         List<KeyLabelPair> keyValues = new ArrayList<KeyLabelPair>();
 41  
 
 42  0
         Country defaultCountry = null;
 43  0
         for (Country element : boList) {
 44  0
             String defaultCountryCode = KNSServiceLocator.getCountryService().getDefaultCountry().getPostalCountryCode();
 45  
             
 46  
             // Find default country code and pull it out so we can set it first in the results list later.
 47  0
             if (StringUtils.equals(defaultCountryCode, element.getPostalCountryCode())) {
 48  0
                 defaultCountry = element;
 49  
             }
 50  
             else {
 51  0
                 if(element.isActive()) {
 52  0
                     keyValues.add(new KeyLabelPair(element.getPostalCountryCode(), element.getPostalCountryName()));
 53  
                 }
 54  
             }
 55  0
         }
 56  
 
 57  0
         List<KeyLabelPair> keyValueUSFirst = new ArrayList<KeyLabelPair>();
 58  0
         keyValueUSFirst.add(new KeyLabelPair("", ""));
 59  0
         keyValueUSFirst.add(new KeyLabelPair(defaultCountry.getPostalCountryCode(), defaultCountry.getPostalCountryName()));
 60  0
         keyValueUSFirst.addAll(keyValues);
 61  
 
 62  0
         return keyValueUSFirst;
 63  
     }
 64  
 
 65  
 
 66  
 }