aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-11-22 12:23:35 +0500
committerAbyss777 <abyss@fox5.ru>2016-11-22 12:23:35 +0500
commit94c3b6e92531a0b666141611e6d9cf311e30a108 (patch)
tree415fc9ad48685234e8559d8aa90ab731bf53603b
parent1861e896418a284dbbccfa55db7add1036bb94ba (diff)
parentcd121c173f7c3ef0a815583eccec1232968894b9 (diff)
downloadtrackermap-server-94c3b6e92531a0b666141611e6d9cf311e30a108.tar.gz
trackermap-server-94c3b6e92531a0b666141611e6d9cf311e30a108.tar.bz2
trackermap-server-94c3b6e92531a0b666141611e6d9cf311e30a108.zip
Merge remote-tracking branch 'upstream/master' into maintenanceevents
-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.java5
-rw-r--r--src/org/traccar/model/Event.java1
4 files changed, 16 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..7e79e289f 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);
}
@@ -176,9 +175,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 +192,5 @@ public class NotificationManager {
}
return notifications;
}
+
}
diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java
index ad861c570..9c252a1c3 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";