View Javadoc
1   /*
2    * Copyright 2006 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.gl.businessobject.options;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.ole.sys.OLEConstants;
22  import org.kuali.ole.sys.businessobject.UniversityDate;
23  import org.kuali.ole.sys.context.SpringContext;
24  import org.kuali.ole.sys.service.UniversityDateService;
25  import org.kuali.rice.core.api.util.ConcreteKeyValue;
26  import org.kuali.rice.krad.keyvalues.KeyValuesBase;
27  import org.kuali.rice.krad.valuefinder.ValueFinder;
28  
29  /**
30   * An implementation of ValueFinder that allows the selection of a period code
31   */
32  public class PeriodCodeOptionFinder extends KeyValuesBase implements ValueFinder {
33  
34      /**
35       * Returns this default value of this ValueFinder, in this case the current period code
36       * @return the key of the default Key/Value pair
37       * @see org.kuali.rice.krad.valuefinder.ValueFinder#getValue()
38       */
39      public String getValue() {
40          UniversityDate ud = SpringContext.getBean(UniversityDateService.class).getCurrentUniversityDate();
41          return ud.getUniversityFiscalAccountingPeriod();
42      }
43  
44      /**
45       * Returns a list of possible options for this ValueFinder; here, each of the fiscal periods
46       * @return a List of key/value pair options
47       * @see org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder#getKeyValues()
48       */
49      public List getKeyValues() {
50          List labels = new ArrayList();
51          labels.add(new ConcreteKeyValue(OLEConstants.MONTH1, OLEConstants.MONTH1));
52          labels.add(new ConcreteKeyValue(OLEConstants.MONTH2, OLEConstants.MONTH2));
53          labels.add(new ConcreteKeyValue(OLEConstants.MONTH3, OLEConstants.MONTH3));
54          labels.add(new ConcreteKeyValue(OLEConstants.MONTH4, OLEConstants.MONTH4));
55  
56          labels.add(new ConcreteKeyValue(OLEConstants.MONTH5, OLEConstants.MONTH5));
57          labels.add(new ConcreteKeyValue(OLEConstants.MONTH6, OLEConstants.MONTH6));
58          labels.add(new ConcreteKeyValue(OLEConstants.MONTH7, OLEConstants.MONTH7));
59          labels.add(new ConcreteKeyValue(OLEConstants.MONTH8, OLEConstants.MONTH8));
60  
61          labels.add(new ConcreteKeyValue(OLEConstants.MONTH9, OLEConstants.MONTH9));
62          labels.add(new ConcreteKeyValue(OLEConstants.MONTH10, OLEConstants.MONTH10));
63          labels.add(new ConcreteKeyValue(OLEConstants.MONTH11, OLEConstants.MONTH11));
64          labels.add(new ConcreteKeyValue(OLEConstants.MONTH12, OLEConstants.MONTH12));
65  
66          labels.add(new ConcreteKeyValue(OLEConstants.MONTH13, OLEConstants.MONTH13));
67          labels.add(new ConcreteKeyValue(OLEConstants.PERIOD_CODE_ANNUAL_BALANCE, OLEConstants.PERIOD_CODE_ANNUAL_BALANCE));
68          labels.add(new ConcreteKeyValue(OLEConstants.PERIOD_CODE_BEGINNING_BALANCE, OLEConstants.PERIOD_CODE_BEGINNING_BALANCE));
69          labels.add(new ConcreteKeyValue(OLEConstants.PERIOD_CODE_CG_BEGINNING_BALANCE, OLEConstants.PERIOD_CODE_CG_BEGINNING_BALANCE));
70  
71          return labels;
72      }
73  
74  }