diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-18 11:08:32 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-18 11:08:32 -0700 |
commit | ddbe4d7de6ae7590e2b927066312597efa129393 (patch) | |
tree | 777882e24ce5488b4cfc8a4d6f11119abcbeb7a3 /src/main/java/org/traccar/handler/events/IgnitionEventHandler.java | |
parent | 182656b6dc1fb5d167bb752c16ecf633add001a8 (diff) | |
download | trackermap-server-ddbe4d7de6ae7590e2b927066312597efa129393.tar.gz trackermap-server-ddbe4d7de6ae7590e2b927066312597efa129393.tar.bz2 trackermap-server-ddbe4d7de6ae7590e2b927066312597efa129393.zip |
Remove positions from manager
Diffstat (limited to 'src/main/java/org/traccar/handler/events/IgnitionEventHandler.java')
-rw-r--r-- | src/main/java/org/traccar/handler/events/IgnitionEventHandler.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java b/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java index 9887c9db6..6e411539c 100644 --- a/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java +++ b/src/main/java/org/traccar/handler/events/IgnitionEventHandler.java @@ -20,27 +20,28 @@ import java.util.Collections; import java.util.Map; import io.netty.channel.ChannelHandler; -import org.traccar.database.IdentityManager; +import org.traccar.helper.model.PositionUtil; import org.traccar.model.Device; import org.traccar.model.Event; import org.traccar.model.Position; +import org.traccar.session.cache.CacheManager; import javax.inject.Inject; @ChannelHandler.Sharable public class IgnitionEventHandler extends BaseEventHandler { - private final IdentityManager identityManager; + private final CacheManager cacheManager; @Inject - public IgnitionEventHandler(IdentityManager identityManager) { - this.identityManager = identityManager; + public IgnitionEventHandler(CacheManager cacheManager) { + this.cacheManager = cacheManager; } @Override protected Map<Event, Position> analyzePosition(Position position) { - Device device = identityManager.getById(position.getDeviceId()); - if (device == null || !identityManager.isLatestPosition(position)) { + Device device = cacheManager.getObject(Device.class, position.getDeviceId()); + if (device == null || !PositionUtil.isLatest(cacheManager, position)) { return null; } @@ -49,7 +50,7 @@ public class IgnitionEventHandler extends BaseEventHandler { if (position.getAttributes().containsKey(Position.KEY_IGNITION)) { boolean ignition = position.getBoolean(Position.KEY_IGNITION); - Position lastPosition = identityManager.getLastPosition(position.getDeviceId()); + Position lastPosition = cacheManager.getPosition(position.getDeviceId()); if (lastPosition != null && lastPosition.getAttributes().containsKey(Position.KEY_IGNITION)) { boolean oldIgnition = lastPosition.getBoolean(Position.KEY_IGNITION); |