View Javadoc
1   /*
2    * Copyright 2005 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 org.apache.ojb.broker.query.Criteria;
19  import org.apache.ojb.broker.query.QueryFactory;
20  import org.kuali.ole.coa.businessobject.Account;
21  import org.kuali.ole.coa.businessobject.SubFundGroup;
22  import org.kuali.ole.coa.dataaccess.SubFundGroupDao;
23  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
24  
25  /**
26   * This class implements the {@link SubFundGroupDao} data access methods using Ojb
27   */
28  public class SubFundGroupDaoOjb extends PlatformAwareDaoBaseOjb implements SubFundGroupDao {
29  
30      /**
31       * @see org.kuali.ole.coa.dataaccess.SubFundGroupDao#getByChartAndAccount(java.lang.String, java.lang.String)
32       */
33      public SubFundGroup getByChartAndAccount(String chartCode, String accountNumber) {
34          Criteria criteria = new Criteria();
35          criteria.addEqualTo("chartOfAccountsCode", chartCode);
36          criteria.addEqualTo("accountNumber", accountNumber);
37  
38          Account account = (Account) getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(Account.class, criteria));
39          criteria = new Criteria();
40          criteria.addEqualTo("subFundGroupCode", account.getSubFundGroupCode());
41  
42          return (SubFundGroup) getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(SubFundGroup.class, criteria));
43      }
44  
45  }