aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/reports
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 11:44:40 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 11:44:40 -0700
commit03b50c61afd7c9d7e19a76feb261147dd0f69588 (patch)
tree575f1737e3006c66844c1fa9e06a3323bac7746c /src/main/java/org/traccar/reports
parentddbe4d7de6ae7590e2b927066312597efa129393 (diff)
downloadtrackermap-server-03b50c61afd7c9d7e19a76feb261147dd0f69588.tar.gz
trackermap-server-03b50c61afd7c9d7e19a76feb261147dd0f69588.tar.bz2
trackermap-server-03b50c61afd7c9d7e19a76feb261147dd0f69588.zip
Remove identity manager
Diffstat (limited to 'src/main/java/org/traccar/reports')
-rw-r--r--src/main/java/org/traccar/reports/EventsReportProvider.java3
-rw-r--r--src/main/java/org/traccar/reports/RouteReportProvider.java3
-rw-r--r--src/main/java/org/traccar/reports/StopsReportProvider.java3
-rw-r--r--src/main/java/org/traccar/reports/SummaryReportProvider.java6
-rw-r--r--src/main/java/org/traccar/reports/TripsReportProvider.java3
-rw-r--r--src/main/java/org/traccar/reports/common/ReportUtils.java18
6 files changed, 18 insertions, 18 deletions
diff --git a/src/main/java/org/traccar/reports/EventsReportProvider.java b/src/main/java/org/traccar/reports/EventsReportProvider.java
index 4db842fdb..69d95d1be 100644
--- a/src/main/java/org/traccar/reports/EventsReportProvider.java
+++ b/src/main/java/org/traccar/reports/EventsReportProvider.java
@@ -17,7 +17,6 @@
package org.traccar.reports;
import org.apache.poi.ss.util.WorkbookUtil;
-import org.traccar.Context;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.model.Device;
@@ -133,7 +132,7 @@ public class EventsReportProvider {
}
}
DeviceReportSection deviceEvents = new DeviceReportSection();
- Device device = Context.getIdentityManager().getById(deviceId);
+ Device device = reportUtils.getDevice(deviceId);
deviceEvents.setDeviceName(device.getName());
sheetNames.add(WorkbookUtil.createSafeSheetName(deviceEvents.getDeviceName()));
if (device.getGroupId() > 0) {
diff --git a/src/main/java/org/traccar/reports/RouteReportProvider.java b/src/main/java/org/traccar/reports/RouteReportProvider.java
index b4401bc87..2364cc0f3 100644
--- a/src/main/java/org/traccar/reports/RouteReportProvider.java
+++ b/src/main/java/org/traccar/reports/RouteReportProvider.java
@@ -17,7 +17,6 @@
package org.traccar.reports;
import org.apache.poi.ss.util.WorkbookUtil;
-import org.traccar.Context;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.helper.model.PositionUtil;
@@ -79,7 +78,7 @@ public class RouteReportProvider {
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
var positions = PositionUtil.getPositions(storage, deviceId, from, to);
DeviceReportSection deviceRoutes = new DeviceReportSection();
- Device device = Context.getIdentityManager().getById(deviceId);
+ Device device = reportUtils.getDevice(deviceId);
deviceRoutes.setDeviceName(device.getName());
sheetNames.add(WorkbookUtil.createSafeSheetName(deviceRoutes.getDeviceName()));
if (device.getGroupId() > 0) {
diff --git a/src/main/java/org/traccar/reports/StopsReportProvider.java b/src/main/java/org/traccar/reports/StopsReportProvider.java
index 192d7a0f7..3b1f3c1fe 100644
--- a/src/main/java/org/traccar/reports/StopsReportProvider.java
+++ b/src/main/java/org/traccar/reports/StopsReportProvider.java
@@ -17,7 +17,6 @@
package org.traccar.reports;
import org.apache.poi.ss.util.WorkbookUtil;
-import org.traccar.Context;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.helper.model.PositionUtil;
@@ -86,7 +85,7 @@ public class StopsReportProvider {
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
Collection<StopReportItem> stops = detectStops(deviceId, from, to);
DeviceReportSection deviceStops = new DeviceReportSection();
- Device device = Context.getIdentityManager().getById(deviceId);
+ Device device = reportUtils.getDevice(deviceId);
deviceStops.setDeviceName(device.getName());
sheetNames.add(WorkbookUtil.createSafeSheetName(deviceStops.getDeviceName()));
if (device.getGroupId() > 0) {
diff --git a/src/main/java/org/traccar/reports/SummaryReportProvider.java b/src/main/java/org/traccar/reports/SummaryReportProvider.java
index f3a9786b9..1f136adeb 100644
--- a/src/main/java/org/traccar/reports/SummaryReportProvider.java
+++ b/src/main/java/org/traccar/reports/SummaryReportProvider.java
@@ -17,7 +17,6 @@
package org.traccar.reports;
import org.jxls.util.JxlsHelper;
-import org.traccar.Context;
import org.traccar.api.security.PermissionsService;
import org.traccar.config.Config;
import org.traccar.config.Keys;
@@ -58,10 +57,11 @@ public class SummaryReportProvider {
this.storage = storage;
}
- private SummaryReportItem calculateSummaryResult(long deviceId, Collection<Position> positions) {
+ private SummaryReportItem calculateSummaryResult(
+ long deviceId, Collection<Position> positions) throws StorageException {
SummaryReportItem result = new SummaryReportItem();
result.setDeviceId(deviceId);
- result.setDeviceName(Context.getIdentityManager().getById(deviceId).getName());
+ result.setDeviceName(reportUtils.getDevice(deviceId).getName());
if (positions != null && !positions.isEmpty()) {
Position firstPosition = null;
Position previousPosition = null;
diff --git a/src/main/java/org/traccar/reports/TripsReportProvider.java b/src/main/java/org/traccar/reports/TripsReportProvider.java
index 928609b9e..95612ab30 100644
--- a/src/main/java/org/traccar/reports/TripsReportProvider.java
+++ b/src/main/java/org/traccar/reports/TripsReportProvider.java
@@ -17,7 +17,6 @@
package org.traccar.reports;
import org.apache.poi.ss.util.WorkbookUtil;
-import org.traccar.Context;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.helper.model.PositionUtil;
@@ -85,7 +84,7 @@ public class TripsReportProvider {
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
Collection<TripReportItem> trips = detectTrips(deviceId, from, to);
DeviceReportSection deviceTrips = new DeviceReportSection();
- Device device = Context.getIdentityManager().getById(deviceId);
+ Device device = reportUtils.getDevice(deviceId);
deviceTrips.setDeviceName(device.getName());
sheetNames.add(WorkbookUtil.createSafeSheetName(deviceTrips.getDeviceName()));
if (device.getGroupId() > 0) {
diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java
index bb37bfa9c..ab009161f 100644
--- a/src/main/java/org/traccar/reports/common/ReportUtils.java
+++ b/src/main/java/org/traccar/reports/common/ReportUtils.java
@@ -31,7 +31,6 @@ import org.traccar.api.security.PermissionsService;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.database.DeviceManager;
-import org.traccar.database.IdentityManager;
import org.traccar.geocoder.Geocoder;
import org.traccar.handler.events.MotionEventHandler;
import org.traccar.helper.UnitsConverter;
@@ -74,7 +73,6 @@ public class ReportUtils {
private final Config config;
private final Storage storage;
private final PermissionsService permissionsService;
- private final IdentityManager identityManager;
private final DeviceManager deviceManager;
private final TripsConfig tripsConfig;
private final VelocityEngine velocityEngine;
@@ -82,13 +80,12 @@ public class ReportUtils {
@Inject
public ReportUtils(
- Config config, Storage storage, PermissionsService permissionsService, IdentityManager identityManager,
+ Config config, Storage storage, PermissionsService permissionsService,
DeviceManager deviceManager, TripsConfig tripsConfig, VelocityEngine velocityEngine,
@Nullable Geocoder geocoder) {
this.config = config;
this.storage = storage;
this.permissionsService = permissionsService;
- this.identityManager = identityManager;
this.deviceManager = deviceManager;
this.tripsConfig = tripsConfig;
this.velocityEngine = velocityEngine;
@@ -104,6 +101,12 @@ public class ReportUtils {
new Condition.Permission(User.class, userId, clazz))));
}
+ public Device getDevice(long deviceId) throws StorageException {
+ return storage.getObject(Device.class, new Request(
+ new Columns.Include("id"),
+ new Condition.Equals("id", "id", deviceId)));
+ }
+
public void checkPeriodLimit(Date from, Date to) {
long limit = config.getLong(Keys.REPORT_PERIOD_LIMIT) * 1000;
if (limit > 0 && to.getTime() - from.getTime() > limit) {
@@ -212,7 +215,7 @@ public class ReportUtils {
long tripDuration = endTrip.getFixTime().getTime() - startTrip.getFixTime().getTime();
long deviceId = startTrip.getDeviceId();
trip.setDeviceId(deviceId);
- trip.setDeviceName(identityManager.getById(deviceId).getName());
+ trip.setDeviceName(getDevice(deviceId).getName());
trip.setStartPositionId(startTrip.getId());
trip.setStartLat(startTrip.getLatitude());
@@ -259,7 +262,8 @@ public class ReportUtils {
}
private StopReportItem calculateStop(
- ArrayList<Position> positions, int startIndex, int endIndex, boolean ignoreOdometer) {
+ ArrayList<Position> positions, int startIndex, int endIndex,
+ boolean ignoreOdometer) throws StorageException {
Position startStop = positions.get(startIndex);
Position endStop = positions.get(endIndex);
@@ -268,7 +272,7 @@ public class ReportUtils {
long deviceId = startStop.getDeviceId();
stop.setDeviceId(deviceId);
- stop.setDeviceName(identityManager.getById(deviceId).getName());
+ stop.setDeviceName(getDevice(deviceId).getName());
stop.setPositionId(startStop.getId());
stop.setLatitude(startStop.getLatitude());