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.gl.dao.ojb;
17:
18: import java.util.List;
19:
20: import org.apache.ojb.broker.query.Criteria;
21: import org.apache.ojb.broker.query.QueryByCriteria;
22: import org.apache.ojb.broker.query.QueryFactory;
23: import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
24: import org.kuali.kfs.KFSPropertyConstants;
25: import org.kuali.module.gl.bo.CorrectionChange;
26: import org.kuali.module.gl.dao.CorrectionChangeDao;
27:
28: /**
29: * The OJB implementation of the CorrectionChangeDao
30: */
31: public class CorrectionChangeDaoOjb extends PlatformAwareDaoBaseOjb
32: implements CorrectionChangeDao {
33: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
34: .getLogger(CorrectionChangeDaoOjb.class);
35:
36: /**
37: * Delete a CorrectionChange from the database
38: *
39: * @param spec the CorrectionChange to delete
40: * @see org.kuali.module.gl.dao.CorrectionChangeDao#delete(org.kuali.module.gl.bo.CorrectionChange)
41: */
42: public void delete(CorrectionChange spec) {
43: LOG.debug("delete() started");
44:
45: getPersistenceBrokerTemplate().delete(spec);
46: }
47:
48: /**
49: * Query the database to find qualifying CorrectionChange records
50: *
51: * @param documentHeaderId the document number of a GLCP document
52: * @param correctionGroupLineNumber the line number of the group within the GLCP document to find correction chagnes for
53: * @return a List of correction changes
54: * @see org.kuali.module.gl.dao.CorrectionChangeDao#findByDocumentHeaderIdAndCorrectionGroupNumber(java.lang.String,
55: * java.lang.Integer)
56: */
57: public List findByDocumentHeaderIdAndCorrectionGroupNumber(
58: String documentNumber, Integer correctionGroupLineNumber) {
59: LOG
60: .debug("findByDocumentHeaderIdAndCorrectionGroupNumber() started");
61:
62: Criteria criteria = new Criteria();
63: criteria.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER,
64: documentNumber);
65: criteria.addEqualTo("correctionChangeGroupLineNumber",
66: correctionGroupLineNumber);
67:
68: QueryByCriteria query = QueryFactory.newQuery(
69: CorrectionChange.class, criteria);
70:
71: return (List) getPersistenceBrokerTemplate()
72: .getCollectionByQuery(query);
73: }
74:
75: /**
76: * Save a CorrectionChange to the database
77: *
78: * @param spec a CorrectionChange to save to the database
79: * @see org.kuali.module.gl.dao.CorrectionChangeDao#save(org.kuali.module.gl.bo.CorrectionChange)
80: */
81: public void save(CorrectionChange spec) {
82: LOG.debug("save() started");
83:
84: getPersistenceBrokerTemplate().store(spec);
85: }
86: }
|