From b298aef26f01154e84e9a00b29ff62921484a220 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 21 Sep 2016 09:29:42 +0500 Subject: - Add two functions to lookup attributes from device to server and from device to config - Removed constant --- src/org/traccar/database/DeviceManager.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/database/DeviceManager.java') diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java index 5f68df831..21e370051 100644 --- a/src/org/traccar/database/DeviceManager.java +++ b/src/org/traccar/database/DeviceManager.java @@ -316,7 +316,16 @@ public class DeviceManager implements IdentityManager { groupsById.remove(groupId); } - public String lookupAttribute(long deviceId, String attributeName) { + public String lookupServerAttribute(long deviceId, String attributeName) { + return lookupAttribute(deviceId, attributeName, true); + } + + public String lookupConfigAttribute(long deviceId, String attributeName) { + return lookupAttribute(deviceId, attributeName, false); + } + + + private String lookupAttribute(long deviceId, String attributeName, boolean lookupServer) { String result = null; Device device = getDeviceById(deviceId); if (device != null) { @@ -338,8 +347,12 @@ public class DeviceManager implements IdentityManager { } } if (result == null) { - Server server = Context.getPermissionsManager().getServer(); - result = (String) server.getAttributes().get(attributeName); + if (lookupServer) { + Server server = Context.getPermissionsManager().getServer(); + result = (String) server.getAttributes().get(attributeName); + } else { + result = Context.getConfig().getString(attributeName); + } } } return result; -- cgit v1.2.3