aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database/DeviceManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/database/DeviceManager.java')
-rw-r--r--src/main/java/org/traccar/database/DeviceManager.java36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java
index 62e6de080..d5b1c8c0d 100644
--- a/src/main/java/org/traccar/database/DeviceManager.java
+++ b/src/main/java/org/traccar/database/DeviceManager.java
@@ -324,8 +324,8 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
@Override
public boolean lookupAttributeBoolean(
- long deviceId, String attributeName, boolean defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ long deviceId, String attributeName, boolean defaultValue, boolean lookupServer, boolean lookupConfig) {
+ Object result = lookupAttribute(deviceId, attributeName, lookupServer, lookupConfig);
if (result != null) {
return result instanceof String ? Boolean.parseBoolean((String) result) : (Boolean) result;
}
@@ -334,14 +334,15 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
@Override
public String lookupAttributeString(
- long deviceId, String attributeName, String defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ long deviceId, String attributeName, String defaultValue, boolean lookupServer, boolean lookupConfig) {
+ Object result = lookupAttribute(deviceId, attributeName, lookupServer, lookupConfig);
return result != null ? (String) result : defaultValue;
}
@Override
- public int lookupAttributeInteger(long deviceId, String attributeName, int defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ public int lookupAttributeInteger(
+ long deviceId, String attributeName, int defaultValue, boolean lookupServer, boolean lookupConfig) {
+ Object result = lookupAttribute(deviceId, attributeName, lookupServer, lookupConfig);
if (result != null) {
return result instanceof String ? Integer.parseInt((String) result) : ((Number) result).intValue();
}
@@ -350,8 +351,8 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
@Override
public long lookupAttributeLong(
- long deviceId, String attributeName, long defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ long deviceId, String attributeName, long defaultValue, boolean lookupServer, boolean lookupConfig) {
+ Object result = lookupAttribute(deviceId, attributeName, lookupServer, lookupConfig);
if (result != null) {
return result instanceof String ? Long.parseLong((String) result) : ((Number) result).longValue();
}
@@ -359,15 +360,15 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
}
public double lookupAttributeDouble(
- long deviceId, String attributeName, double defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ long deviceId, String attributeName, double defaultValue, boolean lookupServer, boolean lookupConfig) {
+ Object result = lookupAttribute(deviceId, attributeName, lookupServer, lookupConfig);
if (result != null) {
return result instanceof String ? Double.parseDouble((String) result) : ((Number) result).doubleValue();
}
return defaultValue;
}
- private Object lookupAttribute(long deviceId, String attributeName, boolean lookupConfig) {
+ private Object lookupAttribute(long deviceId, String attributeName, boolean lookupServer, boolean lookupConfig) {
Object result = null;
Device device = getById(deviceId);
if (device != null) {
@@ -387,13 +388,12 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
}
}
}
- if (result == null) {
- if (lookupConfig) {
- result = Context.getConfig().getString(attributeName);
- } else {
- Server server = Context.getPermissionsManager().getServer();
- result = server.getAttributes().get(attributeName);
- }
+ if (result == null && lookupServer) {
+ Server server = Context.getPermissionsManager().getServer();
+ result = server.getAttributes().get(attributeName);
+ }
+ if (result == null && lookupConfig) {
+ result = Context.getConfig().getString(attributeName);
}
}
return result;