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.module.purap.document.dataaccess.impl;
17  
18  import org.apache.log4j.Logger;
19  import org.apache.ojb.broker.query.Criteria;
20  import org.apache.ojb.broker.query.Query;
21  import org.apache.ojb.broker.query.QueryByCriteria;
22  import org.kuali.ole.module.purap.businessobject.NegativePaymentRequestApprovalLimit;
23  import org.kuali.ole.module.purap.document.dataaccess.NegativePaymentRequestApprovalLimitDao;
24  import org.kuali.ole.sys.OLEPropertyConstants;
25  import org.kuali.rice.core.api.util.type.KualiDecimal;
26  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
27  import org.kuali.rice.krad.util.KRADPropertyConstants;
28  import org.springframework.transaction.annotation.Transactional;
29  
30  import java.util.Collection;
31  
32  /**
33   * OJB Implementation of NegativePaymentRequestApprovalLimitDao.
34   */
35  @Transactional
36  public class NegativePaymentRequestApprovalLimitDaoOjb extends PlatformAwareDaoBaseOjb implements NegativePaymentRequestApprovalLimitDao {
37      private static Logger LOG = Logger.getLogger(NegativePaymentRequestApprovalLimitDaoOjb.class);
38  
39      /**
40       * @see org.kuali.ole.module.purap.document.dataaccess.NegativePaymentRequestApprovalLimitDao#findByChart(java.lang.String)
41       */
42      public Collection<NegativePaymentRequestApprovalLimit> findByChart(String chartCode) {
43          LOG.debug("Entering findByChart(String)");
44          Criteria criteria = new Criteria();
45          criteria.addEqualTo(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
46          criteria.addIsNull(OLEPropertyConstants.ORGANIZATION_CODE);
47          criteria.addIsNull(OLEPropertyConstants.ACCOUNT_NUMBER);
48          criteria.addAndCriteria(buildActiveCriteria());
49          Query query = new QueryByCriteria(NegativePaymentRequestApprovalLimit.class, criteria);
50          LOG.debug("Leaving findByChart(String)");
51  
52          return getPersistenceBrokerTemplate().getCollectionByQuery(query);
53      }
54  
55      /**
56       * @see org.kuali.ole.module.purap.document.dataaccess.NegativePaymentRequestApprovalLimitDao#findByChartAndAccount(java.lang.String,
57       *      java.lang.String)
58       */
59      public Collection<NegativePaymentRequestApprovalLimit> findByChartAndAccount(String chartCode, String accountNumber) {
60          LOG.debug("Entering findByChartAndAccount(String, String)");
61          Criteria criteria = new Criteria();
62          criteria.addEqualTo(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
63          criteria.addEqualTo(OLEPropertyConstants.ACCOUNT_NUMBER, accountNumber);
64          criteria.addIsNull(OLEPropertyConstants.ORGANIZATION_CODE);
65          criteria.addAndCriteria(buildActiveCriteria());
66          Query query = new QueryByCriteria(NegativePaymentRequestApprovalLimit.class, criteria);
67          LOG.debug("Leaving findByChartAndAccount(String, String)");
68  
69          return getPersistenceBrokerTemplate().getCollectionByQuery(query);
70      }
71  
72      /**
73       * @see org.kuali.ole.module.purap.document.dataaccess.NegativePaymentRequestApprovalLimitDao#findByChartAndOrganization(java.lang.String,
74       *      java.lang.String)
75       */
76      public Collection<NegativePaymentRequestApprovalLimit> findByChartAndOrganization(String chartCode, String organizationCode) {
77          LOG.debug("Entering findByChartAndOrganization(String, String)");
78          Criteria criteria = new Criteria();
79          criteria.addEqualTo(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
80          criteria.addEqualTo(OLEPropertyConstants.ORGANIZATION_CODE, organizationCode);
81          criteria.addIsNull(OLEPropertyConstants.ACCOUNT_NUMBER);
82          criteria.addAndCriteria(buildActiveCriteria());
83          Query query = new QueryByCriteria(NegativePaymentRequestApprovalLimit.class, criteria);
84          LOG.debug("Leaving findByChartAndOrganization(String, String)");
85  
86          return getPersistenceBrokerTemplate().getCollectionByQuery(query);
87      }
88  
89      /**
90       * @see org.kuali.ole.module.purap.document.dataaccess.NegativePaymentRequestApprovalLimitDao#findAboveLimit(org.kuali.rice.core.api.util.type.KualiDecimal)
91       */
92      public Collection<NegativePaymentRequestApprovalLimit> findAboveLimit(KualiDecimal limit) {
93          LOG.debug("Entering findAboveLimit(KualiDecimal)");
94          Criteria criteria = new Criteria();
95          criteria.addGreaterThan("negativePaymentRequestApprovalLimitAmount", limit);
96          criteria.addAndCriteria(buildActiveCriteria());
97          Query query = new QueryByCriteria(NegativePaymentRequestApprovalLimit.class, criteria);
98          LOG.debug("Leaving findAboveLimit(KualiDecimal)");
99  
100         return getPersistenceBrokerTemplate().getCollectionByQuery(query);
101     }
102 
103     /**
104      * @see org.kuali.ole.module.purap.document.dataaccess.NegativePaymentRequestApprovalLimitDao#findBelowLimit(org.kuali.rice.core.api.util.type.KualiDecimal)
105      */
106     public Collection<NegativePaymentRequestApprovalLimit> findBelowLimit(KualiDecimal limit) {
107         LOG.debug("Entering findBelowLimit(KualiDecimal)");
108         Criteria criteria = new Criteria();
109         criteria.addLessThan("negativePaymentRequestApprovalLimitAmount", limit);
110         criteria.addAndCriteria(buildActiveCriteria());
111         Query query = new QueryByCriteria(NegativePaymentRequestApprovalLimit.class, criteria);
112         LOG.debug("Leaving findBelowLimit(KualiDecimal)");
113 
114         return getPersistenceBrokerTemplate().getCollectionByQuery(query);
115     }
116 
117     /**
118      * Builds a Criteria object for activeIndicator field set to true
119      *
120      * @return Criteria
121      */
122     protected Criteria buildActiveCriteria() {
123         Criteria criteria = new Criteria();
124         criteria.addEqualTo(KRADPropertyConstants.ACTIVE, true);
125 
126         return criteria;
127     }
128 }