From 2a3fad9496decd83f06ae5abf067f8d4337ec741 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 23 Apr 2015 15:49:56 +1200 Subject: Major code refacroting --- src/org/traccar/database/DataManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/database') 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(); 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 generatedKeysResultSetProcessor = new NamedParameterStatement.ResultSetProcessor() { -- cgit v1.2.3