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.financial.util;
17:
18: import java.util.Collection;
19: import java.util.HashMap;
20: import java.util.Map;
21: import java.util.Set;
22:
23: import org.kuali.core.bo.PersistableBusinessObject;
24: import org.kuali.core.service.BusinessObjectService;
25: import org.kuali.kfs.KFSConstants;
26: import org.kuali.kfs.context.SpringContext;
27: import org.kuali.module.chart.bo.ObjLevel;
28:
29: /**
30: * This class...
31: */
32: public class ObjectLevelCodeDescriptionFormatter extends
33: CodeDescriptionFormatterBase {
34:
35: private String chartOfAccountsCode;
36:
37: public ObjectLevelCodeDescriptionFormatter(
38: String chartOfAccountsCode) {
39: this .chartOfAccountsCode = chartOfAccountsCode;
40: }
41:
42: /**
43: * @see org.kuali.module.financial.util.CodeDescriptionFormatterBase#getDescriptionOfBO(org.kuali.core.bo.BusinessObject)
44: */
45: @Override
46: protected String getDescriptionOfBO(PersistableBusinessObject bo) {
47: return ((ObjLevel) bo).getFinancialObjectLevelName();
48: }
49:
50: /**
51: * @see org.kuali.module.financial.util.CodeDescriptionFormatterBase#getValuesToBusinessObjectsMap(java.util.Set)
52: */
53: @Override
54: protected Map<String, PersistableBusinessObject> getValuesToBusinessObjectsMap(
55: Set values) {
56: Map<String, Object> criteria = new HashMap<String, Object>();
57: criteria.put(KFSConstants.CHART_OF_ACCOUNTS_CODE_PROPERTY_NAME,
58: chartOfAccountsCode);
59: criteria.put(
60: KFSConstants.FINANCIAL_OBJECT_LEVEL_CODE_PROPERTY_NAME,
61: values);
62: Collection<ObjLevel> coll = SpringContext.getBean(
63: BusinessObjectService.class).findMatchingOrderBy(
64: ObjLevel.class, criteria, KFSConstants.VERSION_NUMBER,
65: true);
66:
67: Map<String, PersistableBusinessObject> results = new HashMap<String, PersistableBusinessObject>();
68: // TODO: worry about version #s
69: for (ObjLevel ol : coll) {
70: results.put(ol.getFinancialObjectLevelCode(), ol);
71: }
72: return results;
73: }
74:
75: }
|