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.NegativeInvoiceApprovalLimit;
23 import org.kuali.ole.module.purap.document.dataaccess.NegativeInvoiceApprovalLimitDao;
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 NegativeInvoiceApprovalLimitDaoOjb extends PlatformAwareDaoBaseOjb implements NegativeInvoiceApprovalLimitDao {
37 private static Logger LOG = Logger.getLogger(NegativeInvoiceApprovalLimitDaoOjb.class);
38
39
40
41
42 public Collection<NegativeInvoiceApprovalLimit> 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(NegativeInvoiceApprovalLimit.class, criteria);
50 LOG.debug("Leaving findByChart(String)");
51
52 return getPersistenceBrokerTemplate().getCollectionByQuery(query);
53 }
54
55
56
57
58
59 public Collection<NegativeInvoiceApprovalLimit> 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(NegativeInvoiceApprovalLimit.class, criteria);
67 LOG.debug("Leaving findByChartAndAccount(String, String)");
68
69 return getPersistenceBrokerTemplate().getCollectionByQuery(query);
70 }
71
72
73
74
75
76 public Collection<NegativeInvoiceApprovalLimit> 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(NegativeInvoiceApprovalLimit.class, criteria);
84 LOG.debug("Leaving findByChartAndOrganization(String, String)");
85
86 return getPersistenceBrokerTemplate().getCollectionByQuery(query);
87 }
88
89
90
91
92 public Collection<NegativeInvoiceApprovalLimit> findAboveLimit(KualiDecimal limit) {
93 LOG.debug("Entering findAboveLimit(KualiDecimal)");
94 Criteria criteria = new Criteria();
95 criteria.addGreaterThan("negativeInvoiceApprovalLimitAmount", limit);
96 criteria.addAndCriteria(buildActiveCriteria());
97 Query query = new QueryByCriteria(NegativeInvoiceApprovalLimit.class, criteria);
98 LOG.debug("Leaving findAboveLimit(KualiDecimal)");
99
100 return getPersistenceBrokerTemplate().getCollectionByQuery(query);
101 }
102
103
104
105
106 public Collection<NegativeInvoiceApprovalLimit> findBelowLimit(KualiDecimal limit) {
107 LOG.debug("Entering findBelowLimit(KualiDecimal)");
108 Criteria criteria = new Criteria();
109 criteria.addLessThan("negativeInvoiceApprovalLimitAmount", limit);
110 criteria.addAndCriteria(buildActiveCriteria());
111 Query query = new QueryByCriteria(NegativeInvoiceApprovalLimit.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 }