blob: 8c8e958c87e1082d07736f07fdd34a97bebc7790 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package org.traccar.database;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Set;
import org.traccar.Context;
import org.traccar.helper.Log;
import org.traccar.model.Event;
import org.traccar.model.Position;
public class NotificationManager {
private final DataManager dataManager;
public NotificationManager(DataManager dataManager) {
this.dataManager = dataManager;
}
public void updateEvent(Event event, Position position) {
try {
dataManager.addEvent(event);
} catch (SQLException error) {
Log.warning(error);
}
Set<Long> users = Context.getPermissionsManager().getDeviceUsers(event.getDeviceId());
for (Long userId : users) {
if (event.getGeofenceId() == 0
|| Context.getGeofenceManager().checkGeofence(userId, event.getGeofenceId())) {
Context.getConnectionManager().updateEvent(userId, event, position);
}
}
}
public void updateEvents(Collection<Event> events, Position position) {
for (Event event : events) {
updateEvent(event, position);
}
}
}
|