1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.ken.dao.impl;
18
19 import org.apache.log4j.Logger;
20 import org.apache.ojb.broker.query.Criteria;
21 import org.kuali.rice.core.api.util.RiceConstants;
22 import org.kuali.rice.core.framework.persistence.dao.GenericDao;
23 import org.kuali.rice.ken.bo.NotificationMessageDelivery;
24 import org.kuali.rice.ken.dao.NotificationMessegeDeliveryDao;
25 import org.kuali.rice.ken.util.NotificationConstants;
26 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
27
28 import java.sql.Timestamp;
29 import java.util.Collection;
30
31
32
33
34
35
36
37 public class NotificationMessegeDeliveryDaoOjb extends PersistenceBrokerDaoSupport implements
38 NotificationMessegeDeliveryDao {
39
40 private static final Logger LOG = Logger.getLogger(NotificationDaoOjb.class);
41
42
43
44
45
46
47 @Override
48 public Collection getUndeliveredMessageDelivers(GenericDao businessObjectDao) {
49
50
51
52 Criteria criteria = new Criteria();
53 criteria.addEqualTo(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED);
54 criteria.addIsNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
55 Collection<NotificationMessageDelivery> messageDeliveries = businessObjectDao.findMatching(NotificationMessageDelivery.class, criteria, true, RiceConstants.NO_WAIT);
56
57 return messageDeliveries;
58 }
59
60
61
62
63
64
65 @Override
66 public Collection<NotificationMessageDelivery> getMessageDeliveriesForAutoRemoval(Timestamp tm, GenericDao businessObjectDao) {
67
68
69
70
71 Criteria criteria_STATUS = new Criteria();
72 criteria_STATUS.addEqualTo(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.DELIVERED);
73
74 Criteria criteria_UNDELIVERED = new Criteria();
75 criteria_UNDELIVERED.addEqualTo(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED);
76
77
78 criteria_STATUS.addOrCriteria(criteria_UNDELIVERED);
79
80 Criteria fullQueryCriteria = new Criteria();
81 fullQueryCriteria.addIsNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
82 fullQueryCriteria.addLessOrEqualThan(NotificationConstants.BO_PROPERTY_NAMES.NOTIFICATION_AUTO_REMOVE_DATE_TIME, tm);
83 fullQueryCriteria.addAndCriteria(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();
99 criteria.addNotNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
100 Collection<NotificationMessageDelivery> lockedDeliveries = dao.findMatching(clazz, criteria);
101
102 return lockedDeliveries;
103 }
104
105 }