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  /*
17   * Created on Sep 2, 2004
18   *
19   */
20  package org.kuali.ole.pdp.dataaccess.impl;
21  
22  import java.util.Iterator;
23  
24  import org.apache.ojb.broker.query.Criteria;
25  import org.apache.ojb.broker.query.QueryByCriteria;
26  import org.apache.ojb.broker.query.QueryFactory;
27  import org.kuali.ole.pdp.PdpPropertyConstants;
28  import org.kuali.ole.pdp.businessobject.GlPendingTransaction;
29  import org.kuali.ole.pdp.dataaccess.PendingTransactionDao;
30  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
31  
32  
33  /**
34   * @see org.kuali.ole.pdp.dataaccess.PendingTransactionDao
35   */
36  public class PendingTransactionDaoOjb extends PlatformAwareDaoBaseOjb implements PendingTransactionDao {
37      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PendingTransactionDaoOjb.class);
38  
39      public PendingTransactionDaoOjb() {
40          super();
41      }
42  
43      /**
44       * @see org.kuali.ole.pdp.dataaccess.PendingTransactionDao#getUnextractedTransactions()
45       */
46      public Iterator<GlPendingTransaction> getUnextractedTransactions() {
47          LOG.debug("save() started");
48  
49          Criteria criteria = new Criteria();
50          criteria.addEqualTo(PdpPropertyConstants.PROCESS_IND, false);
51          
52          Criteria criteria2 = new Criteria();
53          criteria2.addIsNull(PdpPropertyConstants.PROCESS_IND);
54          
55          criteria.addOrCriteria(criteria2);
56          return getPersistenceBrokerTemplate().getIteratorByQuery(new QueryByCriteria(GlPendingTransaction.class, criteria));
57      }
58      
59      /**
60       * @see org.kuali.ole.pdp.dataaccess.PendingTransactionDao#clearExtractedTransactions()
61       */
62      public void clearExtractedTransactions() {
63          LOG.debug("clearExtractedTransactions() started");
64  
65          Criteria criteria = new Criteria();
66          criteria.addEqualTo(PdpPropertyConstants.PROCESS_IND, true);
67  
68          QueryByCriteria qbc = QueryFactory.newQuery(GlPendingTransaction.class, criteria);
69          getPersistenceBrokerTemplate().deleteByQuery(qbc);
70          getPersistenceBrokerTemplate().clearCache();
71      }
72  
73  }