1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.ken.service.impl;
18
19 import org.kuali.rice.core.framework.persistence.dao.GenericDao;
20 import org.kuali.rice.ken.bo.NotificationChannel;
21 import org.kuali.rice.ken.service.NotificationChannelService;
22
23 import java.util.Collection;
24 import java.util.HashMap;
25 import java.util.Map;
26
27
28
29
30
31 public class NotificationChannelServiceImpl implements NotificationChannelService {
32 private GenericDao businessObjectDao;
33
34
35
36
37
38 public NotificationChannelServiceImpl(GenericDao businessObjectDao) {
39 this.businessObjectDao = businessObjectDao;
40 }
41
42
43
44
45 public NotificationChannel getNotificationChannel(String id) {
46 Map<String, String> primaryKeys = new HashMap<String, String>();
47 primaryKeys.put("id", id);
48 return (NotificationChannel) businessObjectDao.findByPrimaryKey(NotificationChannel.class, primaryKeys);
49 }
50
51
52
53
54 public NotificationChannel getNotificationChannelByName(String name) {
55 Map<String, String> fields = new HashMap<String, String>();
56 fields.put("name", name);
57 Collection<NotificationChannel> found = businessObjectDao.findMatching(NotificationChannel.class, fields);
58 assert(found.size() <= 1);
59 if (found.size() == 0) return null;
60 return found.iterator().next();
61 }
62
63
64
65
66 public Collection getSubscribableChannels() {
67 Map<String, Boolean> fieldValues = new HashMap<String, Boolean>();
68 String sortField = new String("name");
69 fieldValues.put("subscribable", true);
70 return businessObjectDao.findMatchingOrderBy(NotificationChannel.class, fieldValues, sortField, true);
71 }
72
73
74
75
76 public Collection getAllNotificationChannels() {
77 String sortField = new String("name");
78 return businessObjectDao.findAllOrderBy(NotificationChannel.class, sortField, true);
79 }
80 }