From 171896fdbaa498fea269a5c163617c29a66c722b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 16 Apr 2018 20:57:50 +1200 Subject: Minor code cleanup --- src/org/traccar/reports/ReportUtils.java | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/org/traccar/reports') diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index e12968428..010c88b22 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) * Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -151,8 +151,10 @@ public final class ReportUtils { return jxlsContext; } - public static void processTemplateWithSheets(InputStream templateStream, OutputStream targetStream, + public static void processTemplateWithSheets( + InputStream templateStream, OutputStream targetStream, org.jxls.common.Context jxlsContext) throws IOException { + Transformer transformer = TransformerFactory.createTransformer(templateStream, targetStream); List xlsAreas = new XlsCommentAreaBuilder(transformer).build(); for (Area xlsArea : xlsAreas) { @@ -166,6 +168,7 @@ public final class ReportUtils { private static TripReport calculateTrip( ArrayList positions, int startIndex, int endIndex, boolean ignoreOdometer) { + Position startTrip = positions.get(startIndex); Position endTrip = positions.get(endIndex); @@ -230,8 +233,9 @@ public final class ReportUtils { return trip; } - private static StopReport calculateStop(ArrayList positions, int startIndex, int endIndex, - boolean ignoreOdometer) { + private static StopReport calculateStop( + ArrayList positions, int startIndex, int endIndex, boolean ignoreOdometer) { + Position startStop = positions.get(startIndex); Position endStop = positions.get(endIndex); @@ -281,8 +285,9 @@ public final class ReportUtils { } - private static T calculateTripOrStop(ArrayList positions, int startIndex, - int endIndex, boolean ignoreOdometer, Class reportClass) { + private static T calculateTripOrStop( + ArrayList positions, int startIndex, int endIndex, boolean ignoreOdometer, Class reportClass) { + if (reportClass.equals(TripReport.class)) { return (T) calculateTrip(positions, startIndex, endIndex, ignoreOdometer); } else { @@ -310,12 +315,14 @@ public final class ReportUtils { } } - public static Collection detectTripsAndStops(Collection positionCollection, + public static Collection detectTripsAndStops( + Collection positionCollection, TripsConfig tripsConfig, boolean ignoreOdometer, Class reportClass) { + Collection result = new ArrayList<>(); ArrayList positions = new ArrayList<>(positionCollection); - if (positions != null && !positions.isEmpty()) { + if (!positions.isEmpty()) { boolean trips = reportClass.equals(TripReport.class); MotionEventHandler motionHandler = new MotionEventHandler(tripsConfig); DeviceState deviceState = new DeviceState(); @@ -354,6 +361,8 @@ public final class ReportUtils { ignoreOdometer, reportClass)); } } + return result; } + } -- cgit v1.2.3