aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-12-03 12:12:57 -0800
committerAnton Tananaev <anton@traccar.org>2023-12-03 12:12:57 -0800
commit1efe470d4df335dfaaad5a9e2c6417c24d8864e1 (patch)
tree1a23061ea91b3ec51c8d80ef65819f5b96e7b4e5
parentf3f12a2ff295d8e60a87e521d09022a2c09763cf (diff)
downloadtrackermap-server-1efe470d4df335dfaaad5a9e2c6417c24d8864e1.tar.gz
trackermap-server-1efe470d4df335dfaaad5a9e2c6417c24d8864e1.tar.bz2
trackermap-server-1efe470d4df335dfaaad5a9e2c6417c24d8864e1.zip
Move find driver method
-rw-r--r--src/main/java/org/traccar/notification/NotificationFormatter.java4
-rw-r--r--src/main/java/org/traccar/session/cache/CacheManager.java7
2 files changed, 3 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/notification/NotificationFormatter.java b/src/main/java/org/traccar/notification/NotificationFormatter.java
index 85e8a54bb..e994729c0 100644
--- a/src/main/java/org/traccar/notification/NotificationFormatter.java
+++ b/src/main/java/org/traccar/notification/NotificationFormatter.java
@@ -19,6 +19,7 @@ package org.traccar.notification;
import org.apache.velocity.VelocityContext;
import org.traccar.helper.model.UserUtil;
import org.traccar.model.Device;
+import org.traccar.model.Driver;
import org.traccar.model.Event;
import org.traccar.model.Geofence;
import org.traccar.model.Maintenance;
@@ -66,7 +67,8 @@ public class NotificationFormatter {
}
String driverUniqueId = event.getString(Position.KEY_DRIVER_UNIQUE_ID);
if (driverUniqueId != null) {
- velocityContext.put("driver", cacheManager.findDriverByUniqueId(device.getId(), driverUniqueId));
+ velocityContext.put("driver", cacheManager.getDeviceObjects(device.getId(), Driver.class).stream()
+ .filter(driver -> driver.getUniqueId().equals(driverUniqueId)).findFirst().orElse(null));
}
return textTemplateFormatter.formatMessage(velocityContext, event.getType(), templatePath);
diff --git a/src/main/java/org/traccar/session/cache/CacheManager.java b/src/main/java/org/traccar/session/cache/CacheManager.java
index 0aadb3692..4b6422de2 100644
--- a/src/main/java/org/traccar/session/cache/CacheManager.java
+++ b/src/main/java/org/traccar/session/cache/CacheManager.java
@@ -155,13 +155,6 @@ public class CacheManager implements BroadcastInterface {
}
}
- public Driver findDriverByUniqueId(long deviceId, String driverUniqueId) {
- return getDeviceObjects(deviceId, Driver.class).stream()
- .filter(driver -> driver.getUniqueId().equals(driverUniqueId))
- .findFirst()
- .orElse(null);
- }
-
public void addDevice(long deviceId) throws StorageException {
try {
lock.writeLock().lock();