diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-09 22:50:35 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-09 22:50:35 +1200 |
commit | ee7452124062845401afb0920d1569217595b8c5 (patch) | |
tree | 7e9f2f47ecdbed91544baf4fff0e2d7e9071e454 /src/org/traccar/database | |
parent | 6ef886814b3b6b91450a64ffb967fccde3ec61cb (diff) | |
download | trackermap-server-ee7452124062845401afb0920d1569217595b8c5.tar.gz trackermap-server-ee7452124062845401afb0920d1569217595b8c5.tar.bz2 trackermap-server-ee7452124062845401afb0920d1569217595b8c5.zip |
Fix issue with missing groups
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/GeofenceManager.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/org/traccar/database/GeofenceManager.java b/src/org/traccar/database/GeofenceManager.java index cc9f82879..d3cf2ad1f 100644 --- a/src/org/traccar/database/GeofenceManager.java +++ b/src/org/traccar/database/GeofenceManager.java @@ -30,11 +30,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import org.traccar.Context; import org.traccar.helper.Log; import org.traccar.model.Device; +import org.traccar.model.DeviceGeofence; import org.traccar.model.Geofence; +import org.traccar.model.GeofencePermission; +import org.traccar.model.Group; import org.traccar.model.GroupGeofence; import org.traccar.model.Position; -import org.traccar.model.DeviceGeofence; -import org.traccar.model.GeofencePermission; public class GeofenceManager { @@ -137,15 +138,15 @@ public class GeofenceManager { } for (Device device : dataManager.getAllDevicesCached()) { - long groupId = device.getGroupId(); - while (groupId != 0) { + Group group = dataManager.getGroupById(device.getGroupId()); + while (group != null) { getDeviceGeofences(deviceGeofencesWithGroups, - device.getId()).addAll(getGroupGeofences(groupId)); - groupId = dataManager.getGroupById(groupId).getGroupId(); + device.getId()).addAll(getGroupGeofences(group.getGroupId())); + group = dataManager.getGroupById(group.getGroupId()); } List<Long> deviceGeofenceIds = device.getGeofenceIds(); if (deviceGeofenceIds == null) { - deviceGeofenceIds = new ArrayList<Long>(); + deviceGeofenceIds = new ArrayList<>(); } else { deviceGeofenceIds.clear(); } @@ -232,7 +233,7 @@ public class GeofenceManager { } public List<Long> getCurrentDeviceGeofences(Position position) { - List<Long> result = new ArrayList<Long>(); + List<Long> result = new ArrayList<>(); for (Long geofenceId : getAllDeviceGeofences(position.getDeviceId())) { if (getGeofence(geofenceId).getGeometry().containsPoint(position.getLatitude(), position.getLongitude())) { result.add(geofenceId); |