diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-29 09:54:48 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-29 09:54:48 +1200 |
commit | 4f875a6fb51aa1eb7aebc779d2b971f74a53e901 (patch) | |
tree | bd097caeea4d554b344d10d12b2531b8d1cc312b /src/org/traccar/events/GeofenceEventHandler.java | |
parent | b1e7bd492b9f6739936e533b4ab16d4825f1ce3c (diff) | |
parent | 6f89644fdcb3dbeb966cadbd810f9795922b8c4e (diff) | |
download | trackermap-server-4f875a6fb51aa1eb7aebc779d2b971f74a53e901.tar.gz trackermap-server-4f875a6fb51aa1eb7aebc779d2b971f74a53e901.tar.bz2 trackermap-server-4f875a6fb51aa1eb7aebc779d2b971f74a53e901.zip |
Merge pull request #2163 from Abyss777/overspeed_extension
OverspeedEventHandler enhancement to use attributes
Diffstat (limited to 'src/org/traccar/events/GeofenceEventHandler.java')
-rw-r--r-- | src/org/traccar/events/GeofenceEventHandler.java | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java index a9bed6f82..a0291dcfa 100644 --- a/src/org/traccar/events/GeofenceEventHandler.java +++ b/src/org/traccar/events/GeofenceEventHandler.java @@ -15,30 +15,23 @@ */ package org.traccar.events; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.traccar.BaseEventHandler; import org.traccar.Context; -import org.traccar.database.DataManager; import org.traccar.database.GeofenceManager; -import org.traccar.helper.Log; import org.traccar.model.Device; import org.traccar.model.Event; import org.traccar.model.Position; public class GeofenceEventHandler extends BaseEventHandler { - private int suppressRepeated; private GeofenceManager geofenceManager; - private DataManager dataManager; public GeofenceEventHandler() { - suppressRepeated = Context.getConfig().getInteger("event.suppressRepeated", 60); geofenceManager = Context.getGeofenceManager(); - dataManager = Context.getDataManager(); } @Override @@ -63,29 +56,15 @@ public class GeofenceEventHandler extends BaseEventHandler { device.setGeofenceIds(currentGeofences); Collection<Event> events = new ArrayList<>(); - try { - if (dataManager.getLastEvents(position.getDeviceId(), - Event.TYPE_GEOFENCE_ENTER, suppressRepeated).isEmpty()) { - for (long geofenceId : newGeofences) { - Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId()); - event.setGeofenceId(geofenceId); - events.add(event); - } - } - } catch (SQLException error) { - Log.warning(error); + for (long geofenceId : newGeofences) { + Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId()); + event.setGeofenceId(geofenceId); + events.add(event); } - try { - if (dataManager.getLastEvents(position.getDeviceId(), - Event.TYPE_GEOFENCE_EXIT, suppressRepeated).isEmpty()) { - for (long geofenceId : oldGeofences) { - Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId()); - event.setGeofenceId(geofenceId); - events.add(event); - } - } - } catch (SQLException error) { - Log.warning(error); + for (long geofenceId : oldGeofences) { + Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId()); + event.setGeofenceId(geofenceId); + events.add(event); } return events; } |