View Javadoc
1   /*
2    * Copyright 2006 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.fp.dataaccess.impl;
17  
18  import java.util.Collection;
19  
20  import org.apache.log4j.Logger;
21  import org.apache.ojb.broker.query.Criteria;
22  import org.apache.ojb.broker.query.QueryByCriteria;
23  import org.apache.ojb.broker.query.QueryFactory;
24  import org.kuali.ole.fp.businessobject.Check;
25  import org.kuali.ole.fp.businessobject.CheckBase;
26  import org.kuali.ole.fp.dataaccess.CheckDao;
27  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
28  import org.springframework.dao.DataAccessException;
29  
30  /**
31   * This class is the OJB implementation of the AccountingLineDao interface.
32   */
33  
34  public class CheckDaoOjb extends PlatformAwareDaoBaseOjb implements CheckDao {
35      private static final Logger LOG = Logger.getLogger(CheckDaoOjb.class);
36  
37      /**
38       * @param line
39       * @throws DataAccessException
40       */
41      public void deleteCheck(Check check) throws DataAccessException {
42          getPersistenceBrokerTemplate().delete(check);
43      }
44  
45      /**
46       * Retrieves accounting lines associate with a given document header ID using OJB.
47       * 
48       * @param classname
49       * @param id
50       * @return
51       */
52      public Collection<CheckBase> findByDocumentHeaderId(String documentHeaderId) throws DataAccessException {
53          Criteria criteria = new Criteria();
54          criteria.addEqualTo("FDOC_NBR", documentHeaderId);
55  
56          QueryByCriteria query = QueryFactory.newQuery(CheckBase.class, criteria);
57  
58          Collection<CheckBase> lines = getPersistenceBrokerTemplate().getCollectionByQuery(query);
59  
60          return lines;
61      }
62  }