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.CorrectionCriteria;
26: import org.kuali.module.gl.dao.CorrectionCriteriaDao;
27:
28: /**
29: * An OJB implementation of CorrectionCriteriaDao
30: */
31: public class CorrectionCriteriaDaoOjb extends PlatformAwareDaoBaseOjb
32: implements CorrectionCriteriaDao {
33: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
34: .getLogger(CorrectionCriteriaDaoOjb.class);
35:
36: /**
37: * Deletes a correction criterion
38: *
39: * @param criterion the criterion to delete
40: * @see org.kuali.module.gl.dao.CorrectionCriteriaDao#delete(org.kuali.module.gl.bo.CorrectionCriteria)
41: */
42: public void delete(CorrectionCriteria criterion) {
43: LOG.debug("delete() started");
44:
45: getPersistenceBrokerTemplate().delete(criterion);
46: }
47:
48: /**
49: * Queries the database for a list of all the correction criteria associated with the given GLCP document and correction group
50: *
51: * @param documentNumber the GLCP document number of correction criteria to find
52: * @param correctionGroupLineNumber the correction group of correction criteria to find
53: * @return a List of collection criteria
54: * @see org.kuali.module.gl.dao.CorrectionCriteriaDao#findByDocumentNumberAndCorrectionGroupNumber(java.lang.String,
55: * java.lang.Integer)
56: */
57: public List findByDocumentNumberAndCorrectionGroupNumber(
58: String documentNumber, Integer correctionGroupLineNumber) {
59: LOG
60: .debug("findByDocumentNumberAndCorrectionGroupNumber() started");
61:
62: Criteria criteria = new Criteria();
63: criteria.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER,
64: documentNumber);
65: criteria.addEqualTo("correctionChangeGroupLineNumber",
66: correctionGroupLineNumber);
67:
68: Class clazz = CorrectionCriteria.class;
69: QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
70:
71: List returnList = (List) getPersistenceBrokerTemplate()
72: .getCollectionByQuery(query);
73: return returnList;
74: }
75:
76: /**
77: * Saves a GLCP criterion
78: *
79: * @param criterion the criterion to save
80: */
81: public void save(CorrectionCriteria criterion) {
82: LOG.debug("save() started");
83:
84: getPersistenceBrokerTemplate().store(criterion);
85: }
86: }
|