aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/DataManager.java
diff options
context:
space:
mode:
authorninioe <ninioe@gmail.com>2016-07-17 09:55:25 +0300
committerninioe <ninioe@gmail.com>2016-07-17 09:55:25 +0300
commit5380ff196c88cc6b57fff62db71e4ab3a05aaa98 (patch)
tree636f455a5d2a946ccff892ea6db84fb155ff8f69 /src/org/traccar/database/DataManager.java
parent4d55b911bd252c90d1d0ec4053d8502154192676 (diff)
parent6dfd599ef69fac9ea0851e3c07873c6368231610 (diff)
downloadtrackermap-server-5380ff196c88cc6b57fff62db71e4ab3a05aaa98.tar.gz
trackermap-server-5380ff196c88cc6b57fff62db71e4ab3a05aaa98.tar.bz2
trackermap-server-5380ff196c88cc6b57fff62db71e4ab3a05aaa98.zip
Merge remote-tracking branch 'refs/remotes/tananaev/master'
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-rw-r--r--src/org/traccar/database/DataManager.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index a9fc09448..239fc1930 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -401,9 +401,11 @@ public class DataManager implements IdentityManager {
QueryBuilder.create(dataSource, getQuery("database.updateDeviceStatus"))
.setObject(device)
.executeUpdate();
- Device cachedDevice = getDeviceById(device.getId());
- cachedDevice.setStatus(device.getStatus());
- cachedDevice.setMotion(device.getMotion());
+ if (devicesById.containsKey(device.getId())) {
+ Device cachedDevice = devicesById.get(device.getId());
+ cachedDevice.setStatus(device.getStatus());
+ cachedDevice.setMotion(device.getMotion());
+ }
}
public void removeDevice(long deviceId) throws SQLException {
@@ -512,8 +514,10 @@ public class DataManager implements IdentityManager {
.setDate("now", new Date())
.setObject(position)
.executeUpdate();
- Device device = getDeviceById(position.getDeviceId());
- device.setPositionId(position.getId());
+ if (devicesById.containsKey(position.getDeviceId())) {
+ Device cachedDevice = devicesById.get(position.getDeviceId());
+ cachedDevice.setPositionId(position.getId());
+ }
}
public Collection<Position> getLatestPositions() throws SQLException {