diff options
author | Abyss777 <abyss@fox5.ru> | 2018-04-13 12:21:05 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2018-04-13 12:21:05 +0500 |
commit | 30ae3d104e9b0446364ebc316dc10d0f811e1480 (patch) | |
tree | b1e0a223e4cb68c5869fcb5cec9b13e893e749da | |
parent | 87de21e95c34936e7d7635c3dd8c07f6221f46eb (diff) | |
download | traccar-server-30ae3d104e9b0446364ebc316dc10d0f811e1480.tar.gz traccar-server-30ae3d104e9b0446364ebc316dc10d0f811e1480.tar.bz2 traccar-server-30ae3d104e9b0446364ebc316dc10d0f811e1480.zip |
- Rename field to Period
- Remove unnecessary check for null
- Move MaintenanceManager initialization with other event related managers
-rw-r--r-- | schema/changelog-3.17.xml | 2 | ||||
-rw-r--r-- | src/org/traccar/Context.java | 3 | ||||
-rw-r--r-- | src/org/traccar/database/NotificationManager.java | 4 | ||||
-rw-r--r-- | src/org/traccar/events/MaintenanceEventHandler.java | 6 | ||||
-rw-r--r-- | src/org/traccar/model/Maintenance.java | 10 |
5 files changed, 12 insertions, 13 deletions
diff --git a/schema/changelog-3.17.xml b/schema/changelog-3.17.xml index 5e67fe75d..ef296fe25 100644 --- a/schema/changelog-3.17.xml +++ b/schema/changelog-3.17.xml @@ -25,7 +25,7 @@ <column name="start" type="DOUBLE" defaultValueNumeric="0"> <constraints nullable="false" /> </column> - <column name="lapse" type="DOUBLE" defaultValueNumeric="0"> + <column name="period" type="DOUBLE" defaultValueNumeric="0"> <constraints nullable="false" /> </column> <column name="attributes" type="VARCHAR(4000)"> diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index a1a5f5a8e..67fd02f75 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -393,8 +393,6 @@ public final class Context { commandsManager = new CommandsManager(dataManager); - maintenancesManager = new MaintenancesManager(dataManager); - statisticsManager = new StatisticsManager(); if (config.getBoolean("sms.smpp.enable")) { @@ -429,6 +427,7 @@ public final class Context { geofenceManager = new GeofenceManager(dataManager); calendarManager = new CalendarManager(dataManager); + maintenancesManager = new MaintenancesManager(dataManager); notificationManager = new NotificationManager(dataManager); Properties velocityProperties = new Properties(); velocityProperties.setProperty("file.resource.loader.path", diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index 9f2606f7f..3bc048356 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -78,8 +78,8 @@ public class NotificationManager extends ExtendedObjectManager<Notification> { usersToForward = new HashSet<>(); } for (long userId : users) { - if ((event.getGeofenceId() == 0 || Context.getGeofenceManager() != null - && Context.getGeofenceManager().checkItemPermission(userId, event.getGeofenceId())) + if ((event.getGeofenceId() == 0 + || Context.getGeofenceManager().checkItemPermission(userId, event.getGeofenceId())) && (event.getMaintenanceId() == 0 || Context.getMaintenancesManager().checkItemPermission(userId, event.getMaintenanceId()))) { if (usersToForward != null) { diff --git a/src/org/traccar/events/MaintenanceEventHandler.java b/src/org/traccar/events/MaintenanceEventHandler.java index b556e1003..4a6122826 100644 --- a/src/org/traccar/events/MaintenanceEventHandler.java +++ b/src/org/traccar/events/MaintenanceEventHandler.java @@ -42,12 +42,12 @@ public class MaintenanceEventHandler extends BaseEventHandler { Map<Event, Position> events = new HashMap<>(); for (long maintenanceId : Context.getMaintenancesManager().getAllDeviceItems(position.getDeviceId())) { Maintenance maintenance = Context.getMaintenancesManager().getById(maintenanceId); - if (maintenance.getLapse() != 0) { + if (maintenance.getPeriod() != 0) { double oldValue = lastPosition.getDouble(maintenance.getType()); double newValue = position.getDouble(maintenance.getType()); if (oldValue != 0.0 && newValue != 0.0 - && (long) ((oldValue - maintenance.getStart()) / maintenance.getLapse()) - < (long) ((newValue - maintenance.getStart()) / maintenance.getLapse())) { + && (long) ((oldValue - maintenance.getStart()) / maintenance.getPeriod()) + < (long) ((newValue - maintenance.getStart()) / maintenance.getPeriod())) { Event event = new Event(Event.TYPE_MAINTENANCE, position.getDeviceId(), position.getId()); event.setMaintenanceId(maintenanceId); event.set(maintenance.getType(), newValue); diff --git a/src/org/traccar/model/Maintenance.java b/src/org/traccar/model/Maintenance.java index 82052e160..73f67ea96 100644 --- a/src/org/traccar/model/Maintenance.java +++ b/src/org/traccar/model/Maintenance.java @@ -48,14 +48,14 @@ public class Maintenance extends ExtendedModel { this.start = start; } - private double lapse; + private double period; - public double getLapse() { - return lapse; + public double getPeriod() { + return period; } - public void setLapse(double lapse) { - this.lapse = lapse; + public void setPeriod(double period) { + this.period = period; } } |