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.Collection;
20: import java.util.Iterator;
21: import java.util.List;
22:
23: import org.kuali.core.lookup.keyvalues.KeyValuesBase;
24: import org.kuali.core.lookup.valueFinder.ValueFinder;
25: import org.kuali.core.web.ui.KeyLabelPair;
26: import org.kuali.kfs.bo.Options;
27: import org.kuali.kfs.context.SpringContext;
28: import org.kuali.kfs.service.OptionsService;
29: import org.kuali.module.chart.bo.codes.BalanceTyp;
30: import org.kuali.module.chart.service.BalanceTypService;
31:
32: /**
33: * A value finder that returns all balance type, but selects the actual balance type
34: */
35: public class GLActualBalanceTypeOptionFinder extends KeyValuesBase
36: implements ValueFinder {
37:
38: /**
39: * Returns the value to select: here the value of the actual balance type
40: *
41: * @return the balance type code for actual balances
42: * @see org.kuali.core.lookup.valueFinder.ValueFinder#getValue()
43: */
44: public String getValue() {
45: OptionsService os = SpringContext.getBean(OptionsService.class);
46: Options o = os.getCurrentYearOptions();
47:
48: return o.getActualFinancialBalanceTypeCd();
49: }
50:
51: /**
52: * Returns a list of the key value pairs of all balance type codes and their names
53: *
54: * @return a List of all balance types to populate a dropdown control
55: * @see org.kuali.core.lookup.keyvalues.KeyValuesFinder#getKeyValues()
56: */
57: public List getKeyValues() {
58: List labels = new ArrayList();
59:
60: BalanceTypService bts = SpringContext
61: .getBean(BalanceTypService.class);
62: Collection c = bts.getAllBalanceTyps();
63:
64: for (Iterator iter = c.iterator(); iter.hasNext();) {
65: BalanceTyp bt = (BalanceTyp) iter.next();
66: labels.add(new KeyLabelPair(bt.getCode(), bt.getCode()
67: + " - " + bt.getName()));
68: }
69:
70: return labels;
71: }
72:
73: }
|