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.util.RiceConstants;
20 import org.kuali.rice.core.framework.persistence.dao.GenericDao;
21 import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria;
22 import org.kuali.rice.ken.bo.NotificationMessageDelivery;
23 import org.kuali.rice.ken.dao.NotificationMessegeDeliveryDao;
24 import org.kuali.rice.ken.util.NotificationConstants;
25
26 import java.sql.Timestamp;
27 import java.util.Collection;
28
29
30
31
32
33
34
35 public class NotificationMessegeDeliveryDaoJpa implements NotificationMessegeDeliveryDao{
36
37 private static final Logger LOG = Logger.getLogger(NotificationDaoJpa.class);
38
39
40
41
42
43
44 @Override
45 public Collection getUndeliveredMessageDelivers(GenericDao businessObjectDao) {
46
47
48
49 Criteria criteria = new Criteria(NotificationMessageDelivery.class.getName());
50 criteria.eq(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED);
51 criteria.isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
52 Collection<NotificationMessageDelivery> messageDeliveries = businessObjectDao.findMatching(NotificationMessageDelivery.class, criteria, true, RiceConstants.NO_WAIT);
53
54 return messageDeliveries;
55 }
56
57
58
59
60
61
62 @Override
63 public Collection<NotificationMessageDelivery> getMessageDeliveriesForAutoRemoval(Timestamp tm, GenericDao businessObjectDao) {
64
65
66
67
68
69 Criteria criteria_STATUS = new Criteria(NotificationMessageDelivery.class.getName());
70 criteria_STATUS.eq(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.DELIVERED);
71
72 Criteria criteria_UNDELIVERED = new Criteria(NotificationMessageDelivery.class.getName());
73 criteria_UNDELIVERED.eq(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED);
74
75
76 criteria_STATUS.or(criteria_UNDELIVERED);
77
78 Criteria fullQueryCriteria = new Criteria(NotificationMessageDelivery.class.getName());
79 fullQueryCriteria.isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
80
81 fullQueryCriteria.lte(NotificationConstants.BO_PROPERTY_NAMES.NOTIFICATION_AUTO_REMOVE_DATE_TIME, new Timestamp(System.currentTimeMillis()));
82
83 fullQueryCriteria.and(criteria_STATUS);
84
85 Collection<NotificationMessageDelivery> messageDeliveries = businessObjectDao.findMatching(NotificationMessageDelivery.class, fullQueryCriteria, true, RiceConstants.NO_WAIT);
86
87 return messageDeliveries;
88 }
89
90
91
92
93
94
95 @Override
96 public Collection<NotificationMessageDelivery> getLockedDeliveries(
97 Class clazz, GenericDao dao) {
98 Criteria criteria = new Criteria(clazz.getName());
99 criteria.notNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
100 Collection<NotificationMessageDelivery> lockedDeliveries = dao.findMatching(clazz, criteria);
101 return null;
102 }
103
104
105 }