1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
34
35 @Transactional
36 public class NegativePaymentRequestApprovalLimitDaoOjb extends PlatformAwareDaoBaseOjb implements NegativePaymentRequestApprovalLimitDao {
37 private static Logger LOG = Logger.getLogger(NegativePaymentRequestApprovalLimitDaoOjb.class);
38
39
40
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
57
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
74
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
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
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
119
120
121
122 protected Criteria buildActiveCriteria() {
123 Criteria criteria = new Criteria();
124 criteria.addEqualTo(KRADPropertyConstants.ACTIVE, true);
125
126 return criteria;
127 }
128 }