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    package org.kuali.kfs.module.ar.dataaccess.impl;
017    
018    import java.util.Iterator;
019    
020    import org.apache.ojb.broker.query.Criteria;
021    import org.apache.ojb.broker.query.QueryByCriteria;
022    import org.kuali.kfs.module.ar.businessobject.InvoiceRecurrence;
023    import org.kuali.kfs.module.ar.dataaccess.InvoiceRecurrenceDao;
024    import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
025    
026    public class InvoiceRecurrenceDaoOjb extends PlatformAwareDaoBaseOjb implements InvoiceRecurrenceDao {
027    
028        private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(InvoiceRecurrenceDaoOjb.class);
029    
030        /**
031         * @see org.kuali.module.ar.dao.OrganizationOptionsDao#getByPrimaryId(java.lang.String, java.lang.String)
032         */
033        public InvoiceRecurrence getByPrimaryId(String invoiceNumber) {
034            LOG.debug("getByPrimaryId() started"); 
035    
036            Criteria criteria = new Criteria();
037            criteria.addEqualTo("invoiceNumber", invoiceNumber);
038    
039            QueryByCriteria query = new QueryByCriteria(InvoiceRecurrence.class, criteria);
040            query.addOrderByAscending("invoiceNumber");
041            
042            return (InvoiceRecurrence) getPersistenceBrokerTemplate().getObjectByQuery(query);
043        }
044    
045        public Iterator<InvoiceRecurrence> getAllActiveInvoiceRecurrences() {
046            LOG.debug("getAllActiveInvoiceRecurrences() started"); 
047    
048            Criteria criteria = new Criteria();
049            criteria.addEqualTo("active", true);
050    
051            QueryByCriteria query = new QueryByCriteria(InvoiceRecurrence.class, criteria);
052            query.addOrderByAscending("invoiceNumber");
053            
054            return (Iterator<InvoiceRecurrence>)getPersistenceBrokerTemplate().getIteratorByQuery(query);
055        }
056        
057        public Iterator<InvoiceRecurrence> getAllInvoiceRecurrences() {
058            LOG.debug("getAllInvoiceRecurrencees() started");
059            Criteria criteria = new Criteria();
060            QueryByCriteria query = new QueryByCriteria(InvoiceRecurrence.class, criteria);
061            query.addOrderByAscending("invoiceNumber");
062            
063            return (Iterator<InvoiceRecurrence>)getPersistenceBrokerTemplate().getIteratorByQuery(query);
064            
065        }
066    
067    }