aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database/NotificationManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-10 07:56:49 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-10 07:56:49 -0700
commitbbe84d6a751fdc840e4201ef9027a96527006049 (patch)
tree4165d09a134eb1c1c61438b17fe44f5a1fcd0654 /src/main/java/org/traccar/database/NotificationManager.java
parentc03b4a2ace925e6a0d7c43ce59e14ddb9cbf18a9 (diff)
downloadtrackermap-server-bbe84d6a751fdc840e4201ef9027a96527006049.tar.gz
trackermap-server-bbe84d6a751fdc840e4201ef9027a96527006049.tar.bz2
trackermap-server-bbe84d6a751fdc840e4201ef9027a96527006049.zip
Inject report utils
Diffstat (limited to 'src/main/java/org/traccar/database/NotificationManager.java')
-rw-r--r--src/main/java/org/traccar/database/NotificationManager.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/database/NotificationManager.java b/src/main/java/org/traccar/database/NotificationManager.java
index eddd7e2b4..1f4a48ac0 100644
--- a/src/main/java/org/traccar/database/NotificationManager.java
+++ b/src/main/java/org/traccar/database/NotificationManager.java
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.Context;
import org.traccar.config.Keys;
+import org.traccar.geocoder.Geocoder;
import org.traccar.model.Calendar;
import org.traccar.model.Event;
import org.traccar.model.Notification;
@@ -41,20 +42,25 @@ import org.traccar.notification.NotificatorManager;
import org.traccar.session.cache.CacheManager;
import org.traccar.storage.StorageException;
+import javax.annotation.Nullable;
+
public class NotificationManager extends ExtendedObjectManager<Notification> {
private static final Logger LOGGER = LoggerFactory.getLogger(NotificationManager.class);
private final CacheManager cacheManager;
private final NotificatorManager notificatorManager;
+ private final Geocoder geocoder;
private final boolean geocodeOnRequest;
public NotificationManager(
- DataManager dataManager, CacheManager cacheManager, NotificatorManager notificatorManager) {
+ DataManager dataManager, CacheManager cacheManager,
+ NotificatorManager notificatorManager, @Nullable Geocoder geocoder) {
super(dataManager, Notification.class);
this.cacheManager = cacheManager;
this.notificatorManager = notificatorManager;
+ this.geocoder = geocoder;
geocodeOnRequest = Context.getConfig().getBoolean(Keys.GEOCODER_ON_REQUEST);
}
@@ -110,10 +116,8 @@ public class NotificationManager extends ExtendedObjectManager<Notification> {
}
}
- if (position != null && position.getAddress() == null
- && geocodeOnRequest && Context.getGeocoder() != null) {
- position.setAddress(Context.getGeocoder()
- .getAddress(position.getLatitude(), position.getLongitude(), null));
+ if (position != null && position.getAddress() == null && geocodeOnRequest && geocoder != null) {
+ position.setAddress(geocoder.getAddress(position.getLatitude(), position.getLongitude(), null));
}
User user = Context.getUsersManager().getById(userId);