From b2584fc441a7dde87f97c66e23a7cabd9591fd13 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 21 Mar 2017 17:16:56 +0500 Subject: Set status to offline for new device --- src/org/traccar/database/DeviceManager.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/org') diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java index ae5784b01..a6caf0e47 100644 --- a/src/org/traccar/database/DeviceManager.java +++ b/src/org/traccar/database/DeviceManager.java @@ -202,6 +202,7 @@ public class DeviceManager implements IdentityManager { public void addDevice(Device device) throws SQLException { dataManager.addDevice(device); + device.setStatus(Device.STATUS_OFFLINE); devicesById.put(device.getId(), device); devicesByUniqueId.put(device.getUniqueId(), device); if (device.getPhone() != null && !device.getPhone().isEmpty()) { -- cgit v1.2.3 From ce809d8f053360bd820cf05175101b92a40b8109 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 22 Mar 2017 17:16:04 +0500 Subject: Move device status initialization to model --- src/org/traccar/database/DeviceManager.java | 1 - src/org/traccar/model/Device.java | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java index a6caf0e47..ae5784b01 100644 --- a/src/org/traccar/database/DeviceManager.java +++ b/src/org/traccar/database/DeviceManager.java @@ -202,7 +202,6 @@ public class DeviceManager implements IdentityManager { public void addDevice(Device device) throws SQLException { dataManager.addDevice(device); - device.setStatus(Device.STATUS_OFFLINE); devicesById.put(device.getId(), device); devicesByUniqueId.put(device.getUniqueId(), device); if (device.getPhone() != null && !device.getPhone().isEmpty()) { diff --git a/src/org/traccar/model/Device.java b/src/org/traccar/model/Device.java index 22426c4db..4c02481ca 100644 --- a/src/org/traccar/model/Device.java +++ b/src/org/traccar/model/Device.java @@ -51,7 +51,11 @@ public class Device extends Extensible { } public void setStatus(String status) { - this.status = status; + if (STATUS_ONLINE.equals(status) || STATUS_UNKNOWN.equals(status)) { + this.status = status; + } else { + this.status = STATUS_OFFLINE; + } } private Date lastUpdate; -- cgit v1.2.3 From ff9f34d6e685119c5d85d705d6cbd4f29149eee0 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 23 Mar 2017 10:21:25 +0500 Subject: Move default device status to getter --- src/org/traccar/database/DeviceManager.java | 1 - src/org/traccar/model/Device.java | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java index ae5784b01..68e2e8262 100644 --- a/src/org/traccar/database/DeviceManager.java +++ b/src/org/traccar/database/DeviceManager.java @@ -131,7 +131,6 @@ public class DeviceManager implements IdentityManager { device.setGeofenceIds(geofenceManager.getCurrentDeviceGeofences(lastPosition)); } } - device.setStatus(Device.STATUS_OFFLINE); } } for (Iterator iterator = devicesById.keySet().iterator(); iterator.hasNext();) { diff --git a/src/org/traccar/model/Device.java b/src/org/traccar/model/Device.java index 4c02481ca..2324da532 100644 --- a/src/org/traccar/model/Device.java +++ b/src/org/traccar/model/Device.java @@ -47,15 +47,11 @@ public class Device extends Extensible { private String status; public String getStatus() { - return status; + return status != null ? status : STATUS_OFFLINE; } public void setStatus(String status) { - if (STATUS_ONLINE.equals(status) || STATUS_UNKNOWN.equals(status)) { - this.status = status; - } else { - this.status = STATUS_OFFLINE; - } + this.status = status; } private Date lastUpdate; -- cgit v1.2.3