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.List;
019
020 import org.apache.ojb.broker.query.Criteria;
021 import org.apache.ojb.broker.query.QueryFactory;
022 import org.kuali.kfs.coa.businessobject.SubAccount;
023 import org.kuali.kfs.coa.dataaccess.SubAccountDao;
024 import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
025
026
027 /**
028 * This class is the OJB implementation of the SubAccountDao interface.
029 */
030 public class SubAccountDaoOjb extends PlatformAwareDaoBaseOjb implements SubAccountDao {
031 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SubAccountDaoOjb.class);
032
033 /**
034 * Retrieves sub account business object by primary key
035 *
036 * @param chartOfAccountsCode - part of composite key
037 * @param accountNumber - part of composite key
038 * @param subAccountNumber - part of composite key
039 * @return SubAccount
040 * @see SubAccountDao#getByPrimaryId(String, String, String)
041 */
042 public SubAccount getByPrimaryId(String chartOfAccountsCode, String accountNumber, String subAccountNumber) {
043 Criteria criteria = new Criteria();
044 criteria.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
045 criteria.addEqualTo("accountNumber", accountNumber);
046 criteria.addEqualTo("subAccountNumber", subAccountNumber);
047
048 return (SubAccount) getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(SubAccount.class, criteria));
049 }
050
051 /**
052 * Retrieves SubAccount objects associated with the given chart-org-subAccount code combination
053 *
054 * @param chartOfAccountsCode - 'Reports To' Chart of Accounts Code
055 * @param organizationCode - 'Reports To' Organization Code
056 * @param subAccountNumber - Sub Account Number
057 * @return a list of SubAccount objects
058 * @see SubAccountDao#getSubAccountsByReportsToOrganization(String, String, String)
059 */
060 public List getSubAccountsByReportsToOrganization(String chartOfAccountsCode, String organizationCode, String subAccountNumber) {
061 Criteria criteria = new Criteria();
062 criteria.addEqualTo("financialReportChartCode", chartOfAccountsCode);
063 criteria.addEqualTo("finReportOrganizationCode", organizationCode);
064 criteria.addEqualTo("subAccountNumber", subAccountNumber);
065
066 return (List) getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(SubAccount.class, criteria));
067 }
068 }