View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
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.ole.pdp.service.impl;
17  
18  import java.util.HashMap;
19  import java.util.Iterator;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.kuali.ole.pdp.PdpPropertyConstants;
24  import org.kuali.ole.pdp.businessobject.PaymentDetail;
25  import org.kuali.ole.pdp.dataaccess.PaymentDetailDao;
26  import org.kuali.ole.pdp.service.PaymentDetailService;
27  import org.kuali.ole.sys.DynamicCollectionComparator;
28  import org.kuali.ole.sys.service.NonTransactional;
29  import org.kuali.rice.krad.service.BusinessObjectService;
30  
31  @NonTransactional
32  public class PaymentDetailServiceImpl implements PaymentDetailService {
33      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PaymentDetailServiceImpl.class);
34  
35      private PaymentDetailDao paymentDetailDao;
36      private BusinessObjectService businessObjectService;
37      
38      public void setPaymentDetailDao(PaymentDetailDao c) {
39          paymentDetailDao = c;
40      }
41  
42      /**
43       * @see org.kuali.ole.pdp.service.PaymentDetailService#getByDisbursementNumber(java.lang.Integer)
44       */
45      public Iterator getByDisbursementNumber(Integer disbursementNumber) {
46          LOG.debug("getByDisbursementNumber() started");
47          
48          Map fieldValues = new HashMap();
49          fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_NUMBER, disbursementNumber);
50          List<PaymentDetail> paymentDetailByDisbursementNumberList= (List<PaymentDetail>)this.businessObjectService.findMatching(PaymentDetail.class, fieldValues);
51          DynamicCollectionComparator.sort(paymentDetailByDisbursementNumberList, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_FINANCIAL_DOCUMENT_TYPE_CODE, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_CUST_PAYMENT_DOC_NBR);
52  
53          return paymentDetailByDisbursementNumberList.iterator();
54      }
55      
56      /**
57       * Returns all PaymentDetail records with the given disbursement number and a group with the given process id, disbursement type, and bank code
58       * @param disbursementNumber the disbursement number of the payment details to find
59       * @param processId the process id of the payment group of payment details to find
60       * @param disbursementType the disbursement type of the payment group of payment details to find
61       * @param bankCode the bank code of the payment group of payment details to find
62       * @return an iterator of PaymentDetail records matching the given criteria
63       */
64      public Iterator<PaymentDetail> getByDisbursementNumber(Integer disbursementNumber, Integer processId, String disbursementType, String bankCode) {
65          if (LOG.isDebugEnabled()) {
66              LOG.debug("getByDisbursementNumber() started");
67          }
68          
69          Map fieldValues = new HashMap();
70          fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_NUMBER, disbursementNumber);
71          fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP+"."+PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PROCESS_ID, processId);
72          fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP+"."+PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, disbursementType);
73          fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP+"."+PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, bankCode);
74          List<PaymentDetail> paymentDetailByDisbursementNumberList= (List<PaymentDetail>)this.businessObjectService.findMatching(PaymentDetail.class, fieldValues);
75          DynamicCollectionComparator.sort(paymentDetailByDisbursementNumberList, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_FINANCIAL_DOCUMENT_TYPE_CODE, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_CUST_PAYMENT_DOC_NBR);
76  
77          return paymentDetailByDisbursementNumberList.iterator();
78      }
79  
80      /**
81       * @see org.kuali.ole.pdp.service.PaymentDetailService#getUnprocessedCancelledDetails(java.lang.String, java.lang.String)
82       */
83      public Iterator getUnprocessedCancelledDetails(String organization, List<String> subUnits) {
84          LOG.debug("getUnprocessedCancelledDetails() started");
85  
86          return paymentDetailDao.getUnprocessedCancelledDetails(organization, subUnits);
87      }
88  
89      /**
90       * @see org.kuali.ole.pdp.service.PaymentDetailService#getUnprocessedPaidDetails(java.lang.String, java.lang.String)
91       */
92      public Iterator getUnprocessedPaidDetails(String organization, List<String> subUnits) {
93          LOG.debug("getUnprocessedPaidDetails() started");
94  
95          return paymentDetailDao.getUnprocessedPaidDetails(organization, subUnits);
96      }
97  
98      public void setBusinessObjectService(BusinessObjectService businessObjectService) {
99          this.businessObjectService = businessObjectService;
100     }
101 }