View Javadoc
1   /*
2    * Copyright 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.ole.sys.businessobject.options;
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.ole.sys.businessobject.SystemOptions;
24  import org.kuali.ole.sys.context.SpringContext;
25  import org.kuali.rice.core.api.util.ConcreteKeyValue;
26  import org.kuali.rice.krad.keyvalues.KeyValuesBase;
27  import org.kuali.rice.krad.service.KeyValuesService;
28  
29  /**
30   * This class...
31   */
32  public class FiscalYearValuesFinder extends KeyValuesBase {
33  
34      /*
35       * @see org.kuali.keyvalues.KeyValuesFinder#getKeyValues()
36       */
37      public List getKeyValues() {
38  
39          KeyValuesService boService = SpringContext.getBean(KeyValuesService.class);
40          FiscalYearComparator fiscalYearComparator = new FiscalYearComparator();
41          List optionList = (List) boService.findAll(SystemOptions.class);
42          // copy the list of codes before sorting, since we can't modify the results from this method
43          if ( optionList == null ) {
44              optionList = new ArrayList(0);
45          } else {
46              optionList = new ArrayList( optionList );
47          }
48          Collections.sort(optionList, fiscalYearComparator);
49          List labels = new ArrayList();
50          labels.add(new ConcreteKeyValue("", ""));
51          for (Iterator iter = optionList.iterator(); iter.hasNext();) {
52              SystemOptions options = (SystemOptions) iter.next();
53              labels.add(new ConcreteKeyValue(options.getUniversityFiscalYear().toString(), options.getUniversityFiscalYear().toString()));
54          }
55  
56          return labels;
57      }
58  
59  }