View Javadoc
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.Collection;
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.CorrectionChangeGroup;
24  import org.kuali.ole.gl.dataaccess.CorrectionChangeGroupDao;
25  import org.kuali.ole.sys.OLEPropertyConstants;
26  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
27  
28  /**
29   * The OJB implementation of CorrectionChangeGroupDao
30   */
31  public class CorrectionChangeGroupDaoOjb extends PlatformAwareDaoBaseOjb implements CorrectionChangeGroupDao {
32      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CorrectionChangeGroupDaoOjb.class);
33  
34      /**
35       * Deletes an unlucky correction change group
36       * 
37       * @param group the group to delete
38       * @see org.kuali.ole.gl.dataaccess.CorrectionChangeGroupDao#delete(org.kuali.ole.gl.businessobject.CorrectionChangeGroup)
39       */
40      public void delete(CorrectionChangeGroup group) {
41          LOG.debug("delete() started");
42  
43          getPersistenceBrokerTemplate().delete(group);
44      }
45  
46      /**
47       * Finds all of the correction change groups associated with a document.
48       * 
49       * @param documentNumber the document number of a GLCP document
50       * @return a Collection of CorrectionChangeGroup records
51       * @see org.kuali.ole.gl.dataaccess.CorrectionChangeGroupDao#findByDocumentNumber(java.lang.String)
52       */
53      public Collection findByDocumentNumber(String documentNumber) {
54          Criteria criteria = new Criteria();
55          criteria.addEqualTo(OLEPropertyConstants.DOCUMENT_NUMBER, documentNumber);
56  
57          QueryByCriteria query = QueryFactory.newQuery(CorrectionChangeGroup.class, criteria);
58  
59          return getPersistenceBrokerTemplate().getCollectionByQuery(query);
60      }
61  
62      /**
63       * Finds the specific group associated with the given document with the given group number
64       * 
65       * @param documentNumber the document number of the correction change group to retrieve
66       * @param CorrectionChangeGroupNumber the number of the group to retrieve
67       * @return the found CorrectionChangeGroup, or null if not found
68       * @see org.kuali.ole.gl.dataaccess.CorrectionChangeGroupDao#findByDocumentNumberAndCorrectionChangeGroupNumber(java.lang.String,
69       *      java.lang.Integer)
70       */
71      public CorrectionChangeGroup findByDocumentNumberAndCorrectionChangeGroupNumber(String documentNumber, Integer CorrectionChangeGroupNumber) {
72          LOG.debug("findByDocumentNumberAndCorrectionChangeGroupNumber() started");
73  
74          Criteria criteria = new Criteria();
75          criteria.addEqualTo(OLEPropertyConstants.DOCUMENT_NUMBER, documentNumber);
76          criteria.addEqualTo("correctionChangeGroupLineNumber", CorrectionChangeGroupNumber);
77  
78          QueryByCriteria query = QueryFactory.newQuery(CorrectionChangeGroup.class, criteria);
79  
80          return (CorrectionChangeGroup) getPersistenceBrokerTemplate().getObjectByQuery(query);
81      }
82  }