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.bo.Options;
25: import org.kuali.kfs.context.SpringContext;
26: import org.kuali.kfs.service.OptionsService;
27:
28: /**
29: * An implementation of ValueFinder that returns all balance types, but which defaults to external encumbrance
30: */
31: public class GLEncumbranceBalanceTypeOptionFinder extends KeyValuesBase
32: implements ValueFinder {
33:
34: /**
35: * Returns the default value of this ValueFinder, in this case, external encumbrance
36: *
37: * @return a String with the key of the default value
38: * @see org.kuali.core.lookup.valueFinder.ValueFinder#getValue()
39: */
40: public String getValue() {
41: OptionsService os = SpringContext.getBean(OptionsService.class);
42: Options o = os.getCurrentYearOptions();
43:
44: return o.getExtrnlEncumFinBalanceTypCd();
45: }
46:
47: /**
48: * Returns a list of all balance types
49: *
50: * @return a List of key/value pairs to populate a drop down box
51: * @see org.kuali.core.lookup.keyvalues.KeyValuesFinder#getKeyValues()
52: */
53: public List getKeyValues() {
54: List labels = new ArrayList();
55:
56: OptionsService os = SpringContext.getBean(OptionsService.class);
57: Options o = os.getCurrentYearOptions();
58:
59: labels.add(new KeyLabelPair(o.getExtrnlEncumFinBalanceTypCd(),
60: o.getExtrnlEncumFinBalanceTypCd()
61: + " - "
62: + o.getExtrnlEncumFinBalanceTyp()
63: .getFinancialBalanceTypeName()));
64: labels.add(new KeyLabelPair(o.getIntrnlEncumFinBalanceTypCd(),
65: o.getIntrnlEncumFinBalanceTypCd()
66: + " - "
67: + o.getIntrnlEncumFinBalanceTyp()
68: .getFinancialBalanceTypeName()));
69: labels.add(new KeyLabelPair(o.getPreencumbranceFinBalTypeCd(),
70: o.getPreencumbranceFinBalTypeCd()
71: + " - "
72: + o.getPreencumbranceFinBalType()
73: .getFinancialBalanceTypeName()));
74:
75: return labels;
76: }
77: }
|