1 /**
2 * Copyright 2011 The Kuali Foundation Licensed under the
3 * Educational Community License, Version 2.0 (the "License"); you may
4 * not use this file except in compliance with the License. You may
5 * obtain a copy of the License at
6 *
7 * http://www.osedu.org/licenses/ECL-2.0
8 *
9 * Unless required by applicable law or agreed to in writing,
10 * software distributed under the License is distributed on an "AS IS"
11 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 * or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 package org.kuali.mobility.push.service;
17
18 import java.util.List;
19
20 import org.kuali.mobility.push.entity.Device;
21 import org.kuali.mobility.push.entity.Push;
22 import org.kuali.mobility.push.entity.PushDeviceTuple;
23
24 /**
25 * Interface for sending and persisting <code>Push</code> messages to
26 * <code>Device</code>.
27 *
28 * Implementations of this service will typically persist <code>Push</code>
29 * messages from a database, retrieve devices from a service, and send
30 * the message to the devices using an implementatin of the <code>SendService</code>
31 * interface.
32 *
33 * @author Kuali Mobility Team (mobility.dev@kuali.org)
34 * @since 2.0.0
35 */
36 public interface PushService {
37
38 /**
39 * Persists a <code>Push</code> message.
40 * @param push Push message to persist.
41 */
42 public abstract void savePush(Push push);
43
44
45 /**
46 * Persists a push messages that should be sent to many devices
47 * @param push Push message to be sent.
48 * @param Devices Devices the Push message should be sent to.
49 */
50 public abstract void savePush(Push push, List<Device> Devices);
51
52
53 /**
54 * Reutns the number of <code>Push</code> messages persisted.
55 * @return number of <code>Push</code> messages persisted.
56 */
57 public abstract int countPushes();
58
59
60 /**
61 * Finds a <code>Push</code> by its ID.
62 * @param id ID of the <code>Push</code> to find.
63 * @return The <code>Push</code> that has the specified ID.
64 */
65 public abstract Push findPushById(Long id);
66
67
68 /**
69 * Returns a list of <b>ALL</b> the <code>Push</code> messages
70 * that are persisted.<br>
71 * <b>WARNING: This method can return A LOT of data</b>
72 * @return A lsit of all the persisted <code>Push</code> messages.
73 */
74 public abstract List<Push> findAllPush();
75
76
77 /**
78 * Finds a list of <code>Devices</code> that was linked to a <code>Push</code>.
79 * @param push <code>Push</code> to find devices of</code>.
80 * @return List of <code>Devices</code> that was linked.
81 */
82 public abstract List<Device> findDevicesForPush(Push push);
83
84
85 /**
86 * Finds a list of unsent <code>PushDeviceTuple</code>.
87 * @return List of unsent <code>PushDeviceTuple</code>.
88 */
89 public abstract List<PushDeviceTuple> findUnsentPushTuples();
90
91
92 /**
93 * Sends a <code>Push</code> message to the specified <code>Device</code>
94 * without persisting the message.
95 * @param push Push message to send.
96 * @param device Device to send the message to.
97 */
98 public abstract int sendPush(Push push, Device device);
99
100
101 /**
102 * Sends a <code>Push</code< message to the specified list of devices
103 * without persisting the message.
104 * @param push Push message to send.
105 * @param devices Devices to send the message to.
106 */
107 public abstract int sendPush(Push push, List<Device> devices);
108
109
110 /**
111 * Attempts to send <code>PushDeviceTuple</code>
112 * @param tuples List of <code>PushDeviceTuple</code> to send.
113 * @return
114 */
115 public abstract int sendPush(List<PushDeviceTuple> tuples);
116 }