aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 10:00:52 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 10:00:52 -0700
commitc248ed30047a0525bf792730a0fbd4de0c89ad8e (patch)
tree750adc33654a4f8947e09528cfb85534cfceb8f1 /src/main/java/org/traccar/database
parent68826cdc767bae6b8b39e88667372f0c6161efa9 (diff)
downloadtrackermap-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')
-rw-r--r--src/main/java/org/traccar/database/DeviceManager.java57
-rw-r--r--src/main/java/org/traccar/database/IdentityManager.java11
2 files changed, 0 insertions, 68 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);
diff --git a/src/main/java/org/traccar/database/IdentityManager.java b/src/main/java/org/traccar/database/IdentityManager.java
index ee386fdfd..10a64ebd9 100644
--- a/src/main/java/org/traccar/database/IdentityManager.java
+++ b/src/main/java/org/traccar/database/IdentityManager.java
@@ -20,8 +20,6 @@ import org.traccar.model.Position;
public interface IdentityManager {
- Device addUnknownDevice(String uniqueId);
-
Device getById(long id);
Device getByUniqueId(String uniqueId) throws Exception;
@@ -38,13 +36,4 @@ public interface IdentityManager {
String lookupAttributeString(
long deviceId, String attributeName, String defaultValue, boolean lookupServer, boolean lookupConfig);
- int lookupAttributeInteger(
- long deviceId, String attributeName, int defaultValue, boolean lookupServer, boolean lookupConfig);
-
- long lookupAttributeLong(
- long deviceId, String attributeName, long defaultValue, boolean lookupServer, boolean lookupConfig);
-
- double lookupAttributeDouble(
- long deviceId, String attributeName, double defaultValue, boolean lookupServer, boolean lookupConfig);
-
}