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.Collection;
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.CorrectionChangeGroup;
024 import org.kuali.kfs.gl.dataaccess.CorrectionChangeGroupDao;
025 import org.kuali.kfs.sys.KFSPropertyConstants;
026 import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
027
028 /**
029 * The OJB implementation of CorrectionChangeGroupDao
030 */
031 public class CorrectionChangeGroupDaoOjb extends PlatformAwareDaoBaseOjb implements CorrectionChangeGroupDao {
032 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CorrectionChangeGroupDaoOjb.class);
033
034 /**
035 * Deletes an unlucky correction change group
036 *
037 * @param group the group to delete
038 * @see org.kuali.kfs.gl.dataaccess.CorrectionChangeGroupDao#delete(org.kuali.kfs.gl.businessobject.CorrectionChangeGroup)
039 */
040 public void delete(CorrectionChangeGroup group) {
041 LOG.debug("delete() started");
042
043 getPersistenceBrokerTemplate().delete(group);
044 }
045
046 /**
047 * Finds all of the correction change groups associated with a document.
048 *
049 * @param documentNumber the document number of a GLCP document
050 * @return a Collection of CorrectionChangeGroup records
051 * @see org.kuali.kfs.gl.dataaccess.CorrectionChangeGroupDao#findByDocumentNumber(java.lang.String)
052 */
053 public Collection findByDocumentNumber(String documentNumber) {
054 Criteria criteria = new Criteria();
055 criteria.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER, documentNumber);
056
057 QueryByCriteria query = QueryFactory.newQuery(CorrectionChangeGroup.class, criteria);
058
059 return getPersistenceBrokerTemplate().getCollectionByQuery(query);
060 }
061
062 /**
063 * Finds the specific group associated with the given document with the given group number
064 *
065 * @param documentNumber the document number of the correction change group to retrieve
066 * @param CorrectionChangeGroupNumber the number of the group to retrieve
067 * @return the found CorrectionChangeGroup, or null if not found
068 * @see org.kuali.kfs.gl.dataaccess.CorrectionChangeGroupDao#findByDocumentNumberAndCorrectionChangeGroupNumber(java.lang.String,
069 * java.lang.Integer)
070 */
071 public CorrectionChangeGroup findByDocumentNumberAndCorrectionChangeGroupNumber(String documentNumber, Integer CorrectionChangeGroupNumber) {
072 LOG.debug("findByDocumentNumberAndCorrectionChangeGroupNumber() started");
073
074 Criteria criteria = new Criteria();
075 criteria.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER, documentNumber);
076 criteria.addEqualTo("correctionChangeGroupLineNumber", CorrectionChangeGroupNumber);
077
078 QueryByCriteria query = QueryFactory.newQuery(CorrectionChangeGroup.class, criteria);
079
080 return (CorrectionChangeGroup) getPersistenceBrokerTemplate().getObjectByQuery(query);
081 }
082
083 /**
084 * Saves a correction change group
085 *
086 * @param group the Correction Change Group to save
087 * @see org.kuali.kfs.gl.dataaccess.CorrectionChangeGroupDao#save(org.kuali.kfs.gl.businessobject.CorrectionChangeGroup)
088 */
089 public void save(CorrectionChangeGroup group) {
090 LOG.debug("save() started");
091
092 getPersistenceBrokerTemplate().store(group);
093 }
094 }