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.coa.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.apache.ojb.broker.query.QueryFactory;
023    import org.apache.ojb.broker.query.ReportQueryByCriteria;
024    import org.kuali.kfs.coa.businessobject.IndirectCostRecoveryExclusionAccount;
025    import org.kuali.kfs.coa.dataaccess.IndirectCostRecoveryExclusionAccountDao;
026    import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
027    
028    /**
029     * This class implements the {@link IndirectCostRecoveryExclusionAccountDao} data access methods using Ojb
030     */
031    public class IndirectCostRecoveryExclusionAccountDaoOjb extends PlatformAwareDaoBaseOjb implements IndirectCostRecoveryExclusionAccountDao {
032        private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(IndirectCostRecoveryExclusionAccountDaoOjb.class);
033    
034        public IndirectCostRecoveryExclusionAccountDaoOjb() {
035            super();
036        }
037    
038        /**
039         * @see org.kuali.kfs.coa.dataaccess.IndirectCostRecoveryExclusionAccountDao#getByPrimaryKey(java.lang.String, java.lang.String,
040         *      java.lang.String, java.lang.String)
041         */
042        public IndirectCostRecoveryExclusionAccount getByPrimaryKey(String chartOfAccountsCode, String accountNumber, String objectChartOfAccountsCode, String objectCode) {
043            LOG.debug("getByPrimaryKey() started");
044    
045            Criteria crit = new Criteria();
046            crit.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
047            crit.addEqualTo("accountNumber", accountNumber);
048            crit.addEqualTo("financialObjectChartOfAccountCode", objectChartOfAccountsCode);
049            crit.addEqualTo("financialObjectCode", objectCode);
050    
051            QueryByCriteria qbc = QueryFactory.newQuery(IndirectCostRecoveryExclusionAccount.class, crit);
052            return (IndirectCostRecoveryExclusionAccount) getPersistenceBrokerTemplate().getObjectByQuery(qbc);
053        }
054    
055        /**
056         * @see org.kuali.kfs.coa.dataaccess.IndirectCostRecoveryExclusionAccountDao#existByAccount(java.lang.String, java.lang.String)
057         */
058        public boolean existByAccount(String chartOfAccountsCode, String accountNumber) {
059            LOG.debug("existByAccount() started");
060    
061            Criteria crit = new Criteria();
062            crit.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
063            crit.addEqualTo("accountNumber", accountNumber);
064    
065            ReportQueryByCriteria q = QueryFactory.newReportQuery(IndirectCostRecoveryExclusionAccount.class, crit);
066            q.setAttributes(new String[] { "chartOfAccountsCode" });
067            q.setDistinct(true);
068    
069            Iterator iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(q);
070            return iter.hasNext();
071        }
072    
073    }