diff options
author | Abyss777 <abyss@fox5.ru> | 2017-08-17 10:10:05 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-08-17 10:10:05 +0500 |
commit | 1324c00d0ece6e20545fb75f7775a2c6cee2a391 (patch) | |
tree | 775ad2a42ebba160d1e36be38c59384cd1da5a1e /src/org/traccar/database/NotificationManager.java | |
parent | 9476e6be8fae228cda5867750bc4d102b1f9497d (diff) | |
download | trackermap-server-1324c00d0ece6e20545fb75f7775a2c6cee2a391.tar.gz trackermap-server-1324c00d0ece6e20545fb75f7775a2c6cee2a391.tar.bz2 trackermap-server-1324c00d0ece6e20545fb75f7775a2c6cee2a391.zip |
Pass Map<Event, Position> to notifications
Diffstat (limited to 'src/org/traccar/database/NotificationManager.java')
-rw-r--r-- | src/org/traccar/database/NotificationManager.java | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index 8eea287de..98cae3499 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -48,13 +49,8 @@ public class NotificationManager { } public void updateEvent(Event event, Position position) { - Position relatedPosition = position; try { dataManager.addObject(event); - if (event.getPositionId() != 0 && (relatedPosition == null - || event.getPositionId() != relatedPosition.getId())) { - relatedPosition = dataManager.getObject(Position.class, event.getPositionId()); - } } catch (SQLException error) { Log.warning(error); } @@ -69,22 +65,22 @@ public class NotificationManager { Context.getConnectionManager().updateEvent(userId, event); } if (notification.getMail()) { - NotificationMail.sendMailAsync(userId, event, relatedPosition); + NotificationMail.sendMailAsync(userId, event, position); } if (notification.getSms()) { - NotificationSms.sendSmsAsync(userId, event, relatedPosition); + NotificationSms.sendSmsAsync(userId, event, position); } } } } if (Context.getEventForwarder() != null) { - Context.getEventForwarder().forwardEvent(event, relatedPosition); + Context.getEventForwarder().forwardEvent(event, position); } } - public void updateEvents(Collection<Event> events, Position position) { - for (Event event : events) { - updateEvent(event, position); + public void updateEvents(Map<Event, Position> events) { + for (Entry<Event, Position> event : events.entrySet()) { + updateEvent(event.getKey(), event.getValue()); } } |