001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.gl.businessobject.options;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import org.kuali.kfs.sys.KFSConstants;
022 import org.kuali.kfs.sys.businessobject.UniversityDate;
023 import org.kuali.kfs.sys.context.SpringContext;
024 import org.kuali.kfs.sys.service.UniversityDateService;
025 import org.kuali.rice.kns.lookup.keyvalues.KeyValuesBase;
026 import org.kuali.rice.kns.lookup.valueFinder.ValueFinder;
027 import org.kuali.rice.core.util.KeyLabelPair;
028
029 /**
030 * An implementation of ValueFinder that allows the selection of a period code
031 */
032 public class PeriodCodeOptionFinder extends KeyValuesBase implements ValueFinder {
033
034 /**
035 * Returns this default value of this ValueFinder, in this case the current period code
036 * @return the key of the default Key/Value pair
037 * @see org.kuali.rice.kns.lookup.valueFinder.ValueFinder#getValue()
038 */
039 public String getValue() {
040 UniversityDate ud = SpringContext.getBean(UniversityDateService.class).getCurrentUniversityDate();
041 return ud.getUniversityFiscalAccountingPeriod();
042 }
043
044 /**
045 * Returns a list of possible options for this ValueFinder; here, each of the fiscal periods
046 * @return a List of key/value pair options
047 * @see org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder#getKeyValues()
048 */
049 public List getKeyValues() {
050 List labels = new ArrayList();
051 labels.add(new KeyLabelPair(KFSConstants.MONTH1, KFSConstants.MONTH1));
052 labels.add(new KeyLabelPair(KFSConstants.MONTH2, KFSConstants.MONTH2));
053 labels.add(new KeyLabelPair(KFSConstants.MONTH3, KFSConstants.MONTH3));
054 labels.add(new KeyLabelPair(KFSConstants.MONTH4, KFSConstants.MONTH4));
055
056 labels.add(new KeyLabelPair(KFSConstants.MONTH5, KFSConstants.MONTH5));
057 labels.add(new KeyLabelPair(KFSConstants.MONTH6, KFSConstants.MONTH6));
058 labels.add(new KeyLabelPair(KFSConstants.MONTH7, KFSConstants.MONTH7));
059 labels.add(new KeyLabelPair(KFSConstants.MONTH8, KFSConstants.MONTH8));
060
061 labels.add(new KeyLabelPair(KFSConstants.MONTH9, KFSConstants.MONTH9));
062 labels.add(new KeyLabelPair(KFSConstants.MONTH10, KFSConstants.MONTH10));
063 labels.add(new KeyLabelPair(KFSConstants.MONTH11, KFSConstants.MONTH11));
064 labels.add(new KeyLabelPair(KFSConstants.MONTH12, KFSConstants.MONTH12));
065
066 labels.add(new KeyLabelPair(KFSConstants.MONTH13, KFSConstants.MONTH13));
067 labels.add(new KeyLabelPair(KFSConstants.PERIOD_CODE_ANNUAL_BALANCE, KFSConstants.PERIOD_CODE_ANNUAL_BALANCE));
068 labels.add(new KeyLabelPair(KFSConstants.PERIOD_CODE_BEGINNING_BALANCE, KFSConstants.PERIOD_CODE_BEGINNING_BALANCE));
069 labels.add(new KeyLabelPair(KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE, KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE));
070
071 return labels;
072 }
073
074 }