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.gl.dataaccess.impl;
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.ole.gl.businessobject.CorrectionCriteria;
24 import org.kuali.ole.gl.dataaccess.CorrectionCriteriaDao;
25 import org.kuali.ole.sys.OLEPropertyConstants;
26 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
27
28 /**
29 * An OJB implementation of CorrectionCriteriaDao
30 */
31 public class CorrectionCriteriaDaoOjb extends PlatformAwareDaoBaseOjb implements CorrectionCriteriaDao {
32 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CorrectionCriteriaDaoOjb.class);
33
34 /**
35 * Deletes a correction criterion
36 *
37 * @param criterion the criterion to delete
38 * @see org.kuali.ole.gl.dataaccess.CorrectionCriteriaDao#delete(org.kuali.ole.gl.businessobject.CorrectionCriteria)
39 */
40 public void delete(CorrectionCriteria criterion) {
41 LOG.debug("delete() started");
42
43 getPersistenceBrokerTemplate().delete(criterion);
44 }
45
46 /**
47 * Queries the database for a list of all the correction criteria associated with the given GLCP document and correction group
48 *
49 * @param documentNumber the GLCP document number of correction criteria to find
50 * @param correctionGroupLineNumber the correction group of correction criteria to find
51 * @return a List of collection criteria
52 * @see org.kuali.ole.gl.dataaccess.CorrectionCriteriaDao#findByDocumentNumberAndCorrectionGroupNumber(java.lang.String,
53 * java.lang.Integer)
54 */
55 public List findByDocumentNumberAndCorrectionGroupNumber(String documentNumber, Integer correctionGroupLineNumber) {
56 LOG.debug("findByDocumentNumberAndCorrectionGroupNumber() started");
57
58 Criteria criteria = new Criteria();
59 criteria.addEqualTo(OLEPropertyConstants.DOCUMENT_NUMBER, documentNumber);
60 criteria.addEqualTo("correctionChangeGroupLineNumber", correctionGroupLineNumber);
61
62 Class clazz = CorrectionCriteria.class;
63 QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
64
65 List returnList = (List) getPersistenceBrokerTemplate().getCollectionByQuery(query);
66 return returnList;
67 }
68
69 }