From 9476e6be8fae228cda5867750bc4d102b1f9497d Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 16 Aug 2017 16:52:45 +0500 Subject: - Map correct position to delayed event notification - Fix nested condition --- src/org/traccar/database/NotificationManager.java | 11 ++++++++--- src/org/traccar/reports/ReportUtils.java | 6 ++---- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index 0987f255b..8eea287de 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -48,8 +48,13 @@ 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); } @@ -64,16 +69,16 @@ public class NotificationManager { Context.getConnectionManager().updateEvent(userId, event); } if (notification.getMail()) { - NotificationMail.sendMailAsync(userId, event, position); + NotificationMail.sendMailAsync(userId, event, relatedPosition); } if (notification.getSms()) { - NotificationSms.sendSmsAsync(userId, event, position); + NotificationSms.sendSmsAsync(userId, event, relatedPosition); } } } } if (Context.getEventForwarder() != null) { - Context.getEventForwarder().forwardEvent(event, position); + Context.getEventForwarder().forwardEvent(event, relatedPosition); } } diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 6a5370d15..8a398e4c2 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -302,12 +302,10 @@ public final class ReportUtils { startEventIndex = -1; } } - if (startEventIndex != -1) { - if (startNoEventIndex != -1 || !trips) { - result.add(calculateTripOrStop(positions, startEventIndex, + if (startEventIndex != -1 && (startNoEventIndex != -1 || !trips)) { + result.add(calculateTripOrStop(positions, startEventIndex, startNoEventIndex != -1 ? startNoEventIndex : positions.size() - 1, ignoreOdometer, reportClass)); - } } } return result; -- cgit v1.2.3