01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.chart.dao.ojb;
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.core.dao.ojb.PlatformAwareDaoBaseOjb;
25: import org.kuali.module.chart.bo.IndirectCostRecoveryExclusionAccount;
26: import org.kuali.module.chart.dao.IndirectCostRecoveryExclusionAccountDao;
27:
28: /**
29: * This class implements the {@link IndirectCostRecoveryExclusionAccountDao} data access methods using Ojb
30: */
31: public class IndirectCostRecoveryExclusionAccountDaoOjb extends
32: PlatformAwareDaoBaseOjb implements
33: IndirectCostRecoveryExclusionAccountDao {
34: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
35: .getLogger(IndirectCostRecoveryExclusionAccountDaoOjb.class);
36:
37: public IndirectCostRecoveryExclusionAccountDaoOjb() {
38: super ();
39: }
40:
41: /**
42: * @see org.kuali.module.chart.dao.IndirectCostRecoveryExclusionAccountDao#getByPrimaryKey(java.lang.String, java.lang.String,
43: * java.lang.String, java.lang.String)
44: */
45: public IndirectCostRecoveryExclusionAccount getByPrimaryKey(
46: String chartOfAccountsCode, String accountNumber,
47: String objectChartOfAccountsCode, String objectCode) {
48: LOG.debug("getByPrimaryKey() started");
49:
50: Criteria crit = new Criteria();
51: crit.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
52: crit.addEqualTo("accountNumber", accountNumber);
53: crit.addEqualTo("financialObjectChartOfAccountCode",
54: objectChartOfAccountsCode);
55: crit.addEqualTo("financialObjectCode", objectCode);
56:
57: QueryByCriteria qbc = QueryFactory.newQuery(
58: IndirectCostRecoveryExclusionAccount.class, crit);
59: return (IndirectCostRecoveryExclusionAccount) getPersistenceBrokerTemplate()
60: .getObjectByQuery(qbc);
61: }
62:
63: /**
64: * @see org.kuali.module.chart.dao.IndirectCostRecoveryExclusionAccountDao#existByAccount(java.lang.String, java.lang.String)
65: */
66: public boolean existByAccount(String chartOfAccountsCode,
67: String accountNumber) {
68: LOG.debug("existByAccount() started");
69:
70: Criteria crit = new Criteria();
71: crit.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
72: crit.addEqualTo("accountNumber", accountNumber);
73:
74: ReportQueryByCriteria q = QueryFactory.newReportQuery(
75: IndirectCostRecoveryExclusionAccount.class, crit);
76: q.setAttributes(new String[] { "chartOfAccountsCode" });
77: q.setDistinct(true);
78:
79: Iterator iter = getPersistenceBrokerTemplate()
80: .getReportQueryIteratorByQuery(q);
81: return iter.hasNext();
82: }
83:
84: }
|