1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.dao.impl;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.core.api.criteria.QueryByCriteria;
20 import org.kuali.rice.ken.bo.NotificationMessageDelivery;
21 import org.kuali.rice.ken.dao.NotificationMessegeDeliveryDao;
22 import org.kuali.rice.ken.util.NotificationConstants;
23 import org.kuali.rice.krad.data.DataObjectService;
24
25 import java.sql.Timestamp;
26 import java.util.Collection;
27
28 import static org.kuali.rice.core.api.criteria.PredicateFactory.*;
29
30
31
32
33
34
35
36 public class NotificationMessegeDeliveryDaoJpa implements NotificationMessegeDeliveryDao{
37
38 private static final Logger LOG = Logger.getLogger(NotificationMessegeDeliveryDaoJpa.class);
39
40
41
42
43
44
45 @Override
46 public Collection getUndeliveredMessageDelivers(DataObjectService dataObjectService) {
47
48
49
50 QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
51 criteria.setPredicates(
52 equal(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED),
53 isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE)
54 );
55
56 return dataObjectService.findMatching(NotificationMessageDelivery.class, criteria.build()).getResults();
57 }
58
59
60
61
62
63
64 @Override
65 public Collection<NotificationMessageDelivery> getMessageDeliveriesForAutoRemoval(Timestamp tm, DataObjectService dataObjectService) {
66
67
68
69
70 QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
71 criteria.setPredicates(
72 and(
73 or(
74 equal(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.DELIVERED),
75 equal(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED)
76 ),
77 isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE),
78 lessThanOrEqual(NotificationConstants.BO_PROPERTY_NAMES.NOTIFICATION_AUTO_REMOVE_DATE_TIME, new Timestamp(System.currentTimeMillis()))
79 )
80 );
81
82 Collection<NotificationMessageDelivery> messageDeliveries = dataObjectService.findMatching(NotificationMessageDelivery.class, criteria.build()).getResults();
83
84 return messageDeliveries;
85 }
86
87
88
89
90
91
92 @Override
93 public Collection<NotificationMessageDelivery> getLockedDeliveries(Class clazz, DataObjectService dataObjectService) {
94 QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
95 criteria.setPredicates(isNotNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE));
96 return dataObjectService.findMatching(clazz, criteria.build()).getResults();
97 }
98
99
100 }