diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-23 15:49:56 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-23 15:49:56 +1200 |
commit | 2a3fad9496decd83f06ae5abf067f8d4337ec741 (patch) | |
tree | 69837f0bf89cf6ff78915d70380118575cc5c47a /src/org/traccar/database | |
parent | a8d2a0170b7ac891ffe784320ac2d1389f11bf68 (diff) | |
download | trackermap-server-2a3fad9496decd83f06ae5abf067f8d4337ec741.tar.gz trackermap-server-2a3fad9496decd83f06ae5abf067f8d4337ec741.tar.bz2 trackermap-server-2a3fad9496decd83f06ae5abf067f8d4337ec741.zip |
Major code refacroting
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 9bc8ea805..1c6579bf4 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -138,10 +138,11 @@ public class DataManager { private long devicesRefreshDelay; private static final long DEFAULT_REFRESH_DELAY = 300; - public Device getDeviceByImei(String imei) throws SQLException { + public Device getDeviceByUniqueId(String uniqueId) throws SQLException { - if (devices == null || !devices.containsKey(imei) || + if (devices == null || !devices.containsKey(uniqueId) || (Calendar.getInstance().getTimeInMillis() - devicesLastUpdate.getTimeInMillis() > devicesRefreshDelay)) { + devices = new HashMap<String, Device>(); for (Device device : getDevices()) { devices.put(device.getImei(), device); @@ -149,7 +150,7 @@ public class DataManager { devicesLastUpdate = Calendar.getInstance(); } - return devices.get(imei); + return devices.get(uniqueId); } private NamedParameterStatement.ResultSetProcessor<Long> generatedKeysResultSetProcessor = new NamedParameterStatement.ResultSetProcessor<Long>() { |