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.sql.Timestamp;
19 import java.util.Iterator;
20 import java.util.List;
21
22 import org.apache.ojb.broker.query.Criteria;
23 import org.apache.ojb.broker.query.QueryByCriteria;
24 import org.kuali.ole.pdp.PdpConstants;
25 import org.kuali.ole.pdp.PdpPropertyConstants;
26 import org.kuali.ole.pdp.businessobject.PaymentGroup;
27 import org.kuali.ole.pdp.businessobject.PaymentProcess;
28 import org.kuali.ole.pdp.dataaccess.FormatPaymentDao;
29 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
30 import org.kuali.rice.krad.service.BusinessObjectService;
31
32 public class FormatPaymentDaoOjb extends PlatformAwareDaoBaseOjb implements FormatPaymentDao {
33 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(FormatPaymentDaoOjb.class);
34
35 private BusinessObjectService businessObjectService;
36
37
38
39
40
41 public Iterator markPaymentsForFormat(List customerIds, Timestamp paydateTs, String paymentTypes) {
42 LOG.debug("markPaymentsForFormat() started");
43
44 Criteria criteria = new Criteria();
45
46 if (customerIds.size() > 0) {
47 criteria.addIn(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BATCH + "." + PdpPropertyConstants.BatchConstants.CUSTOMER_ID, customerIds);
48 }
49
50 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.OPEN);
51
52 if (PdpConstants.PaymentTypes.DISBURSEMENTS_WITH_SPECIAL_HANDLING.equals(paymentTypes)) {
53
54 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_SPECIAL_HANDLING, Boolean.TRUE);
55 }
56 else if (PdpConstants.PaymentTypes.DISBURSEMENTS_NO_SPECIAL_HANDLING.equals(paymentTypes)) {
57
58 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_SPECIAL_HANDLING, Boolean.FALSE);
59 }
60 else if (PdpConstants.PaymentTypes.DISBURSEMENTS_WITH_ATTACHMENTS.equals(paymentTypes)) {
61
62 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_ATTACHMENT, Boolean.TRUE);
63 }
64 else if (PdpConstants.PaymentTypes.DISBURSEMENTS_NO_ATTACHMENTS.equals(paymentTypes)) {
65
66 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_ATTACHMENT, Boolean.FALSE);
67 }
68
69 if (PdpConstants.PaymentTypes.PROCESS_IMMEDIATE.equals(paymentTypes)) {
70 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PROCESS_IMMEDIATE, Boolean.TRUE);
71 }
72 else {
73
74 Criteria criteria1 = new Criteria();
75 criteria1.addEqualTo(PdpPropertyConstants.PaymentGroup.PROCESS_IMMEDIATE, Boolean.TRUE);
76
77 Criteria criteria2 = new Criteria();
78 criteria2.addLessOrEqualThan(PdpPropertyConstants.PaymentGroup.PAYMENT_DATE, paydateTs);
79 criteria1.addOrCriteria(criteria2);
80
81 criteria.addAndCriteria(criteria1);
82 }
83
84 Iterator groupIterator = getPersistenceBrokerTemplate().getIteratorByQuery(new QueryByCriteria(PaymentGroup.class, criteria));
85 return groupIterator;
86 }
87
88
89
90
91 public Iterator unmarkPaymentsForFormat(PaymentProcess proc) {
92 LOG.debug("unmarkPaymentsForFormat() started");
93
94 Criteria criteria = new Criteria();
95 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PROCESS_ID, proc.getId());
96 criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.FORMAT);
97
98 Iterator groupIterator = getPersistenceBrokerTemplate().getIteratorByQuery(new QueryByCriteria(PaymentGroup.class, criteria));
99 return groupIterator;
100 }
101
102
103
104
105
106
107 public BusinessObjectService getBusinessObjectService() {
108 return businessObjectService;
109 }
110
111
112
113
114
115
116 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
117 this.businessObjectService = businessObjectService;
118 }
119
120 }