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.CorrectionChange;
024 import org.kuali.kfs.gl.dataaccess.CorrectionChangeDao;
025 import org.kuali.kfs.sys.KFSPropertyConstants;
026 import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
027
028 /**
029 * The OJB implementation of the CorrectionChangeDao
030 */
031 public class CorrectionChangeDaoOjb extends PlatformAwareDaoBaseOjb implements CorrectionChangeDao {
032 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CorrectionChangeDaoOjb.class);
033
034 /**
035 * Delete a CorrectionChange from the database
036 *
037 * @param spec the CorrectionChange to delete
038 * @see org.kuali.kfs.gl.dataaccess.CorrectionChangeDao#delete(org.kuali.kfs.gl.businessobject.CorrectionChange)
039 */
040 public void delete(CorrectionChange spec) {
041 LOG.debug("delete() started");
042
043 getPersistenceBrokerTemplate().delete(spec);
044 }
045
046 /**
047 * Query the database to find qualifying CorrectionChange records
048 *
049 * @param documentHeaderId the document number of a GLCP document
050 * @param correctionGroupLineNumber the line number of the group within the GLCP document to find correction chagnes for
051 * @return a List of correction changes
052 * @see org.kuali.kfs.gl.dataaccess.CorrectionChangeDao#findByDocumentHeaderIdAndCorrectionGroupNumber(java.lang.String,
053 * java.lang.Integer)
054 */
055 public List findByDocumentHeaderIdAndCorrectionGroupNumber(String documentNumber, Integer correctionGroupLineNumber) {
056 LOG.debug("findByDocumentHeaderIdAndCorrectionGroupNumber() started");
057
058 Criteria criteria = new Criteria();
059 criteria.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER, documentNumber);
060 criteria.addEqualTo("correctionChangeGroupLineNumber", correctionGroupLineNumber);
061
062 QueryByCriteria query = QueryFactory.newQuery(CorrectionChange.class, criteria);
063
064 return (List) getPersistenceBrokerTemplate().getCollectionByQuery(query);
065 }
066
067 /**
068 * Save a CorrectionChange to the database
069 *
070 * @param spec a CorrectionChange to save to the database
071 * @see org.kuali.kfs.gl.dataaccess.CorrectionChangeDao#save(org.kuali.kfs.gl.businessobject.CorrectionChange)
072 */
073 public void save(CorrectionChange spec) {
074 LOG.debug("save() started");
075
076 getPersistenceBrokerTemplate().store(spec);
077 }
078 }