01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.core.lookup.keyvalues;
17:
18: import java.util.ArrayList;
19: import java.util.Collection;
20: import java.util.Collections;
21: import java.util.Comparator;
22: import java.util.Iterator;
23: import java.util.List;
24:
25: import org.kuali.core.bo.EmployeeStatus;
26: import org.kuali.core.service.KeyValuesService;
27: import org.kuali.core.web.ui.KeyLabelPair;
28: import org.kuali.rice.KNSServiceLocator;
29:
30: public class EmployeeStatusValuesFinder extends KeyValuesBase {
31:
32: /**
33: * This class returns a list of active employee statuses.
34: * @see org.kuali.core.lookup.keyvalues.KeyValuesFinder#getKeyValues()
35: */
36: public List getKeyValues() {
37: KeyValuesService boService = KNSServiceLocator
38: .getKeyValuesService();
39: List<EmployeeStatus> codes = new ArrayList<EmployeeStatus>();
40: for (Object employeeStatusAsObj : boService
41: .findAll(EmployeeStatus.class)) {
42: codes.add((EmployeeStatus) employeeStatusAsObj);
43: }
44: Collections.sort(codes, new Comparator<EmployeeStatus>() {
45: public int compare(EmployeeStatus empStatusA,
46: EmployeeStatus empStatusB) {
47: return empStatusA.getCode().compareTo(
48: empStatusB.getCode());
49: }
50:
51: });
52: List labels = new ArrayList();
53: labels.add(new KeyLabelPair("", ""));
54: Iterator iter = codes.iterator();
55: while (iter.hasNext()) {
56: EmployeeStatus status = (EmployeeStatus) iter.next();
57: labels.add(new KeyLabelPair(status.getCode(), status
58: .getCodeAndDescription()));
59: }
60:
61: return labels;
62: }
63:
64: }
|