01: /*
02: * Copyright 2005-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 org.apache.ojb.broker.query.Criteria;
19: import org.apache.ojb.broker.query.QueryFactory;
20: import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
21: import org.kuali.module.chart.bo.Account;
22: import org.kuali.module.chart.bo.SubFundGroup;
23: import org.kuali.module.chart.dao.SubFundGroupDao;
24:
25: /**
26: * This class implements the {@link SubFundGroupDao} data access methods using Ojb
27: */
28: public class SubFundGroupDaoOjb extends PlatformAwareDaoBaseOjb
29: implements SubFundGroupDao {
30:
31: /**
32: * @see org.kuali.module.chart.dao.SubFundGroupDao#getByPrimaryId(java.lang.String)
33: */
34: public SubFundGroup getByPrimaryId(String subFundGroupCode) {
35: Criteria criteria = new Criteria();
36: criteria.addEqualTo("subFundGroupCode", subFundGroupCode);
37:
38: return (SubFundGroup) getPersistenceBrokerTemplate()
39: .getObjectByQuery(
40: QueryFactory.newQuery(SubFundGroup.class,
41: criteria));
42: }
43:
44: /**
45: * @see org.kuali.module.chart.dao.SubFundGroupDao#getByChartAndAccount(java.lang.String, java.lang.String)
46: */
47: public SubFundGroup getByChartAndAccount(String chartCode,
48: String accountNumber) {
49: Criteria criteria = new Criteria();
50: criteria.addEqualTo("chartOfAccountsCode", chartCode);
51: criteria.addEqualTo("accountNumber", accountNumber);
52:
53: Account account = (Account) getPersistenceBrokerTemplate()
54: .getObjectByQuery(
55: QueryFactory.newQuery(Account.class, criteria));
56: criteria = new Criteria();
57: criteria.addEqualTo("subFundGroupCode", account
58: .getSubFundGroupCode());
59:
60: return (SubFundGroup) getPersistenceBrokerTemplate()
61: .getObjectByQuery(
62: QueryFactory.newQuery(SubFundGroup.class,
63: criteria));
64: }
65:
66: }
|