aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-22 06:28:00 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-11-22 06:28:00 +1300
commitd08857e6c87d41eba835f16035e2da9159de9e49 (patch)
tree771662499c4793b7649caf7270a3a126a6cebeb8 /src/org
parent82f51b570a0957587b25b48fdb5cfd21c4b14e9d (diff)
downloadtrackermap-server-d08857e6c87d41eba835f16035e2da9159de9e49.tar.gz
trackermap-server-d08857e6c87d41eba835f16035e2da9159de9e49.tar.bz2
trackermap-server-d08857e6c87d41eba835f16035e2da9159de9e49.zip
Implement unknown status event
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/api/resource/NotificationResource.java1
-rw-r--r--src/org/traccar/database/ConnectionManager.java16
-rw-r--r--src/org/traccar/database/NotificationManager.java6
-rw-r--r--src/org/traccar/model/Event.java1
4 files changed, 17 insertions, 7 deletions
diff --git a/src/org/traccar/api/resource/NotificationResource.java b/src/org/traccar/api/resource/NotificationResource.java
index 9010babf2..c43cca122 100644
--- a/src/org/traccar/api/resource/NotificationResource.java
+++ b/src/org/traccar/api/resource/NotificationResource.java
@@ -56,4 +56,5 @@ public class NotificationResource extends BaseResource {
Context.getNotificationManager().updateNotification(entity);
return Response.ok(entity).build();
}
+
}
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index 216c90bc2..bc44c31ae 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -76,10 +76,19 @@ public class ConnectionManager {
}
if (enableStatusEvents && !status.equals(device.getStatus())) {
- Event event = new Event(Event.TYPE_DEVICE_OFFLINE, deviceId);
- if (status.equals(Device.STATUS_ONLINE)) {
- event.setType(Event.TYPE_DEVICE_ONLINE);
+ String eventType;
+ switch (status) {
+ case Device.STATUS_ONLINE:
+ eventType = Event.TYPE_DEVICE_ONLINE;
+ break;
+ case Device.STATUS_UNKNOWN:
+ eventType = Event.TYPE_DEVICE_UNKNOWN;
+ break;
+ default:
+ eventType = Event.TYPE_DEVICE_OFFLINE;
+ break;
}
+ Event event = new Event(eventType, deviceId);
if (Context.getNotificationManager() != null) {
Context.getNotificationManager().updateEvent(event, null);
}
@@ -91,7 +100,6 @@ public class ConnectionManager {
timeout.cancel();
}
-
if (time != null) {
device.setLastUpdate(time);
}
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java
index 110f699b7..b82fca0f3 100644
--- a/src/org/traccar/database/NotificationManager.java
+++ b/src/org/traccar/database/NotificationManager.java
@@ -74,7 +74,6 @@ public class NotificationManager {
}
public void updateEvents(Collection<Event> events, Position position) {
-
for (Event event : events) {
updateEvent(event, position);
}
@@ -159,6 +158,7 @@ public class NotificationManager {
}
} else {
notification.setId(cachedNotification.getId());
+ notification.setId(cachedNotification.getId());
}
} else if (!notification.getAttributes().isEmpty()) {
try {
@@ -176,9 +176,8 @@ public class NotificationManager {
}
public Set<Notification> getAllNotifications() {
-
Set<Notification> notifications = new HashSet<>();
- long id = 0;
+ long id = 1;
Field[] fields = Event.class.getDeclaredFields();
for (Field field : fields) {
if (Modifier.isStatic(field.getModifiers()) && field.getName().startsWith("TYPE_")) {
@@ -194,4 +193,5 @@ public class NotificationManager {
}
return notifications;
}
+
}
diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java
index cdb79f04d..3dc4778e1 100644
--- a/src/org/traccar/model/Event.java
+++ b/src/org/traccar/model/Event.java
@@ -40,6 +40,7 @@ public class Event extends Message {
public static final String TYPE_COMMAND_RESULT = "commandResult";
public static final String TYPE_DEVICE_ONLINE = "deviceOnline";
+ public static final String TYPE_DEVICE_UNKNOWN = "deviceUnknown";
public static final String TYPE_DEVICE_OFFLINE = "deviceOffline";
public static final String TYPE_DEVICE_MOVING = "deviceMoving";