001/* 002 * Copyright 2006 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 */ 016package org.kuali.ole.gl.businessobject.options; 017 018import java.util.ArrayList; 019import java.util.List; 020 021import org.kuali.ole.sys.OLEConstants; 022import org.kuali.ole.sys.businessobject.UniversityDate; 023import org.kuali.ole.sys.context.SpringContext; 024import org.kuali.ole.sys.service.UniversityDateService; 025import org.kuali.rice.core.api.util.ConcreteKeyValue; 026import org.kuali.rice.krad.keyvalues.KeyValuesBase; 027import org.kuali.rice.krad.valuefinder.ValueFinder; 028 029/** 030 * An implementation of ValueFinder that allows the selection of a period code 031 */ 032public 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.krad.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 ConcreteKeyValue(OLEConstants.MONTH1, OLEConstants.MONTH1)); 052 labels.add(new ConcreteKeyValue(OLEConstants.MONTH2, OLEConstants.MONTH2)); 053 labels.add(new ConcreteKeyValue(OLEConstants.MONTH3, OLEConstants.MONTH3)); 054 labels.add(new ConcreteKeyValue(OLEConstants.MONTH4, OLEConstants.MONTH4)); 055 056 labels.add(new ConcreteKeyValue(OLEConstants.MONTH5, OLEConstants.MONTH5)); 057 labels.add(new ConcreteKeyValue(OLEConstants.MONTH6, OLEConstants.MONTH6)); 058 labels.add(new ConcreteKeyValue(OLEConstants.MONTH7, OLEConstants.MONTH7)); 059 labels.add(new ConcreteKeyValue(OLEConstants.MONTH8, OLEConstants.MONTH8)); 060 061 labels.add(new ConcreteKeyValue(OLEConstants.MONTH9, OLEConstants.MONTH9)); 062 labels.add(new ConcreteKeyValue(OLEConstants.MONTH10, OLEConstants.MONTH10)); 063 labels.add(new ConcreteKeyValue(OLEConstants.MONTH11, OLEConstants.MONTH11)); 064 labels.add(new ConcreteKeyValue(OLEConstants.MONTH12, OLEConstants.MONTH12)); 065 066 labels.add(new ConcreteKeyValue(OLEConstants.MONTH13, OLEConstants.MONTH13)); 067 labels.add(new ConcreteKeyValue(OLEConstants.PERIOD_CODE_ANNUAL_BALANCE, OLEConstants.PERIOD_CODE_ANNUAL_BALANCE)); 068 labels.add(new ConcreteKeyValue(OLEConstants.PERIOD_CODE_BEGINNING_BALANCE, OLEConstants.PERIOD_CODE_BEGINNING_BALANCE)); 069 labels.add(new ConcreteKeyValue(OLEConstants.PERIOD_CODE_CG_BEGINNING_BALANCE, OLEConstants.PERIOD_CODE_CG_BEGINNING_BALANCE)); 070 071 return labels; 072 } 073 074}