aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-06-14 21:08:21 -0600
committerIván Ávalos <avalos@disroot.org>2024-06-14 21:08:21 -0600
commit471dc4ca7b6cfd656cc2c04c526fe56ee538991c (patch)
tree4766fa7209e2eaab65269db456cf0436e6a64a49 /src/main/java/org/traccar/handler/ComputedAttributesHandler.java
parent447c7e15fcec8fc72d0457bb7dbf166cbea84acd (diff)
parent64528b96da4a742070d5845a876b07ca66ad0be3 (diff)
downloadtrackermap-server-471dc4ca7b6cfd656cc2c04c526fe56ee538991c.tar.gz
trackermap-server-471dc4ca7b6cfd656cc2c04c526fe56ee538991c.tar.bz2
trackermap-server-471dc4ca7b6cfd656cc2c04c526fe56ee538991c.zip
Merge tag 'v6.2'
Diffstat (limited to 'src/main/java/org/traccar/handler/ComputedAttributesHandler.java')
-rw-r--r--src/main/java/org/traccar/handler/ComputedAttributesHandler.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
index 4293bd1fc..d286866a5 100644
--- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
+++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
@@ -35,12 +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 {
@@ -63,7 +65,7 @@ public class ComputedAttributesHandler extends BasePositionHandler {
sandbox.allow(Math.class.getName());
List.of(
Double.class, Float.class, Integer.class, Long.class, Short.class,
- Character.class, Boolean.class, String.class, Byte.class)
+ Character.class, Boolean.class, String.class, Byte.class, Date.class)
.forEach((type) -> sandbox.allow(type.getName()));
features = new JexlFeatures()
.localVar(config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_LOCAL_VARIABLES))
@@ -139,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;