01: /*
02: * Copyright 2006-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.module.gl.web.optionfinder;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20:
21: import org.kuali.core.lookup.keyvalues.KeyValuesBase;
22: import org.kuali.core.lookup.valueFinder.ValueFinder;
23: import org.kuali.core.web.ui.KeyLabelPair;
24: import org.kuali.kfs.KFSConstants;
25: import org.kuali.kfs.context.SpringContext;
26: import org.kuali.module.financial.service.UniversityDateService;
27: import org.kuali.module.gl.bo.UniversityDate;
28:
29: /**
30: * An implementation of ValueFinder that allows the selection of a period code
31: */
32: public class GLPeriodCodeOptionFinder extends KeyValuesBase implements
33: ValueFinder {
34:
35: /**
36: * Returns this default value of this ValueFinder, in this case the current period code
37: * @return the key of the default Key/Value pair
38: * @see org.kuali.core.lookup.valueFinder.ValueFinder#getValue()
39: */
40: public String getValue() {
41: UniversityDate ud = SpringContext.getBean(
42: UniversityDateService.class).getCurrentUniversityDate();
43: return ud.getUniversityFiscalAccountingPeriod();
44: }
45:
46: /**
47: * Returns a list of possible options for this ValueFinder; here, each of the fiscal periods
48: * @return a List of key/value pair options
49: * @see org.kuali.core.lookup.keyvalues.KeyValuesFinder#getKeyValues()
50: */
51: public List getKeyValues() {
52: List labels = new ArrayList();
53: labels.add(new KeyLabelPair(KFSConstants.MONTH1,
54: KFSConstants.MONTH1));
55: labels.add(new KeyLabelPair(KFSConstants.MONTH2,
56: KFSConstants.MONTH2));
57: labels.add(new KeyLabelPair(KFSConstants.MONTH3,
58: KFSConstants.MONTH3));
59: labels.add(new KeyLabelPair(KFSConstants.MONTH4,
60: KFSConstants.MONTH4));
61:
62: labels.add(new KeyLabelPair(KFSConstants.MONTH5,
63: KFSConstants.MONTH5));
64: labels.add(new KeyLabelPair(KFSConstants.MONTH6,
65: KFSConstants.MONTH6));
66: labels.add(new KeyLabelPair(KFSConstants.MONTH7,
67: KFSConstants.MONTH7));
68: labels.add(new KeyLabelPair(KFSConstants.MONTH8,
69: KFSConstants.MONTH8));
70:
71: labels.add(new KeyLabelPair(KFSConstants.MONTH9,
72: KFSConstants.MONTH9));
73: labels.add(new KeyLabelPair(KFSConstants.MONTH10,
74: KFSConstants.MONTH10));
75: labels.add(new KeyLabelPair(KFSConstants.MONTH11,
76: KFSConstants.MONTH11));
77: labels.add(new KeyLabelPair(KFSConstants.MONTH12,
78: KFSConstants.MONTH12));
79:
80: labels.add(new KeyLabelPair(KFSConstants.MONTH13,
81: KFSConstants.MONTH13));
82: labels.add(new KeyLabelPair(
83: KFSConstants.PERIOD_CODE_ANNUAL_BALANCE,
84: KFSConstants.PERIOD_CODE_ANNUAL_BALANCE));
85: labels.add(new KeyLabelPair(
86: KFSConstants.PERIOD_CODE_BEGINNING_BALANCE,
87: KFSConstants.PERIOD_CODE_BEGINNING_BALANCE));
88: labels.add(new KeyLabelPair(
89: KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE,
90: KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE));
91:
92: return labels;
93: }
94:
95: }
|