1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.mobility.push.dao;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.mobility.push.service.PushDeviceTupleService;
20 import org.kuali.mobility.security.authz.expression.GroupExpression;
21 import org.kuali.mobility.security.user.api.User;
22 import org.kuali.mobility.shared.Constants;
23 import org.springframework.beans.factory.annotation.Autowired;
24
25 import javax.persistence.EntityManager;
26 import javax.persistence.PersistenceContext;
27 import javax.servlet.http.HttpServletRequest;
28
29
30
31
32
33
34
35 public class PurgePushNotificationDaoImpl implements PurgePushNotificationDao {
36
37
38 private static final Logger LOG = Logger.getLogger(PurgePushNotificationDaoImpl.class);
39
40
41 @PersistenceContext
42 private EntityManager entityManager;
43
44
45 @Autowired
46 private PushDeviceTupleService pdtService;
47
48
49
50
51
52 public PurgePushNotificationDaoImpl(){}
53
54 public boolean purgePushNotification(HttpServletRequest request, int status){
55 boolean success = false;
56 User user = (User) request.getSession().getAttribute(Constants.KME_USER_KEY);
57
58
59 if(new GroupExpression("KME-ADMINISTRATOR").evaluate(user)) {
60 entityManager.createNamedQuery("PushDeviceTuple.deleteForStatus").setParameter("status", status).executeUpdate();
61 success = true;
62 }
63 return success;
64 }
65
66
67
68
69
70 public EntityManager getEntityManager() {
71 return entityManager;
72 }
73
74
75
76
77
78 public void setEntityManager(EntityManager entityManager) {
79 this.entityManager = entityManager;
80 }
81
82 }