aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 10:27:24 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 10:27:24 -0700
commit97a189c51817a6b1d7a86aece8a91ff378488799 (patch)
tree9f47127dafa956ae6a8f98c818a9fbcef5432a5b /src/main/java/org/traccar/handler
parent22bd8bcc80b850dc2308be50cf2886c39b0655da (diff)
downloadtrackermap-server-97a189c51817a6b1d7a86aece8a91ff378488799.tar.gz
trackermap-server-97a189c51817a6b1d7a86aece8a91ff378488799.tar.bz2
trackermap-server-97a189c51817a6b1d7a86aece8a91ff378488799.zip
Refactor attribute lookup
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r--src/main/java/org/traccar/handler/CopyAttributesHandler.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/handler/CopyAttributesHandler.java b/src/main/java/org/traccar/handler/CopyAttributesHandler.java
index 8285dcc5d..405a52ecd 100644
--- a/src/main/java/org/traccar/handler/CopyAttributesHandler.java
+++ b/src/main/java/org/traccar/handler/CopyAttributesHandler.java
@@ -20,8 +20,9 @@ import io.netty.channel.ChannelHandler;
import org.traccar.BaseDataHandler;
import org.traccar.config.Config;
import org.traccar.config.Keys;
-import org.traccar.database.IdentityManager;
+import org.traccar.helper.model.AttributeUtil;
import org.traccar.model.Position;
+import org.traccar.session.cache.CacheManager;
import javax.inject.Inject;
@@ -29,20 +30,20 @@ import javax.inject.Inject;
public class CopyAttributesHandler extends BaseDataHandler {
private final boolean enabled;
- private final IdentityManager identityManager;
+ private final CacheManager cacheManager;
@Inject
- public CopyAttributesHandler(Config config, IdentityManager identityManager) {
+ public CopyAttributesHandler(Config config, CacheManager cacheManager) {
enabled = config.getBoolean(Keys.PROCESSING_COPY_ATTRIBUTES_ENABLE);
- this.identityManager = identityManager;
+ this.cacheManager = cacheManager;
}
@Override
protected Position handlePosition(Position position) {
if (enabled) {
- String attributesString = identityManager.lookupAttributeString(
- position.getDeviceId(), "processing.copyAttributes", "", false, true);
- Position last = identityManager.getLastPosition(position.getDeviceId());
+ String attributesString = AttributeUtil.lookup(
+ cacheManager, Keys.PROCESSING_COPY_ATTRIBUTES, position.getDeviceId());
+ Position last = cacheManager.getPosition(position.getDeviceId());
if (last != null) {
for (String attribute : attributesString.split("[ ,]")) {
if (last.getAttributes().containsKey(attribute)