aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-11-13 10:12:32 -0800
committerAnton Tananaev <anton@traccar.org>2022-11-13 10:12:32 -0800
commitff793b2e2872f8ba076e748fab41d944f92b64d4 (patch)
tree3ccf568ebe9d84dabd7e1b840444caa1cc89cb78 /src/main/java/org/traccar/database
parent4ec9db613475066de3f46c24d4ee78fefcbb17df (diff)
downloadtrackermap-server-ff793b2e2872f8ba076e748fab41d944f92b64d4.tar.gz
trackermap-server-ff793b2e2872f8ba076e748fab41d944f92b64d4.tar.bz2
trackermap-server-ff793b2e2872f8ba076e748fab41d944f92b64d4.zip
Refactor event forwarding
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r--src/main/java/org/traccar/database/NotificationManager.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/database/NotificationManager.java b/src/main/java/org/traccar/database/NotificationManager.java
index 5ea89fcac..7c82454b2 100644
--- a/src/main/java/org/traccar/database/NotificationManager.java
+++ b/src/main/java/org/traccar/database/NotificationManager.java
@@ -20,12 +20,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.config.Config;
import org.traccar.config.Keys;
+import org.traccar.forward.EventData;
+import org.traccar.forward.EventForwarder;
import org.traccar.geocoder.Geocoder;
import org.traccar.model.Calendar;
import org.traccar.model.Event;
+import org.traccar.model.Geofence;
+import org.traccar.model.Maintenance;
import org.traccar.model.Notification;
import org.traccar.model.Position;
-import org.traccar.notification.EventForwarder;
import org.traccar.notification.MessageException;
import org.traccar.notification.NotificatorManager;
import org.traccar.session.cache.CacheManager;
@@ -112,8 +115,21 @@ public class NotificationManager {
});
}
+ forwardEvent(event, position);
+ }
+
+ private void forwardEvent(Event event, Position position) {
if (eventForwarder != null) {
- eventForwarder.forwardEvent(event, position);
+ EventData eventData = new EventData();
+ eventData.setEvent(event);
+ eventData.setPosition(position);
+ if (event.getGeofenceId() != 0) {
+ eventData.setGeofence(cacheManager.getObject(Geofence.class, event.getGeofenceId()));
+ }
+ if (event.getMaintenanceId() != 0) {
+ eventData.setMaintenance(cacheManager.getObject(Maintenance.class, event.getMaintenanceId()));
+ }
+ eventForwarder.forward(eventData);
}
}