aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/handler
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-02-25 23:50:42 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-02-25 23:50:42 -0800
commit34a5823cb19d4b957da1c0bdda426eb8e76950d2 (patch)
tree7d4b0efb5614e9c0aa0adac8f6b8a5c08041fa50 /src/org/traccar/handler
parente037b4a39ccc2c93bf738b391b02add31a310d4e (diff)
downloadtraccar-server-34a5823cb19d4b957da1c0bdda426eb8e76950d2.tar.gz
traccar-server-34a5823cb19d4b957da1c0bdda426eb8e76950d2.tar.bz2
traccar-server-34a5823cb19d4b957da1c0bdda426eb8e76950d2.zip
Refactor copy attributes handler
Diffstat (limited to 'src/org/traccar/handler')
-rw-r--r--src/org/traccar/handler/CopyAttributesHandler.java17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/org/traccar/handler/CopyAttributesHandler.java b/src/org/traccar/handler/CopyAttributesHandler.java
index 73642d81b..6a0966d33 100644
--- a/src/org/traccar/handler/CopyAttributesHandler.java
+++ b/src/org/traccar/handler/CopyAttributesHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org)
* Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,29 +18,28 @@ package org.traccar.handler;
import io.netty.channel.ChannelHandler;
import org.traccar.BaseDataHandler;
-import org.traccar.Context;
+import org.traccar.database.IdentityManager;
import org.traccar.model.Position;
@ChannelHandler.Sharable
public class CopyAttributesHandler extends BaseDataHandler {
- private Position getLastPosition(long deviceId) {
- if (Context.getIdentityManager() != null) {
- return Context.getIdentityManager().getLastPosition(deviceId);
- }
- return null;
+ private IdentityManager identityManager;
+
+ public CopyAttributesHandler(IdentityManager identityManager) {
+ this.identityManager = identityManager;
}
@Override
protected Position handlePosition(Position position) {
- String attributesString = Context.getDeviceManager().lookupAttributeString(
+ String attributesString = identityManager.lookupAttributeString(
position.getDeviceId(), "processing.copyAttributes", "", true);
- Position last = getLastPosition(position.getDeviceId());
if (attributesString.isEmpty()) {
attributesString = Position.KEY_DRIVER_UNIQUE_ID;
} else {
attributesString += "," + Position.KEY_DRIVER_UNIQUE_ID;
}
+ Position last = identityManager.getLastPosition(position.getDeviceId());
if (last != null) {
for (String attribute : attributesString.split("[ ,]")) {
if (last.getAttributes().containsKey(attribute) && !position.getAttributes().containsKey(attribute)) {