diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-18 10:00:52 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-18 10:00:52 -0700 |
commit | c248ed30047a0525bf792730a0fbd4de0c89ad8e (patch) | |
tree | 750adc33654a4f8947e09528cfb85534cfceb8f1 /src/main/java/org/traccar/database/DeviceManager.java | |
parent | 68826cdc767bae6b8b39e88667372f0c6161efa9 (diff) | |
download | trackermap-server-c248ed30047a0525bf792730a0fbd4de0c89ad8e.tar.gz trackermap-server-c248ed30047a0525bf792730a0fbd4de0c89ad8e.tar.bz2 trackermap-server-c248ed30047a0525bf792730a0fbd4de0c89ad8e.zip |
Refactor attribute lookup
Diffstat (limited to 'src/main/java/org/traccar/database/DeviceManager.java')
-rw-r--r-- | src/main/java/org/traccar/database/DeviceManager.java | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java index 81043fd7a..a3e04f920 100644 --- a/src/main/java/org/traccar/database/DeviceManager.java +++ b/src/main/java/org/traccar/database/DeviceManager.java @@ -73,34 +73,6 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity refreshLastPositions(); } - @Override - public Device addUnknownDevice(String uniqueId) { - Device device = new Device(); - device.setName(uniqueId); - device.setUniqueId(uniqueId); - device.setCategory(Context.getConfig().getString(Keys.DATABASE_REGISTER_UNKNOWN_DEFAULT_CATEGORY)); - - long defaultGroupId = Context.getConfig().getLong(Keys.DATABASE_REGISTER_UNKNOWN_DEFAULT_GROUP_ID); - if (defaultGroupId != 0) { - device.setGroupId(defaultGroupId); - } - - try { - addItem(device); - - LOGGER.info("Automatically registered device " + uniqueId); - - if (defaultGroupId != 0) { - Context.getPermissionsManager().refreshDeviceAndGroupPermissions(); - } - - return device; - } catch (StorageException e) { - LOGGER.warn("Automatic device registration error", e); - return null; - } - } - public void updateDeviceCache(boolean force) { long lastUpdate = devicesLastUpdate.get(); if ((force || System.currentTimeMillis() - lastUpdate > dataRefreshDelay) @@ -316,35 +288,6 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity return result != null ? (String) result : defaultValue; } - @Override - 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(); - } - return defaultValue; - } - - @Override - public long lookupAttributeLong( - 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(); - } - return defaultValue; - } - - public double lookupAttributeDouble( - 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 lookupServer, boolean lookupConfig) { Object result = null; Device device = getById(deviceId); |