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.NotificationBo;
21 import org.kuali.rice.ken.dao.NotificationDao;
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.and;
29 import static org.kuali.rice.core.api.criteria.PredicateFactory.lessThanOrEqual;
30 import static org.kuali.rice.core.api.criteria.PredicateFactory.equal;
31 import static org.kuali.rice.core.api.criteria.PredicateFactory.isNull;
32
33
34
35
36
37
38
39 public class NotificationDaoJpa implements NotificationDao{
40
41 private static final Logger LOG = Logger.getLogger(NotificationDaoJpa.class);
42
43
44
45
46
47
48 @Override
49 public Collection findMatchedNotificationsForResolution(Timestamp tm, DataObjectService dataObjectService) {
50
51
52
53 QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
54 criteria.setPredicates(
55 and(
56 equal(NotificationConstants.BO_PROPERTY_NAMES.PROCESSING_FLAG, NotificationConstants.PROCESSING_FLAGS.UNRESOLVED),
57 lessThanOrEqual(NotificationConstants.BO_PROPERTY_NAMES.SEND_DATE_TIME, new Timestamp(System.currentTimeMillis())),
58 isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE)
59 )
60 );
61
62 return dataObjectService.findMatching(NotificationBo.class, criteria.build()).getResults();
63 }
64
65
66
67
68
69
70 @Override
71 public Collection findMatchedNotificationsForUnlock(NotificationBo not, DataObjectService dataObjectService) {
72
73
74
75 QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
76 criteria.setPredicates(equal(NotificationConstants.BO_PROPERTY_NAMES.ID, not.getId()));
77
78 Collection<NotificationBo> notifications = dataObjectService.findMatching(NotificationBo.class, criteria.build()).getResults();
79
80 return notifications;
81 }
82 }
83