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 java.util.List;
19:
20: import org.apache.ojb.broker.query.Criteria;
21: import org.apache.ojb.broker.query.QueryFactory;
22: import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
23: import org.kuali.module.chart.bo.SubAccount;
24: import org.kuali.module.chart.dao.SubAccountDao;
25:
26: /**
27: * This class is the OJB implementation of the SubAccountDao interface.
28: */
29: public class SubAccountDaoOjb extends PlatformAwareDaoBaseOjb implements
30: SubAccountDao {
31: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
32: .getLogger(SubAccountDaoOjb.class);
33:
34: /**
35: * Retrieves sub account business object by primary key
36: *
37: * @param chartOfAccountsCode - part of composite key
38: * @param accountNumber - part of composite key
39: * @param subAccountNumber - part of composite key
40: * @return SubAccount
41: * @see SubAccountDao#getByPrimaryId(String, String, String)
42: */
43: public SubAccount getByPrimaryId(String chartOfAccountsCode,
44: String accountNumber, String subAccountNumber) {
45: Criteria criteria = new Criteria();
46: criteria.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
47: criteria.addEqualTo("accountNumber", accountNumber);
48: criteria.addEqualTo("subAccountNumber", subAccountNumber);
49:
50: return (SubAccount) getPersistenceBrokerTemplate()
51: .getObjectByQuery(
52: QueryFactory.newQuery(SubAccount.class,
53: criteria));
54: }
55:
56: /**
57: * Retrieves SubAccount objects associated with the given chart-org-subAccount code combination
58: *
59: * @param chartOfAccountsCode - 'Reports To' Chart of Accounts Code
60: * @param organizationCode - 'Reports To' Organization Code
61: * @param subAccountNumber - Sub Account Number
62: * @return a list of SubAccount objects
63: * @see SubAccountDao#getSubAccountsByReportsToOrganization(String, String, String)
64: */
65: public List getSubAccountsByReportsToOrganization(
66: String chartOfAccountsCode, String organizationCode,
67: String subAccountNumber) {
68: Criteria criteria = new Criteria();
69: criteria.addEqualTo("financialReportChartCode",
70: chartOfAccountsCode);
71: criteria.addEqualTo("finReportOrganizationCode",
72: organizationCode);
73: criteria.addEqualTo("subAccountNumber", subAccountNumber);
74:
75: return (List) getPersistenceBrokerTemplate()
76: .getCollectionByQuery(
77: QueryFactory.newQuery(SubAccount.class,
78: criteria));
79: }
80: }
|