01: /*
02: * Copyright 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: /*
17: * Created on Aug 2, 2004
18: *
19: */
20: package org.kuali.module.pdp.service.impl;
21:
22: import java.util.ArrayList;
23: import java.util.Collections;
24: import java.util.Comparator;
25: import java.util.List;
26:
27: import org.kuali.kfs.service.ParameterService;
28: import org.kuali.kfs.service.impl.ParameterConstants;
29: import org.kuali.module.pdp.PdpConstants;
30: import org.kuali.module.pdp.bo.PaymentDetailSearch;
31: import org.kuali.module.pdp.dao.PaymentDetailSearchDao;
32: import org.kuali.module.pdp.service.PaymentDetailSearchService;
33: import org.kuali.module.pdp.utilities.GeneralUtilities;
34: import org.springframework.transaction.annotation.Transactional;
35:
36: /**
37: * @author delyea
38: */
39: @Transactional
40: public class PaymentDetailSearchServiceImpl implements
41: PaymentDetailSearchService {
42: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
43: .getLogger(PaymentDetailSearchServiceImpl.class);
44:
45: private ParameterService parameterService;
46: private PaymentDetailSearchDao paymentDetailSearchDao;
47:
48: public void setPaymentDetailSearchDao(PaymentDetailSearchDao p) {
49: paymentDetailSearchDao = p;
50: }
51:
52: public List getAllPaymentsForSearchCriteria(PaymentDetailSearch pds) {
53: LOG.debug("getAllPaymentsForSearchCriteria() started");
54:
55: List finalResults = new ArrayList();
56: List nonCancels = paymentDetailSearchDao
57: .getAllPaymentsForSearchCriteria(pds,
58: getMaxSearchTotal());
59: finalResults.addAll(nonCancels);
60:
61: if (pds.getDisbursementNbr() != null) {
62: finalResults.addAll(paymentDetailSearchDao
63: .getAllPaymentsWithCancelReissueDisbNbr(pds));
64: }
65:
66: Collections.sort(finalResults, new Comparator() {
67: public int compare(Object o1, Object o2) {
68: return (((org.kuali.module.pdp.bo.PaymentDetail) o1)
69: .getPaymentGroup().getPayeeName())
70: .compareTo(((org.kuali.module.pdp.bo.PaymentDetail) o2)
71: .getPaymentGroup().getPayeeName());
72: }
73: });
74:
75: return finalResults;
76: }
77:
78: private int getMaxSearchTotal() {
79: return GeneralUtilities
80: .getParameterInteger(
81: parameterService,
82: ParameterConstants.PRE_DISBURSEMENT_LOOKUP.class,
83: PdpConstants.ApplicationParameterKeys.SEARCH_RESULTS_TOTAL);
84: }
85:
86: public void setParameterService(ParameterService parameterService) {
87: this.parameterService = parameterService;
88: }
89: }
|