aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/handler/events/DriverEventHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-03-09 20:02:51 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-03-09 20:02:51 -0800
commit69ebfe201e6399340545e167110e87fdd4e16a6b (patch)
tree435cf0e2fb2b3858bdbf7360d75afe2c66f3145d /src/org/traccar/handler/events/DriverEventHandler.java
parentc7e9f996ed7d183442a7dd2fbbc5c9329981f261 (diff)
downloadtrackermap-server-69ebfe201e6399340545e167110e87fdd4e16a6b.tar.gz
trackermap-server-69ebfe201e6399340545e167110e87fdd4e16a6b.tar.bz2
trackermap-server-69ebfe201e6399340545e167110e87fdd4e16a6b.zip
Refactor driver event handler
Diffstat (limited to 'src/org/traccar/handler/events/DriverEventHandler.java')
-rw-r--r--src/org/traccar/handler/events/DriverEventHandler.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/org/traccar/handler/events/DriverEventHandler.java b/src/org/traccar/handler/events/DriverEventHandler.java
index dbb980c89..994df93fa 100644
--- a/src/org/traccar/handler/events/DriverEventHandler.java
+++ b/src/org/traccar/handler/events/DriverEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2019 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,22 +20,28 @@ import java.util.Collections;
import java.util.Map;
import io.netty.channel.ChannelHandler;
-import org.traccar.Context;
+import org.traccar.database.IdentityManager;
import org.traccar.model.Event;
import org.traccar.model.Position;
@ChannelHandler.Sharable
public class DriverEventHandler extends BaseEventHandler {
+ private final IdentityManager identityManager;
+
+ public DriverEventHandler(IdentityManager identityManager) {
+ this.identityManager = identityManager;
+ }
+
@Override
protected Map<Event, Position> analyzePosition(Position position) {
- if (!Context.getIdentityManager().isLatestPosition(position)) {
+ if (!identityManager.isLatestPosition(position)) {
return null;
}
String driverUniqueId = position.getString(Position.KEY_DRIVER_UNIQUE_ID);
if (driverUniqueId != null) {
String oldDriverUniqueId = null;
- Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
+ Position lastPosition = identityManager.getLastPosition(position.getDeviceId());
if (lastPosition != null) {
oldDriverUniqueId = lastPosition.getString(Position.KEY_DRIVER_UNIQUE_ID);
}