aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/events/GeofenceEventHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-07-23 18:29:36 +1200
committerGitHub <noreply@github.com>2017-07-23 18:29:36 +1200
commit4b2372336d0496c85befe099914434e5b68f05b3 (patch)
tree798de625a07c18287e829b3a037cacee179ebcff /src/org/traccar/events/GeofenceEventHandler.java
parentba82047a492be54545961716814584d8880d28ae (diff)
parent5a65c0d6be8ffc2db0ffdb0c35ecedfb2b3750c7 (diff)
downloadtrackermap-server-4b2372336d0496c85befe099914434e5b68f05b3.tar.gz
trackermap-server-4b2372336d0496c85befe099914434e5b68f05b3.tar.bz2
trackermap-server-4b2372336d0496c85befe099914434e5b68f05b3.zip
Merge pull request #3373 from Abyss777/refactor_managers
Refactor managers, permissions etc
Diffstat (limited to 'src/org/traccar/events/GeofenceEventHandler.java')
-rw-r--r--src/org/traccar/events/GeofenceEventHandler.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java
index fbec932b1..516df9d69 100644
--- a/src/org/traccar/events/GeofenceEventHandler.java
+++ b/src/org/traccar/events/GeofenceEventHandler.java
@@ -22,8 +22,10 @@ import java.util.List;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.database.GeofenceManager;
+import org.traccar.model.Calendar;
import org.traccar.model.Device;
import org.traccar.model.Event;
+import org.traccar.model.Geofence;
import org.traccar.model.Position;
public class GeofenceEventHandler extends BaseEventHandler {
@@ -57,18 +59,18 @@ public class GeofenceEventHandler extends BaseEventHandler {
Collection<Event> events = new ArrayList<>();
for (long geofenceId : newGeofences) {
- long calendarId = geofenceManager.getGeofence(geofenceId).getCalendarId();
- if (calendarId == 0 || Context.getCalendarManager().getCalendar(calendarId) == null
- || Context.getCalendarManager().getCalendar(calendarId).checkMoment(position.getFixTime())) {
+ long calendarId = ((Geofence) geofenceManager.getById(geofenceId)).getCalendarId();
+ Calendar calendar = calendarId != 0 ? (Calendar) Context.getCalendarManager().getById(calendarId) : null;
+ if (calendar == null || calendar.checkMoment(position.getFixTime())) {
Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId());
event.setGeofenceId(geofenceId);
events.add(event);
}
}
for (long geofenceId : oldGeofences) {
- long calendarId = geofenceManager.getGeofence(geofenceId).getCalendarId();
- if (calendarId == 0 || Context.getCalendarManager().getCalendar(calendarId) == null
- || Context.getCalendarManager().getCalendar(calendarId).checkMoment(position.getFixTime())) {
+ long calendarId = ((Geofence) geofenceManager.getById(geofenceId)).getCalendarId();
+ Calendar calendar = calendarId != 0 ? (Calendar) Context.getCalendarManager().getById(calendarId) : null;
+ if (calendar == null || calendar.checkMoment(position.getFixTime())) {
Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId());
event.setGeofenceId(geofenceId);
events.add(event);