Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
NamespaceValuesFinder |
|
| 3.0;3 |
1 | /* | |
2 | * Copyright 2006-2008 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.List; | |
21 | ||
22 | import org.kuali.rice.core.util.KeyLabelPair; | |
23 | import org.kuali.rice.kns.bo.Namespace; | |
24 | import org.kuali.rice.kns.service.KNSServiceLocator; | |
25 | import org.kuali.rice.kns.service.KeyValuesService; | |
26 | ||
27 | /** | |
28 | * This class... | |
29 | * | |
30 | * | |
31 | */ | |
32 | 0 | public class NamespaceValuesFinder extends KeyValuesBase { |
33 | ||
34 | 0 | private static NamespaceComparator comparator = new NamespaceComparator(); |
35 | ||
36 | public List<KeyLabelPair> getKeyValues() { | |
37 | ||
38 | // get a list of all CampusTypes | |
39 | 0 | KeyValuesService boService = KNSServiceLocator.getKeyValuesService(); |
40 | 0 | List<Namespace> bos = (List) boService.findAll(Namespace.class); |
41 | // copy the list of codes before sorting, since we can't modify the results from this method | |
42 | 0 | if ( bos == null ) { |
43 | 0 | bos = new ArrayList<Namespace>(0); |
44 | } else { | |
45 | 0 | bos = new ArrayList<Namespace>( bos ); |
46 | } | |
47 | ||
48 | // sort using comparator. | |
49 | 0 | Collections.sort(bos, comparator); |
50 | ||
51 | // create a new list (code, descriptive-name) | |
52 | 0 | List<KeyLabelPair> labels = new ArrayList<KeyLabelPair>( bos.size() ); |
53 | 0 | labels.add(new KeyLabelPair("", "")); |
54 | 0 | for ( Namespace bo : bos ) { |
55 | 0 | labels.add( new KeyLabelPair(bo.getNamespaceCode(), bo.getCodeAndDescription() ) ); |
56 | } | |
57 | 0 | return labels; |
58 | } | |
59 | } |