01: /*
02: * Copyright 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.labor.dao.ojb;
17:
18: import java.util.ArrayList;
19: import java.util.Collection;
20:
21: import org.apache.log4j.Logger;
22: import org.apache.ojb.broker.query.Criteria;
23: import org.apache.ojb.broker.query.Query;
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.kfs.bo.AccountingLine;
28: import org.kuali.kfs.dao.AccountingLineDao;
29: import org.kuali.module.chart.dao.ojb.ChartDaoOjb;
30: import org.springframework.dao.DataAccessException;
31:
32: /**
33: * This class is the OJB implementation of the AccountingLineDao interface.
34: */
35:
36: public class ExpenseTransferAccountingLineDaoOjb extends
37: PlatformAwareDaoBaseOjb implements AccountingLineDao {
38: private static Logger LOG = Logger.getLogger(ChartDaoOjb.class);
39:
40: /**
41: * Default constructor.
42: */
43: public ExpenseTransferAccountingLineDaoOjb() {
44: super ();
45: }
46:
47: /**
48: * Saves an accounting line to the DB using OJB.
49: *
50: * @param line
51: */
52: public void save(AccountingLine line) throws DataAccessException {
53: getPersistenceBrokerTemplate().store(line);
54: }
55:
56: /**
57: * Deletes an accounting line from the DB using OJB.
58: */
59: public void deleteAccountingLine(AccountingLine line)
60: throws DataAccessException {
61: getPersistenceBrokerTemplate().delete(line);
62: }
63:
64: /**
65: * Retrieves accounting lines associate with a given document header ID using OJB.
66: *
67: * @param classname
68: * @param id
69: * @return
70: */
71: public ArrayList findByDocumentHeaderId(Class clazz,
72: String documentHeaderId) throws DataAccessException {
73: Criteria criteria = new Criteria();
74: criteria.addEqualTo("FDOC_NBR", documentHeaderId);
75:
76: QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
77:
78: Collection lines = findCollection(query);
79:
80: return new ArrayList(lines);
81: }
82:
83: /**
84: * Retrieve a Collection of Document instances found by a query.
85: *
86: * @param query
87: * @return
88: */
89: private Collection findCollection(Query query)
90: throws DataAccessException {
91: return getPersistenceBrokerTemplate().getCollectionByQuery(
92: query);
93: }
94: }
|