aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/BaseProtocolEncoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-02-19 11:53:08 -0800
committerAnton Tananaev <anton@traccar.org>2024-02-19 11:53:14 -0800
commitefd9e261791942334dbf4a911883a1b2b791f282 (patch)
tree8aa830282cd64b9b3a28e858865a8783b1eea3bc /src/main/java/org/traccar/BaseProtocolEncoder.java
parent26548bb534de6c9944ece5a2aa5216da83cb8819 (diff)
downloadtrackermap-server-efd9e261791942334dbf4a911883a1b2b791f282.tar.gz
trackermap-server-efd9e261791942334dbf4a911883a1b2b791f282.tar.bz2
trackermap-server-efd9e261791942334dbf4a911883a1b2b791f282.zip
Streamline model name access
Diffstat (limited to 'src/main/java/org/traccar/BaseProtocolEncoder.java')
-rw-r--r--src/main/java/org/traccar/BaseProtocolEncoder.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolEncoder.java b/src/main/java/org/traccar/BaseProtocolEncoder.java
index b9ca16838..e357c27dc 100644
--- a/src/main/java/org/traccar/BaseProtocolEncoder.java
+++ b/src/main/java/org/traccar/BaseProtocolEncoder.java
@@ -39,6 +39,8 @@ public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter
private CacheManager cacheManager;
+ private String modelOverride;
+
public BaseProtocolEncoder(Protocol protocol) {
this.protocol = protocol;
}
@@ -68,6 +70,15 @@ public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter
}
}
+ public void setModelOverride(String modelOverride) {
+ this.modelOverride = modelOverride;
+ }
+
+ public String getDeviceModel(long deviceId) {
+ String model = getCacheManager().getObject(Device.class, deviceId).getModel();
+ return modelOverride != null ? modelOverride : model;
+ }
+
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {