aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/session
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-09 07:00:20 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-09 07:00:20 -0700
commit12fe28bebbdbc61214363a9c7b51bd300ed62c15 (patch)
tree5e014f785a6f5856c24197b611fd108403bbd5e7 /src/main/java/org/traccar/session
parentc4ff983ffe9a03a57d3ab0596abe8bce08c1ae2e (diff)
downloadtrackermap-server-12fe28bebbdbc61214363a9c7b51bd300ed62c15.tar.gz
trackermap-server-12fe28bebbdbc61214363a9c7b51bd300ed62c15.tar.bz2
trackermap-server-12fe28bebbdbc61214363a9c7b51bd300ed62c15.zip
Remove geofence manager
Diffstat (limited to 'src/main/java/org/traccar/session')
-rw-r--r--src/main/java/org/traccar/session/cache/CacheManager.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/session/cache/CacheManager.java b/src/main/java/org/traccar/session/cache/CacheManager.java
index 4b42ea4e5..18daeae15 100644
--- a/src/main/java/org/traccar/session/cache/CacheManager.java
+++ b/src/main/java/org/traccar/session/cache/CacheManager.java
@@ -15,6 +15,7 @@
*/
package org.traccar.session.cache;
+import org.traccar.helper.model.GeofenceUtil;
import org.traccar.model.Attribute;
import org.traccar.model.BaseModel;
import org.traccar.model.Device;
@@ -181,13 +182,16 @@ public class CacheManager {
if (invalidate) {
invalidate(object.getClass(), object.getId());
} else {
- // TODO if device, also need to update geofences
try {
lock.writeLock().lock();
deviceCache.get(new CacheKey(object.getClass(), object.getId())).setValue(object);
} finally {
lock.writeLock().unlock();
}
+
+ if (object instanceof Device) {
+ invalidateDeviceGeofences((Device) object);
+ }
}
}
@@ -254,6 +258,8 @@ public class CacheManager {
devicePositions.put(deviceId, storage.getObject(Position.class, new Request(
new Columns.All(), new Condition.Equals("id", "id", device.getPositionId()))));
}
+
+ invalidateDeviceGeofences(device);
}
private void unsafeRemoveDevice(long deviceId) {
@@ -306,4 +312,11 @@ public class CacheManager {
}
}
+ private void invalidateDeviceGeofences(Device device) {
+ Position position = getPosition(device.getId());
+ if (position != null) {
+ device.setGeofenceIds(GeofenceUtil.getCurrentGeofences(this, position));
+ }
+ }
+
}