aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/events
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-19 15:24:55 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-19 15:24:55 +0500
commita9478ded48de140d47d17def1ee5329267fe6088 (patch)
treeadc5a9177fd5adcf10a8b56ee4620780dfc13cd9 /src/org/traccar/events
parentcb0d7cccaecfe049e04defd90884976ac1e982f9 (diff)
downloadtrackermap-server-a9478ded48de140d47d17def1ee5329267fe6088.tar.gz
trackermap-server-a9478ded48de140d47d17def1ee5329267fe6088.tar.bz2
trackermap-server-a9478ded48de140d47d17def1ee5329267fe6088.zip
Refactored four managers
Diffstat (limited to 'src/org/traccar/events')
-rw-r--r--src/org/traccar/events/GeofenceEventHandler.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java
index fbec932b1..cdac7993f 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,20 @@ 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();
+ if (calendarId == 0 || Context.getCalendarManager().getById(calendarId) == null
+ || ((Calendar) Context.getCalendarManager().getById(calendarId))
+ .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();
+ if (calendarId == 0 || Context.getCalendarManager().getById(calendarId) == null
+ || ((Calendar) Context.getCalendarManager().getById(calendarId))
+ .checkMoment(position.getFixTime())) {
Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId());
event.setGeofenceId(geofenceId);
events.add(event);