1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class AffiliationTypeValuesFinder extends KeyValuesBase { |
34 | |
|
35 | |
|
36 | |
|
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 | |
|
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 | |
} |