001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.gl.dataaccess.impl;
017
018 import java.util.List;
019
020 import org.apache.ojb.broker.query.Criteria;
021 import org.apache.ojb.broker.query.QueryByCriteria;
022 import org.apache.ojb.broker.query.QueryFactory;
023 import org.kuali.kfs.gl.businessobject.CorrectionCriteria;
024 import org.kuali.kfs.gl.dataaccess.CorrectionCriteriaDao;
025 import org.kuali.kfs.sys.KFSPropertyConstants;
026 import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
027
028 /**
029 * An OJB implementation of CorrectionCriteriaDao
030 */
031 public class CorrectionCriteriaDaoOjb extends PlatformAwareDaoBaseOjb implements CorrectionCriteriaDao {
032 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CorrectionCriteriaDaoOjb.class);
033
034 /**
035 * Deletes a correction criterion
036 *
037 * @param criterion the criterion to delete
038 * @see org.kuali.kfs.gl.dataaccess.CorrectionCriteriaDao#delete(org.kuali.kfs.gl.businessobject.CorrectionCriteria)
039 */
040 public void delete(CorrectionCriteria criterion) {
041 LOG.debug("delete() started");
042
043 getPersistenceBrokerTemplate().delete(criterion);
044 }
045
046 /**
047 * Queries the database for a list of all the correction criteria associated with the given GLCP document and correction group
048 *
049 * @param documentNumber the GLCP document number of correction criteria to find
050 * @param correctionGroupLineNumber the correction group of correction criteria to find
051 * @return a List of collection criteria
052 * @see org.kuali.kfs.gl.dataaccess.CorrectionCriteriaDao#findByDocumentNumberAndCorrectionGroupNumber(java.lang.String,
053 * java.lang.Integer)
054 */
055 public List findByDocumentNumberAndCorrectionGroupNumber(String documentNumber, Integer correctionGroupLineNumber) {
056 LOG.debug("findByDocumentNumberAndCorrectionGroupNumber() started");
057
058 Criteria criteria = new Criteria();
059 criteria.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER, documentNumber);
060 criteria.addEqualTo("correctionChangeGroupLineNumber", correctionGroupLineNumber);
061
062 Class clazz = CorrectionCriteria.class;
063 QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
064
065 List returnList = (List) getPersistenceBrokerTemplate().getCollectionByQuery(query);
066 return returnList;
067 }
068
069 /**
070 * Saves a GLCP criterion
071 *
072 * @param criterion the criterion to save
073 */
074 public void save(CorrectionCriteria criterion) {
075 LOG.debug("save() started");
076
077 getPersistenceBrokerTemplate().store(criterion);
078 }
079 }