1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.pdp.dataaccess.impl;
17
18 import java.math.BigDecimal;
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22
23 import org.apache.ojb.broker.query.Criteria;
24 import org.apache.ojb.broker.query.QueryByCriteria;
25 import org.apache.ojb.broker.query.QueryFactory;
26 import org.apache.ojb.broker.query.ReportQueryByCriteria;
27 import org.kuali.ole.pdp.PdpConstants;
28 import org.kuali.ole.pdp.PdpPropertyConstants;
29 import org.kuali.ole.pdp.businessobject.PaymentGroup;
30 import org.kuali.ole.pdp.dataaccess.PaymentGroupDao;
31 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
32
33 public class PaymentGroupDaoOjb extends PlatformAwareDaoBaseOjb implements PaymentGroupDao {
34 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PaymentGroupDaoOjb.class);
35
36
37 public PaymentGroupDaoOjb() {
38 super();
39 }
40
41
42
43
44 public List<Integer> getDisbursementNumbersByDisbursementType(Integer pid,String disbursementType) {
45 LOG.debug("getDisbursementNumbersByDisbursementType() started");
46
47 List<Integer> results = new ArrayList<Integer>();
48
49 Criteria criteria = new Criteria();
50 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PROCESS_ID, pid);
51 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, disbursementType);
52
53 String[] fields = new String[] { PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR };
54
55 ReportQueryByCriteria rq = QueryFactory.newReportQuery(PaymentGroup.class, fields, criteria, true);
56 rq.addOrderBy(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR, true);
57
58 Iterator i = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rq);
59 while ( i.hasNext() ) {
60 Object[] data = (Object[])i.next();
61 BigDecimal d = (BigDecimal)data[0];
62 results.add( new Integer(d.intValue()) );
63 }
64 return results;
65 }
66
67
68
69
70 public List<Integer> getDisbursementNumbersByDisbursementTypeAndBankCode(Integer pid, String disbursementType, String bankCode) {
71 if (LOG.isDebugEnabled()) {
72 LOG.debug("getDisbursementNumbersByDisbursementType() started");
73 }
74
75 List<Integer> results = new ArrayList<Integer>();
76
77 Criteria criteria = new Criteria();
78 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PROCESS_ID, pid);
79 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, disbursementType);
80 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, bankCode);
81
82 String[] fields = new String[] { PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR };
83
84 ReportQueryByCriteria rq = QueryFactory.newReportQuery(PaymentGroup.class, fields, criteria, true);
85 rq.addOrderBy(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR, true);
86
87 Iterator i = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rq);
88 while ( i.hasNext() ) {
89 Object[] data = (Object[])i.next();
90 BigDecimal d = (BigDecimal)data[0];
91 results.add( new Integer(d.intValue()) );
92 }
93 return results;
94 }
95
96
97
98
99
100
101
102 public List<String> getDistinctBankCodesForProcessAndType(Integer pid, String disbursementType) {
103 List<String> results = new ArrayList<String>();
104
105 Criteria criteria = new Criteria();
106 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PROCESS_ID, pid);
107 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, disbursementType);
108
109 String[] fields = new String[] { PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE };
110
111 ReportQueryByCriteria rq = QueryFactory.newReportQuery(PaymentGroup.class, fields, criteria, true);
112 rq.addOrderBy(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, true);
113
114 Iterator iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rq);
115 while (iter.hasNext()) {
116 final Object[] row = (Object[])iter.next();
117 final String bankCode = (String)row[0];
118
119 results.add(bankCode);
120 }
121
122 return results;
123 }
124
125
126
127
128 public List<PaymentGroup> getAchPaymentsNeedingAdviceNotification() {
129 LOG.debug("getAchPaymentsNeedingAdviceNotification() started");
130
131 Criteria criteria = new Criteria();
132 criteria.addEqualTo(PdpPropertyConstants.PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.EXTRACTED);
133 criteria.addEqualTo(PdpPropertyConstants.DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
134 criteria.addIsNull(PdpPropertyConstants.ADVICE_EMAIL_SENT_DATE);
135
136 return (List<PaymentGroup>) getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(PaymentGroup.class, criteria));
137 }
138
139 }
140