001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     * http://www.opensource.org/licenses/ecl2.php
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    /*
017     * Created on Sep 2, 2004
018     *
019     */
020    package org.kuali.kfs.pdp.dataaccess.impl;
021    
022    import java.util.Iterator;
023    
024    import org.apache.ojb.broker.query.Criteria;
025    import org.apache.ojb.broker.query.QueryByCriteria;
026    import org.apache.ojb.broker.query.QueryFactory;
027    import org.kuali.kfs.pdp.PdpPropertyConstants;
028    import org.kuali.kfs.pdp.businessobject.GlPendingTransaction;
029    import org.kuali.kfs.pdp.dataaccess.PendingTransactionDao;
030    import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
031    
032    
033    /**
034     * @see org.kuali.kfs.pdp.dataaccess.PendingTransactionDao
035     */
036    public class PendingTransactionDaoOjb extends PlatformAwareDaoBaseOjb implements PendingTransactionDao {
037        private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PendingTransactionDaoOjb.class);
038    
039        public PendingTransactionDaoOjb() {
040            super();
041        }
042    
043        /**
044         * @see org.kuali.kfs.pdp.dataaccess.PendingTransactionDao#getUnextractedTransactions()
045         */
046        public Iterator<GlPendingTransaction> getUnextractedTransactions() {
047            LOG.debug("save() started");
048    
049            Criteria criteria = new Criteria();
050            criteria.addEqualTo(PdpPropertyConstants.PROCESS_IND, false);
051            
052            Criteria criteria2 = new Criteria();
053            criteria2.addIsNull(PdpPropertyConstants.PROCESS_IND);
054            
055            criteria.addOrCriteria(criteria2);
056            return getPersistenceBrokerTemplate().getIteratorByQuery(new QueryByCriteria(GlPendingTransaction.class, criteria));
057        }
058        
059        /**
060         * @see org.kuali.kfs.pdp.dataaccess.PendingTransactionDao#clearExtractedTransactions()
061         */
062        public void clearExtractedTransactions() {
063            LOG.debug("clearExtractedTransactions() started");
064    
065            Criteria criteria = new Criteria();
066            criteria.addEqualTo(PdpPropertyConstants.PROCESS_IND, true);
067    
068            QueryByCriteria qbc = QueryFactory.newQuery(GlPendingTransaction.class, criteria);
069            getPersistenceBrokerTemplate().deleteByQuery(qbc);
070            getPersistenceBrokerTemplate().clearCache();
071        }
072    
073    }