diff options
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 6 | ||||
-rw-r--r-- | src/org/traccar/database/GeofenceManager.java | 17 | ||||
-rw-r--r-- | src/org/traccar/database/NotificationManager.java | 2 |
3 files changed, 13 insertions, 12 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 031703023..2d3b75db7 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -241,7 +241,7 @@ public class DataManager implements IdentityManager { } public Group getGroupById(long id) { - boolean forceUpdate; + /*boolean forceUpdate; groupsLock.readLock().lock(); try { forceUpdate = !groupsById.containsKey(id); @@ -253,7 +253,7 @@ public class DataManager implements IdentityManager { updateGroupCache(forceUpdate); } catch (SQLException e) { Log.warning(e); - } + }*/ groupsLock.readLock().lock(); try { @@ -356,7 +356,7 @@ public class DataManager implements IdentityManager { boolean forceUpdate; devicesLock.readLock().lock(); try { - forceUpdate = devicesById.values().isEmpty(); + forceUpdate = devicesById.isEmpty(); } finally { devicesLock.readLock().unlock(); } 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); diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index ae91d81cc..d263e160f 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -87,7 +87,7 @@ public class NotificationManager { public Set<Notification> getUserNotifications(long userId) { notificationsLock.readLock().lock(); try { - return getUserNotificationsUnsafe(userId); + return getUserNotificationsUnsafe(userId); } finally { notificationsLock.readLock().unlock(); } |