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.financial.bo.DisbursementVoucherDocumentationLocation;
28:
29: /**
30: * The values are the same as the disbursementVoucherDocumentationLocationCode in the DisbursementVoucherDocumentationLocation
31: * class.
32: */
33: public class DocumentationLocationCodeDescriptionFormatter extends
34: CodeDescriptionFormatterBase {
35: @Override
36: protected String getDescriptionOfBO(PersistableBusinessObject bo) {
37: return ((DisbursementVoucherDocumentationLocation) bo)
38: .getDisbursementVoucherDocumentationLocationName();
39: }
40:
41: @Override
42: protected Map<String, PersistableBusinessObject> getValuesToBusinessObjectsMap(
43: Set values) {
44: Map<String, PersistableBusinessObject> map = new HashMap<String, PersistableBusinessObject>();
45: Map<String, Object> criteria = new HashMap<String, Object>();
46: criteria
47: .put(
48: KFSConstants.DISBURSEMENT_VOUCHER_DOCUMENTATION_LOCATION_CODE_PROPERTY_NAME,
49: values);
50: Collection<DisbursementVoucherDocumentationLocation> coll = SpringContext
51: .getBean(BusinessObjectService.class)
52: .findMatchingOrderBy(
53: DisbursementVoucherDocumentationLocation.class,
54: criteria, "versionNumber", true);
55: // by sorting on ver #, we can guarantee that the most recent value will remain in the map (assuming the iterator returns
56: // BOs in order)
57: for (DisbursementVoucherDocumentationLocation dvdl : coll) {
58: map.put(dvdl
59: .getDisbursementVoucherDocumentationLocationCode(),
60: dvdl);
61: }
62: return map;
63: }
64: }
|