diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-04 11:01:01 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-04 11:01:01 -0700 |
commit | 31c4ad41f4d91dec3c98af06614e9518d3689a14 (patch) | |
tree | 6606a8e8e4f35d86bf0f6cc4da6d3ebd54f9ae23 /src/main/java/org/traccar/reports | |
parent | 94a2a94330d82fa1c1960b8783e5061c188196e3 (diff) | |
download | trackermap-server-31c4ad41f4d91dec3c98af06614e9518d3689a14.tar.gz trackermap-server-31c4ad41f4d91dec3c98af06614e9518d3689a14.tar.bz2 trackermap-server-31c4ad41f4d91dec3c98af06614e9518d3689a14.zip |
Inject report providers
Diffstat (limited to 'src/main/java/org/traccar/reports')
-rw-r--r-- | src/main/java/org/traccar/reports/EventsReportProvider.java (renamed from src/main/java/org/traccar/reports/Events.java) | 9 | ||||
-rw-r--r-- | src/main/java/org/traccar/reports/RouteReportProvider.java (renamed from src/main/java/org/traccar/reports/Route.java) | 11 | ||||
-rw-r--r-- | src/main/java/org/traccar/reports/StopsReportProvider.java (renamed from src/main/java/org/traccar/reports/Stops.java) | 13 | ||||
-rw-r--r-- | src/main/java/org/traccar/reports/SummaryReportProvider.java (renamed from src/main/java/org/traccar/reports/Summary.java) | 18 | ||||
-rw-r--r-- | src/main/java/org/traccar/reports/TripsReportProvider.java (renamed from src/main/java/org/traccar/reports/Trips.java) | 13 |
5 files changed, 25 insertions, 39 deletions
diff --git a/src/main/java/org/traccar/reports/Events.java b/src/main/java/org/traccar/reports/EventsReportProvider.java index 130fba724..c4b0aad86 100644 --- a/src/main/java/org/traccar/reports/Events.java +++ b/src/main/java/org/traccar/reports/EventsReportProvider.java @@ -38,12 +38,9 @@ import org.traccar.reports.model.DeviceReportSection; import org.traccar.storage.Storage; import org.traccar.storage.StorageException; -public final class Events { +public class EventsReportProvider { - private Events() { - } - - public static Collection<Event> getObjects( + public Collection<Event> getObjects( Storage storage, long userId, Collection<Long> deviceIds, Collection<Long> groupIds, Collection<String> types, Date from, Date to) throws StorageException { @@ -68,7 +65,7 @@ public final class Events { return result; } - public static void getExcel( + public void getExcel( OutputStream outputStream, Storage storage, long userId, Collection<Long> deviceIds, Collection<Long> groupIds, Collection<String> types, Date from, Date to) throws StorageException, IOException { diff --git a/src/main/java/org/traccar/reports/Route.java b/src/main/java/org/traccar/reports/RouteReportProvider.java index 5b8629aad..4c4a41405 100644 --- a/src/main/java/org/traccar/reports/Route.java +++ b/src/main/java/org/traccar/reports/RouteReportProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org) * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,12 +33,9 @@ import org.traccar.reports.common.ReportUtils; import org.traccar.reports.model.DeviceReportSection; import org.traccar.storage.StorageException; -public final class Route { +public class RouteReportProvider { - private Route() { - } - - public static Collection<Position> getObjects(long userId, Collection<Long> deviceIds, Collection<Long> groupIds, + public Collection<Position> getObjects(long userId, Collection<Long> deviceIds, Collection<Long> groupIds, Date from, Date to) throws StorageException { ReportUtils.checkPeriodLimit(from, to); ArrayList<Position> result = new ArrayList<>(); @@ -49,7 +46,7 @@ public final class Route { return result; } - public static void getExcel(OutputStream outputStream, + public void getExcel(OutputStream outputStream, long userId, Collection<Long> deviceIds, Collection<Long> groupIds, Date from, Date to) throws StorageException, IOException { ReportUtils.checkPeriodLimit(from, to); diff --git a/src/main/java/org/traccar/reports/Stops.java b/src/main/java/org/traccar/reports/StopsReportProvider.java index e688d53da..8dedb9a24 100644 --- a/src/main/java/org/traccar/reports/Stops.java +++ b/src/main/java/org/traccar/reports/StopsReportProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2022 Anton Tananaev (anton@traccar.org) * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -37,12 +37,9 @@ import org.traccar.reports.model.DeviceReportSection; import org.traccar.reports.model.StopReportItem; import org.traccar.storage.StorageException; -public final class Stops { +public class StopsReportProvider { - private Stops() { - } - - private static Collection<StopReportItem> detectStops(long deviceId, Date from, Date to) throws StorageException { + private Collection<StopReportItem> detectStops(long deviceId, Date from, Date to) throws StorageException { boolean ignoreOdometer = Context.getDeviceManager() .lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, false, true); @@ -54,7 +51,7 @@ public final class Stops { Context.getTripsConfig(), ignoreOdometer, StopReportItem.class); } - public static Collection<StopReportItem> getObjects( + public Collection<StopReportItem> getObjects( long userId, Collection<Long> deviceIds, Collection<Long> groupIds, Date from, Date to) throws StorageException { ReportUtils.checkPeriodLimit(from, to); @@ -66,7 +63,7 @@ public final class Stops { return result; } - public static void getExcel( + public void getExcel( OutputStream outputStream, long userId, Collection<Long> deviceIds, Collection<Long> groupIds, Date from, Date to) throws StorageException, IOException { ReportUtils.checkPeriodLimit(from, to); diff --git a/src/main/java/org/traccar/reports/Summary.java b/src/main/java/org/traccar/reports/SummaryReportProvider.java index 30c4cb057..a2306f3d1 100644 --- a/src/main/java/org/traccar/reports/Summary.java +++ b/src/main/java/org/traccar/reports/SummaryReportProvider.java @@ -33,12 +33,9 @@ import org.traccar.reports.common.ReportUtils; import org.traccar.reports.model.SummaryReportItem; import org.traccar.storage.StorageException; -public final class Summary { +public class SummaryReportProvider { - private Summary() { - } - - private static SummaryReportItem calculateSummaryResult(long deviceId, Collection<Position> positions) { + private SummaryReportItem calculateSummaryResult(long deviceId, Collection<Position> positions) { SummaryReportItem result = new SummaryReportItem(); result.setDeviceId(deviceId); result.setDeviceName(Context.getIdentityManager().getById(deviceId).getName()); @@ -91,13 +88,13 @@ public final class Summary { return result; } - private static int getDay(long userId, Date date) { + private int getDay(long userId, Date date) { Calendar calendar = Calendar.getInstance(ReportUtils.getTimezone(userId)); calendar.setTime(date); return calendar.get(Calendar.DAY_OF_MONTH); } - private static Collection<SummaryReportItem> calculateSummaryResults( + private Collection<SummaryReportItem> calculateSummaryResults( long userId, long deviceId, Date from, Date to, boolean daily) throws StorageException { ArrayList<Position> positions = new ArrayList<>(Context.getDataManager().getPositions(deviceId, from, to)); @@ -122,8 +119,9 @@ public final class Summary { return results; } - public static Collection<SummaryReportItem> getObjects(long userId, Collection<Long> deviceIds, - Collection<Long> groupIds, Date from, Date to, boolean daily) throws StorageException { + public Collection<SummaryReportItem> getObjects( + long userId, Collection<Long> deviceIds, + Collection<Long> groupIds, Date from, Date to, boolean daily) throws StorageException { ReportUtils.checkPeriodLimit(from, to); ArrayList<SummaryReportItem> result = new ArrayList<>(); for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) { @@ -138,7 +136,7 @@ public final class Summary { return result; } - public static void getExcel(OutputStream outputStream, + public void getExcel(OutputStream outputStream, long userId, Collection<Long> deviceIds, Collection<Long> groupIds, Date from, Date to, boolean daily) throws StorageException, IOException { ReportUtils.checkPeriodLimit(from, to); diff --git a/src/main/java/org/traccar/reports/Trips.java b/src/main/java/org/traccar/reports/TripsReportProvider.java index 74e24cf2f..6aff08a1d 100644 --- a/src/main/java/org/traccar/reports/Trips.java +++ b/src/main/java/org/traccar/reports/TripsReportProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org) * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,12 +36,9 @@ import org.traccar.reports.model.DeviceReportSection; import org.traccar.reports.model.TripReportItem; import org.traccar.storage.StorageException; -public final class Trips { +public class TripsReportProvider { - private Trips() { - } - - private static Collection<TripReportItem> detectTrips(long deviceId, Date from, Date to) throws StorageException { + private Collection<TripReportItem> detectTrips(long deviceId, Date from, Date to) throws StorageException { boolean ignoreOdometer = Context.getDeviceManager() .lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, false, true); @@ -53,7 +50,7 @@ public final class Trips { Context.getTripsConfig(), ignoreOdometer, TripReportItem.class); } - public static Collection<TripReportItem> getObjects(long userId, Collection<Long> deviceIds, Collection<Long> groupIds, + public Collection<TripReportItem> getObjects(long userId, Collection<Long> deviceIds, Collection<Long> groupIds, Date from, Date to) throws StorageException { ReportUtils.checkPeriodLimit(from, to); ArrayList<TripReportItem> result = new ArrayList<>(); @@ -64,7 +61,7 @@ public final class Trips { return result; } - public static void getExcel(OutputStream outputStream, + public void getExcel(OutputStream outputStream, long userId, Collection<Long> deviceIds, Collection<Long> groupIds, Date from, Date to) throws StorageException, IOException { ReportUtils.checkPeriodLimit(from, to); |