From a401b40ee3b69d5679031a1e1d7287a0a56f4160 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 11 Jun 2022 08:28:41 -0700 Subject: Inject velocity engine --- src/main/java/org/traccar/reports/common/ReportUtils.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java/org/traccar/reports/common/ReportUtils.java') diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java index 706475241..95c43f8a0 100644 --- a/src/main/java/org/traccar/reports/common/ReportUtils.java +++ b/src/main/java/org/traccar/reports/common/ReportUtils.java @@ -16,6 +16,7 @@ */ package org.traccar.reports.common; +import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.tools.generic.DateTool; import org.apache.velocity.tools.generic.NumberTool; import org.jxls.area.Area; @@ -74,18 +75,21 @@ public class ReportUtils { private final IdentityManager identityManager; private final DeviceManager deviceManager; private final TripsConfig tripsConfig; + private final VelocityEngine velocityEngine; private final Geocoder geocoder; @Inject public ReportUtils( Config config, Storage storage, PermissionsService permissionsService, IdentityManager identityManager, - DeviceManager deviceManager, TripsConfig tripsConfig, @Nullable Geocoder geocoder) { + 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; this.geocoder = geocoder; } @@ -153,7 +157,7 @@ public class ReportUtils { context.putVar("distanceUnit", UserUtil.getDistanceUnit(server, user)); context.putVar("speedUnit", UserUtil.getSpeedUnit(server, user)); context.putVar("volumeUnit", UserUtil.getVolumeUnit(server, user)); - context.putVar("webUrl", Context.getVelocityEngine().getProperty("web.url")); + context.putVar("webUrl", velocityEngine.getProperty("web.url")); context.putVar("dateTool", new DateTool()); context.putVar("numberTool", new NumberTool()); context.putVar("timezone", UserUtil.getTimezone(server, user)); -- cgit v1.2.3