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