01: /*
02: * Copyright 2006-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.financial.dao.ojb;
17:
18: import java.util.ArrayList;
19: import java.util.Collection;
20: import java.util.List;
21:
22: import org.apache.log4j.Logger;
23: import org.apache.ojb.broker.query.Criteria;
24: import org.apache.ojb.broker.query.QueryByCriteria;
25: import org.apache.ojb.broker.query.QueryFactory;
26: import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
27: import org.kuali.module.chart.dao.ojb.ChartDaoOjb;
28: import org.kuali.module.financial.bo.Check;
29: import org.kuali.module.financial.bo.CheckBase;
30: import org.kuali.module.financial.dao.CheckDao;
31: import org.springframework.dao.DataAccessException;
32:
33: /**
34: * This class is the OJB implementation of the AccountingLineDao interface.
35: */
36:
37: public class CheckDaoOjb extends PlatformAwareDaoBaseOjb implements
38: CheckDao {
39: private static Logger LOG = Logger.getLogger(ChartDaoOjb.class);
40:
41: /**
42: * Default constructor.
43: */
44: public CheckDaoOjb() {
45: super ();
46: }
47:
48: /**
49: * @see org.kuali.core.dao.CheckDao#save(org.kuali.module.financial.bo.Check)
50: */
51: public Check save(Check check) throws DataAccessException {
52: getPersistenceBrokerTemplate().store(check);
53:
54: return check;
55: }
56:
57: /**
58: * @param line
59: * @throws DataAccessException
60: */
61: public void deleteCheck(Check check) throws DataAccessException {
62: getPersistenceBrokerTemplate().delete(check);
63: }
64:
65: /**
66: * Retrieves accounting lines associate with a given document header ID using OJB.
67: *
68: * @param classname
69: * @param id
70: * @return
71: */
72: public List findByDocumentHeaderId(String documentHeaderId)
73: throws DataAccessException {
74: Criteria criteria = new Criteria();
75: criteria.addEqualTo("FDOC_NBR", documentHeaderId);
76:
77: QueryByCriteria query = QueryFactory.newQuery(CheckBase.class,
78: criteria);
79:
80: Collection lines = getPersistenceBrokerTemplate()
81: .getCollectionByQuery(query);
82:
83: return new ArrayList(lines);
84: }
85: }
|