aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-05-27 16:24:14 -0700
committerAnton Tananaev <anton@traccar.org>2024-05-27 16:24:14 -0700
commit4ebc4c6ee6539af45aacf284e331de1fd79b0d0c (patch)
tree6b37a06a44f96a4ba50aff39a8bd433130b3c922 /src/main/java/org/traccar
parent248a3927ddd6606034ac10d2174946c84fee04f0 (diff)
downloadtrackermap-server-4ebc4c6ee6539af45aacf284e331de1fd79b0d0c.tar.gz
trackermap-server-4ebc4c6ee6539af45aacf284e331de1fd79b0d0c.tar.bz2
trackermap-server-4ebc4c6ee6539af45aacf284e331de1fd79b0d0c.zip
Add computed attributes priority
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/handler/ComputedAttributesHandler.java7
-rw-r--r--src/main/java/org/traccar/model/Attribute.java10
2 files changed, 15 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
index 7c2fd70a5..d286866a5 100644
--- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
+++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
@@ -35,13 +35,14 @@ import org.traccar.session.cache.CacheManager;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Date;
+import java.util.stream.Collectors;
public class ComputedAttributesHandler extends BasePositionHandler {
@@ -140,7 +141,9 @@ public class ComputedAttributesHandler extends BasePositionHandler {
@Override
public void handlePosition(Position position, Callback callback) {
- Collection<Attribute> attributes = cacheManager.getDeviceObjects(position.getDeviceId(), Attribute.class);
+ var attributes = cacheManager.getDeviceObjects(position.getDeviceId(), Attribute.class).stream()
+ .sorted(Comparator.comparing(Attribute::getPriority).reversed())
+ .collect(Collectors.toUnmodifiableList());
for (Attribute attribute : attributes) {
if (attribute.getAttribute() != null) {
Object result = null;
diff --git a/src/main/java/org/traccar/model/Attribute.java b/src/main/java/org/traccar/model/Attribute.java
index 65f2e3881..573207170 100644
--- a/src/main/java/org/traccar/model/Attribute.java
+++ b/src/main/java/org/traccar/model/Attribute.java
@@ -61,4 +61,14 @@ public class Attribute extends BaseModel {
this.type = type;
}
+ private int priority;
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
}