View Javadoc
1   /*
2    * Copyright 2006 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.coa.dataaccess.impl;
17  
18  import java.util.Iterator;
19  
20  import org.apache.ojb.broker.query.Criteria;
21  import org.apache.ojb.broker.query.QueryByCriteria;
22  import org.apache.ojb.broker.query.QueryFactory;
23  import org.apache.ojb.broker.query.ReportQueryByCriteria;
24  import org.kuali.ole.coa.businessobject.IndirectCostRecoveryExclusionAccount;
25  import org.kuali.ole.coa.dataaccess.IndirectCostRecoveryExclusionAccountDao;
26  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
27  
28  /**
29   * This class implements the {@link IndirectCostRecoveryExclusionAccountDao} data access methods using Ojb
30   */
31  public class IndirectCostRecoveryExclusionAccountDaoOjb extends PlatformAwareDaoBaseOjb implements IndirectCostRecoveryExclusionAccountDao {
32      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(IndirectCostRecoveryExclusionAccountDaoOjb.class);
33  
34      public IndirectCostRecoveryExclusionAccountDaoOjb() {
35          super();
36      }
37  
38      /**
39       * @see org.kuali.ole.coa.dataaccess.IndirectCostRecoveryExclusionAccountDao#getByPrimaryKey(java.lang.String, java.lang.String,
40       *      java.lang.String, java.lang.String)
41       */
42      public IndirectCostRecoveryExclusionAccount getByPrimaryKey(String chartOfAccountsCode, String accountNumber, String objectChartOfAccountsCode, String objectCode) {
43          LOG.debug("getByPrimaryKey() started");
44  
45          Criteria crit = new Criteria();
46          crit.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
47          crit.addEqualTo("accountNumber", accountNumber);
48          crit.addEqualTo("financialObjectChartOfAccountCode", objectChartOfAccountsCode);
49          crit.addEqualTo("financialObjectCode", objectCode);
50  
51          QueryByCriteria qbc = QueryFactory.newQuery(IndirectCostRecoveryExclusionAccount.class, crit);
52          return (IndirectCostRecoveryExclusionAccount) getPersistenceBrokerTemplate().getObjectByQuery(qbc);
53      }
54  
55      /**
56       * @see org.kuali.ole.coa.dataaccess.IndirectCostRecoveryExclusionAccountDao#existByAccount(java.lang.String, java.lang.String)
57       */
58      public boolean existByAccount(String chartOfAccountsCode, String accountNumber) {
59          LOG.debug("existByAccount() started");
60  
61          Criteria crit = new Criteria();
62          crit.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
63          crit.addEqualTo("accountNumber", accountNumber);
64  
65          ReportQueryByCriteria q = QueryFactory.newReportQuery(IndirectCostRecoveryExclusionAccount.class, crit);
66          q.setAttributes(new String[] { "chartOfAccountsCode" });
67          q.setDistinct(true);
68  
69          Iterator iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(q);
70          return iter.hasNext();
71      }
72  
73  }