diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-30 17:16:03 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-30 17:16:03 -0700 |
commit | d7c1345f6f070e3931af0ad3fac785130cc9f4dc (patch) | |
tree | fa15821f275b99874414df09cf2e0b0d631fd758 /src/main/java/org/traccar/helper | |
parent | 7b23cebec889705f271bc472a7e62851d7177303 (diff) | |
download | trackermap-server-d7c1345f6f070e3931af0ad3fac785130cc9f4dc.tar.gz trackermap-server-d7c1345f6f070e3931af0ad3fac785130cc9f4dc.tar.bz2 trackermap-server-d7c1345f6f070e3931af0ad3fac785130cc9f4dc.zip |
Fix group attribute lookup (fix #4880)
Diffstat (limited to 'src/main/java/org/traccar/helper')
-rw-r--r-- | src/main/java/org/traccar/helper/model/AttributeUtil.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/model/AttributeUtil.java b/src/main/java/org/traccar/helper/model/AttributeUtil.java index b438f97dc..43558e8f7 100644 --- a/src/main/java/org/traccar/helper/model/AttributeUtil.java +++ b/src/main/java/org/traccar/helper/model/AttributeUtil.java @@ -19,6 +19,7 @@ import org.traccar.config.ConfigKey; import org.traccar.config.KeyType; import org.traccar.config.Keys; import org.traccar.model.Device; +import org.traccar.model.Group; import org.traccar.session.cache.CacheManager; public final class AttributeUtil { @@ -30,6 +31,16 @@ public final class AttributeUtil { public static <T> T lookup(CacheManager cacheManager, ConfigKey<T> key, long deviceId) { Device device = cacheManager.getObject(Device.class, deviceId); Object result = device.getAttributes().get(key.getKey()); + long groupId = device.getGroupId(); + while (result == null && groupId > 0) { + Group group = cacheManager.getObject(Group.class, groupId); + if (group != null) { + result = group.getAttributes().get(key.getKey()); + groupId = group.getGroupId(); + } else { + groupId = 0; + } + } if (result == null && key.hasType(KeyType.SERVER)) { result = cacheManager.getServer().getAttributes().get(key.getKey()); } |