View Javadoc
1   /*
2    * Copyright 2007 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.fp.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.kuali.ole.fp.dataaccess.DisbursementVoucherDao;
23  import org.kuali.ole.fp.document.DisbursementVoucherConstants;
24  import org.kuali.ole.fp.document.DisbursementVoucherDocument;
25  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
26  
27  public class DisbursementVoucherDaoOjb extends PlatformAwareDaoBaseOjb implements DisbursementVoucherDao {
28      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DisbursementVoucherDaoOjb.class);
29  
30      /**
31       * @see org.kuali.ole.fp.dataaccess.DisbursementVoucherDao#getDocument(java.lang.String)
32       */
33      @Override
34      public DisbursementVoucherDocument getDocument(String fdocNbr) {
35          LOG.debug("getDocument() started");
36  
37          Criteria criteria = new Criteria();
38          criteria.addEqualTo("documentNumber", fdocNbr);
39  
40          return (DisbursementVoucherDocument) getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(DisbursementVoucherDocument.class, criteria));
41      }
42  
43      /**
44       * @see org.kuali.ole.fp.dataaccess.DisbursementVoucherDao#getDocumentsByHeaderStatus(java.lang.String)
45       */
46      @Override
47      public Collection getDocumentsByHeaderStatus(String statusCode, boolean immediatesOnly) {
48          LOG.debug("getDocumentsByHeaderStatus() started");
49  
50          Criteria criteria = new Criteria();
51          criteria.addEqualTo("documentHeader.financialDocumentStatusCode", statusCode);
52          criteria.addEqualTo("disbVchrPaymentMethodCode", DisbursementVoucherConstants.PAYMENT_METHOD_CHECK);
53          if (immediatesOnly) {
54              criteria.addEqualTo("immediatePaymentIndicator", Boolean.TRUE);
55          }
56  
57          return getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(DisbursementVoucherDocument.class, criteria));
58      }
59  }
60