aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/reports
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-05-14 14:07:50 -0700
committerAnton Tananaev <anton@traccar.org>2023-05-14 14:07:50 -0700
commita96a75cc268f2819431b7441090052b01bf61bed (patch)
tree287c556e270b05a489bc96a4756c82a754af7a41 /src/main/java/org/traccar/reports
parentf68d23d79d0321ef47f72fff2388b5f4aac1beff (diff)
downloadtrackermap-server-a96a75cc268f2819431b7441090052b01bf61bed.tar.gz
trackermap-server-a96a75cc268f2819431b7441090052b01bf61bed.tar.bz2
trackermap-server-a96a75cc268f2819431b7441090052b01bf61bed.zip
Per device trip config
Diffstat (limited to 'src/main/java/org/traccar/reports')
-rw-r--r--src/main/java/org/traccar/reports/common/ReportUtils.java7
-rw-r--r--src/main/java/org/traccar/reports/common/TripsConfig.java31
2 files changed, 13 insertions, 25 deletions
diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java
index 0c168e4ef..f5aa6d040 100644
--- a/src/main/java/org/traccar/reports/common/ReportUtils.java
+++ b/src/main/java/org/traccar/reports/common/ReportUtils.java
@@ -31,6 +31,7 @@ import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.geocoder.Geocoder;
import org.traccar.helper.UnitsConverter;
+import org.traccar.helper.model.AttributeUtil;
import org.traccar.helper.model.PositionUtil;
import org.traccar.helper.model.UserUtil;
import org.traccar.model.BaseModel;
@@ -67,18 +68,16 @@ public class ReportUtils {
private final Config config;
private final Storage storage;
private final PermissionsService permissionsService;
- private final TripsConfig tripsConfig;
private final VelocityEngine velocityEngine;
private final Geocoder geocoder;
@Inject
public ReportUtils(
Config config, Storage storage, PermissionsService permissionsService,
- TripsConfig tripsConfig, VelocityEngine velocityEngine, @Nullable Geocoder geocoder) {
+ VelocityEngine velocityEngine, @Nullable Geocoder geocoder) {
this.config = config;
this.storage = storage;
this.permissionsService = permissionsService;
- this.tripsConfig = tripsConfig;
this.velocityEngine = velocityEngine;
this.geocoder = geocoder;
}
@@ -306,6 +305,8 @@ public class ReportUtils {
Class<T> reportClass) throws StorageException {
Collection<T> result = new ArrayList<>();
+ TripsConfig tripsConfig = new TripsConfig(
+ new AttributeUtil.StorageProvider(config, storage, permissionsService, device));
ArrayList<Position> positions = new ArrayList<>(positionCollection);
if (!positions.isEmpty()) {
diff --git a/src/main/java/org/traccar/reports/common/TripsConfig.java b/src/main/java/org/traccar/reports/common/TripsConfig.java
index 841d9c652..2792114d4 100644
--- a/src/main/java/org/traccar/reports/common/TripsConfig.java
+++ b/src/main/java/org/traccar/reports/common/TripsConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2023 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,35 +16,28 @@
*/
package org.traccar.reports.common;
-import org.traccar.config.Config;
import org.traccar.config.Keys;
+import org.traccar.helper.model.AttributeUtil;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-@Singleton
public class TripsConfig {
- @Inject
- public TripsConfig(Config config) {
+ public TripsConfig(AttributeUtil.Provider attributeProvider) {
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));
+ AttributeUtil.lookup(attributeProvider, Keys.REPORT_TRIP_MINIMAL_TRIP_DISTANCE),
+ AttributeUtil.lookup(attributeProvider, Keys.REPORT_TRIP_MINIMAL_TRIP_DURATION) * 1000,
+ AttributeUtil.lookup(attributeProvider, Keys.REPORT_TRIP_MINIMAL_PARKING_DURATION) * 1000,
+ AttributeUtil.lookup(attributeProvider, Keys.REPORT_TRIP_MINIMAL_NO_DATA_DURATION) * 1000,
+ AttributeUtil.lookup(attributeProvider, Keys.REPORT_TRIP_USE_IGNITION));
}
public TripsConfig(
double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration,
- long minimalNoDataDuration, boolean useIgnition, boolean processInvalidPositions) {
+ long minimalNoDataDuration, boolean useIgnition) {
this.minimalTripDistance = minimalTripDistance;
this.minimalTripDuration = minimalTripDuration;
this.minimalParkingDuration = minimalParkingDuration;
this.minimalNoDataDuration = minimalNoDataDuration;
this.useIgnition = useIgnition;
- this.processInvalidPositions = processInvalidPositions;
}
private final double minimalTripDistance;
@@ -77,10 +70,4 @@ public class TripsConfig {
return useIgnition;
}
- private final boolean processInvalidPositions;
-
- public boolean getProcessInvalidPositions() {
- return processInvalidPositions;
- }
-
}