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