From 1efe470d4df335dfaaad5a9e2c6417c24d8864e1 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 3 Dec 2023 12:12:57 -0800 Subject: Move find driver method --- src/main/java/org/traccar/notification/NotificationFormatter.java | 4 +++- src/main/java/org/traccar/session/cache/CacheManager.java | 7 ------- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'src/main/java') 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(); -- cgit v1.2.3