1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.service.impl;
17
18 import org.kuali.rice.core.api.criteria.QueryByCriteria;
19 import org.kuali.rice.ken.bo.NotificationChannelBo;
20 import org.kuali.rice.ken.service.NotificationChannelService;
21 import org.kuali.rice.krad.data.DataObjectService;
22
23 import java.util.Collection;
24 import java.util.List;
25
26 import static org.kuali.rice.core.api.criteria.PredicateFactory.equal;
27 import static org.kuali.rice.core.api.criteria.PredicateFactory.isNotNull;
28
29
30
31
32
33 public class NotificationChannelServiceImpl implements NotificationChannelService {
34 private DataObjectService dataObjectService;
35
36
37
38
39
40 public NotificationChannelServiceImpl(DataObjectService dataObjectService) {
41 this.dataObjectService = dataObjectService;
42 }
43
44
45
46
47 @Override
48 public NotificationChannelBo getNotificationChannel(String id) {
49
50 return dataObjectService.find(NotificationChannelBo.class, Long.valueOf(id));
51 }
52
53
54
55
56 @Override
57 public NotificationChannelBo getNotificationChannelByName(String name) {
58 QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
59
60 criteria.setPredicates(equal("name", name));
61 List<NotificationChannelBo> found = dataObjectService.findMatching(NotificationChannelBo.class, criteria.build()).getResults();
62 assert(found.size() <= 1);
63
64 return ((found.isEmpty() ? null : found.get(0)));
65 }
66
67
68
69
70 @Override
71 public Collection getSubscribableChannels() {
72 QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
73 criteria.setPredicates(equal("subscribable", Boolean.TRUE));
74 criteria.setOrderByAscending("name");
75
76 return dataObjectService.findMatching(NotificationChannelBo.class, criteria.build()).getResults();
77 }
78
79
80
81
82 @Override
83 public Collection getAllNotificationChannels() {
84 QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
85 criteria.setOrderByAscending("name");
86
87 return dataObjectService.findMatching(NotificationChannelBo.class, criteria.build()).getResults();
88 }
89 }