aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/Context.java20
-rw-r--r--src/main/java/org/traccar/MainModule.java6
-rw-r--r--src/main/java/org/traccar/reports/StopsReportProvider.java7
-rw-r--r--src/main/java/org/traccar/reports/TripsReportProvider.java7
-rw-r--r--src/main/java/org/traccar/reports/common/TripsConfig.java20
5 files changed, 29 insertions, 31 deletions
diff --git a/src/main/java/org/traccar/Context.java b/src/main/java/org/traccar/Context.java
index 1e158438f..46c761094 100644
--- a/src/main/java/org/traccar/Context.java
+++ b/src/main/java/org/traccar/Context.java
@@ -41,7 +41,6 @@ import org.traccar.model.Notification;
import org.traccar.model.User;
import org.traccar.notification.EventForwarder;
import org.traccar.notification.NotificatorManager;
-import org.traccar.reports.common.TripsConfig;
import org.traccar.session.ConnectionManager;
import org.traccar.session.cache.CacheManager;
import org.traccar.sms.HttpSmsClient;
@@ -167,23 +166,6 @@ public final class Context {
return smsManager;
}
- private static TripsConfig tripsConfig;
-
- public static TripsConfig getTripsConfig() {
- return tripsConfig;
- }
-
- public static TripsConfig initTripsConfig() {
- return new TripsConfig(
- config.getLong(Keys.REPORT_TRIP_MINIMAL_TRIP_DISTANCE),
- config.getLong(Keys.REPORT_TRIP_MINIMAL_TRIP_DURATION) * 1000,
- config.getLong(Keys.REPORT_TRIP_MINIMAL_PARKING_DURATION) * 1000,
- config.getLong(Keys.REPORT_TRIP_MINIMAL_NO_DATA_DURATION) * 1000,
- config.getBoolean(Keys.REPORT_TRIP_USE_IGNITION),
- config.getBoolean(Keys.EVENT_MOTION_PROCESS_INVALID_POSITIONS),
- config.getDouble(Keys.EVENT_MOTION_SPEED_THRESHOLD));
- }
-
private static class ObjectMapperContextResolver implements ContextResolver<ObjectMapper> {
@Override
@@ -236,8 +218,6 @@ public final class Context {
connectionManager = new ConnectionManager();
- tripsConfig = initTripsConfig();
-
if (config.hasKey(Keys.SMS_HTTP_URL)) {
smsManager = new HttpSmsClient();
} else if (config.hasKey(Keys.SMS_AWS_REGION)) {
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index c9f2d4e62..d070c9fd7 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -57,7 +57,6 @@ import org.traccar.geolocation.UnwiredGeolocationProvider;
import org.traccar.handler.GeocoderHandler;
import org.traccar.handler.GeolocationHandler;
import org.traccar.handler.SpeedLimitHandler;
-import org.traccar.reports.common.TripsConfig;
import org.traccar.sms.SmsManager;
import org.traccar.speedlimit.OverpassSpeedLimitProvider;
import org.traccar.speedlimit.SpeedLimitProvider;
@@ -111,11 +110,6 @@ public class MainModule extends AbstractModule {
}
@Provides
- public static TripsConfig provideTripsConfig() {
- return Context.getTripsConfig();
- }
-
- @Provides
public static DeviceManager provideDeviceManager() {
return Context.getDeviceManager();
}
diff --git a/src/main/java/org/traccar/reports/StopsReportProvider.java b/src/main/java/org/traccar/reports/StopsReportProvider.java
index 8899dc42f..b7896c423 100644
--- a/src/main/java/org/traccar/reports/StopsReportProvider.java
+++ b/src/main/java/org/traccar/reports/StopsReportProvider.java
@@ -34,6 +34,7 @@ import org.traccar.database.IdentityManager;
import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.reports.common.ReportUtils;
+import org.traccar.reports.common.TripsConfig;
import org.traccar.reports.model.DeviceReportSection;
import org.traccar.reports.model.StopReportItem;
import org.traccar.storage.Storage;
@@ -45,11 +46,13 @@ public class StopsReportProvider {
private final PermissionsService permissionsService;
private final Storage storage;
+ private final TripsConfig tripsConfig;
@Inject
- public StopsReportProvider(PermissionsService permissionsService, Storage storage) {
+ public StopsReportProvider(PermissionsService permissionsService, Storage storage, TripsConfig tripsConfig) {
this.permissionsService = permissionsService;
this.storage = storage;
+ this.tripsConfig = tripsConfig;
}
private Collection<StopReportItem> detectStops(long deviceId, Date from, Date to) throws StorageException {
@@ -61,7 +64,7 @@ public class StopsReportProvider {
return ReportUtils.detectTripsAndStops(
storage, identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to),
- Context.getTripsConfig(), ignoreOdometer, StopReportItem.class);
+ tripsConfig, ignoreOdometer, StopReportItem.class);
}
public Collection<StopReportItem> getObjects(
diff --git a/src/main/java/org/traccar/reports/TripsReportProvider.java b/src/main/java/org/traccar/reports/TripsReportProvider.java
index bcd79ab25..0505baaa1 100644
--- a/src/main/java/org/traccar/reports/TripsReportProvider.java
+++ b/src/main/java/org/traccar/reports/TripsReportProvider.java
@@ -33,6 +33,7 @@ import org.traccar.database.IdentityManager;
import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.reports.common.ReportUtils;
+import org.traccar.reports.common.TripsConfig;
import org.traccar.reports.model.DeviceReportSection;
import org.traccar.reports.model.TripReportItem;
import org.traccar.storage.Storage;
@@ -44,11 +45,13 @@ public class TripsReportProvider {
private final PermissionsService permissionsService;
private final Storage storage;
+ private final TripsConfig tripsConfig;
@Inject
- public TripsReportProvider(PermissionsService permissionsService, Storage storage) {
+ public TripsReportProvider(PermissionsService permissionsService, Storage storage, TripsConfig tripsConfig) {
this.permissionsService = permissionsService;
this.storage = storage;
+ this.tripsConfig = tripsConfig;
}
private Collection<TripReportItem> detectTrips(long deviceId, Date from, Date to) throws StorageException {
@@ -60,7 +63,7 @@ public class TripsReportProvider {
return ReportUtils.detectTripsAndStops(
storage, identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to),
- Context.getTripsConfig(), ignoreOdometer, TripReportItem.class);
+ tripsConfig, ignoreOdometer, TripReportItem.class);
}
public Collection<TripReportItem> getObjects(long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
diff --git a/src/main/java/org/traccar/reports/common/TripsConfig.java b/src/main/java/org/traccar/reports/common/TripsConfig.java
index 9a7cebafb..c28cbeed4 100644
--- a/src/main/java/org/traccar/reports/common/TripsConfig.java
+++ b/src/main/java/org/traccar/reports/common/TripsConfig.java
@@ -16,9 +16,27 @@
*/
package org.traccar.reports.common;
+import org.traccar.config.Config;
+import org.traccar.config.Keys;
+
+import javax.inject.Inject;
+
public class TripsConfig {
- public TripsConfig(double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration,
+ @Inject
+ public TripsConfig(Config config) {
+ this(
+ config.getLong(Keys.REPORT_TRIP_MINIMAL_TRIP_DISTANCE),
+ config.getLong(Keys.REPORT_TRIP_MINIMAL_TRIP_DURATION) * 1000,
+ config.getLong(Keys.REPORT_TRIP_MINIMAL_PARKING_DURATION) * 1000,
+ config.getLong(Keys.REPORT_TRIP_MINIMAL_NO_DATA_DURATION) * 1000,
+ config.getBoolean(Keys.REPORT_TRIP_USE_IGNITION),
+ config.getBoolean(Keys.EVENT_MOTION_PROCESS_INVALID_POSITIONS),
+ config.getDouble(Keys.EVENT_MOTION_SPEED_THRESHOLD));
+ }
+
+ public TripsConfig(
+ double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration,
long minimalNoDataDuration, boolean useIgnition, boolean processInvalidPositions, double speedThreshold) {
this.minimalTripDistance = minimalTripDistance;
this.minimalTripDuration = minimalTripDuration;