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.dataaccess.impl;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.util.Iterator;
21  
22  import org.apache.ojb.broker.query.Criteria;
23  import org.apache.ojb.broker.query.QueryByCriteria;
24  import org.kuali.ole.pdp.PdpConstants;
25  import org.kuali.ole.pdp.PdpPropertyConstants;
26  import org.kuali.ole.pdp.businessobject.PaymentGroupHistory;
27  import org.kuali.ole.pdp.dataaccess.PaymentGroupHistoryDao;
28  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
29  
30  public class PaymentGroupHistoryDaoOjb extends PlatformAwareDaoBaseOjb implements PaymentGroupHistoryDao {
31      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PaymentGroupHistoryDaoOjb.class);
32  
33      public PaymentGroupHistoryDaoOjb() {
34          super();
35      }
36  
37      /**
38       * @see org.kuali.ole.pdp.dataaccess.PaymentGroupHistoryDao#getCanceledChecks()
39       */
40      public Iterator getCanceledChecks() {
41          LOG.debug("getCanceledChecks() started");
42  
43          Collection codes = new ArrayList();
44          codes.add(PdpConstants.PaymentChangeCodes.CANCEL_DISBURSEMENT);
45          codes.add(PdpConstants.PaymentChangeCodes.CANCEL_REISSUE_DISBURSEMENT);
46          codes.add(PdpConstants.PaymentChangeCodes.REISSUE_DISBURSEMENT);
47  
48          Criteria crit = new Criteria();
49          crit.addIn(PdpPropertyConstants.PAYMENT_CHANGE_CODE, codes);
50          crit.addIsNull(PdpPropertyConstants.PaymentGroupHistory.PMT_CANCEL_EXTRACT_DATE);
51  
52          Criteria o1 = new Criteria();
53          o1.addNotEqualTo(PdpPropertyConstants.DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
54          Criteria o1a = new Criteria();
55          o1a.addIsNull(PdpPropertyConstants.DISBURSEMENT_TYPE_CODE);
56          o1.addOrCriteria(o1a);
57  
58          Criteria o2 = new Criteria();
59          o2.addEqualTo(PdpPropertyConstants.DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.CHECK);
60          Criteria o2a = new Criteria();
61          o2a.addEqualTo(PdpPropertyConstants.PAYMENT_GROUP + "." + PdpPropertyConstants.DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.CHECK);
62          o2.addOrCriteria(o2a);
63  
64          crit.addAndCriteria(o1);
65          crit.addAndCriteria(o2);
66  
67          return getPersistenceBrokerTemplate().getIteratorByQuery(new QueryByCriteria(PaymentGroupHistory.class, crit));
68      }
69  }