From 1ea8569eb87a714d6b2e2b817d05190dd3784384 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 1 Nov 2016 10:35:31 +0500 Subject: Remove json conversion in reports --- src/org/traccar/reports/Summary.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/org/traccar/reports/Summary.java') diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java index 14f8b7839..a82624bcf 100644 --- a/src/org/traccar/reports/Summary.java +++ b/src/org/traccar/reports/Summary.java @@ -25,15 +25,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; -import javax.json.Json; -import javax.json.JsonArrayBuilder; - import org.jxls.transform.poi.PoiTransformer; import org.jxls.util.JxlsHelper; import org.traccar.Context; import org.traccar.model.Position; import org.traccar.reports.model.SummaryReport; -import org.traccar.web.JsonConverter; public final class Summary { @@ -74,24 +70,20 @@ public final class Summary { return result; } - public static String getJson(long userId, Collection deviceIds, Collection groupIds, - Date from, Date to) throws SQLException { - JsonArrayBuilder json = Json.createArrayBuilder(); + public static Collection getObjects(long userId, Collection deviceIds, + Collection groupIds, Date from, Date to) throws SQLException { + ArrayList result = new ArrayList<>(); for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) { Context.getPermissionsManager().checkDevice(userId, deviceId); - json.add(JsonConverter.objectToJson(calculateSummaryResult(deviceId, from, to))); + result.add(calculateSummaryResult(deviceId, from, to)); } - return json.build().toString(); + return result; } public static void getExcel(OutputStream outputStream, long userId, Collection deviceIds, Collection groupIds, Date from, Date to) throws SQLException, IOException { - ArrayList summaries = new ArrayList<>(); - for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) { - Context.getPermissionsManager().checkDevice(userId, deviceId); - summaries.add(calculateSummaryResult(deviceId, from, to)); - } + Collection summaries = getObjects(userId, deviceIds, groupIds, from, to); String templatePath = Context.getConfig().getString("report.templatesPath", "templates/export/"); try (InputStream inputStream = new FileInputStream(templatePath + "/summary.xlsx")) { -- cgit v1.2.3