aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports/Summary.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-09-21 09:29:42 +0500
committerAbyss777 <abyss@fox5.ru>2016-09-21 09:29:42 +0500
commitb298aef26f01154e84e9a00b29ff62921484a220 (patch)
treefa8b81237c8a4771241aab2da99fa22759ba7587 /src/org/traccar/reports/Summary.java
parente0a4ed2a60fd1a38a904fa7156afba6c0aee1cdb (diff)
downloadtrackermap-server-b298aef26f01154e84e9a00b29ff62921484a220.tar.gz
trackermap-server-b298aef26f01154e84e9a00b29ff62921484a220.tar.bz2
trackermap-server-b298aef26f01154e84e9a00b29ff62921484a220.zip
- Add two functions to lookup attributes from device to server and from device to config
- Removed constant
Diffstat (limited to 'src/org/traccar/reports/Summary.java')
-rw-r--r--src/org/traccar/reports/Summary.java14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java
index 79e1a7c05..763ddb600 100644
--- a/src/org/traccar/reports/Summary.java
+++ b/src/org/traccar/reports/Summary.java
@@ -24,7 +24,6 @@ import javax.json.Json;
import javax.json.JsonArrayBuilder;
import org.traccar.Context;
-import org.traccar.model.Device;
import org.traccar.model.Position;
import org.traccar.reports.model.SummaryReport;
import org.traccar.web.CsvBuilder;
@@ -36,11 +35,9 @@ public final class Summary {
}
private static SummaryReport calculateSummaryResult(long deviceId, Date from, Date to) throws SQLException {
- boolean ignoreOdometerConfig = Context.getConfig().getBoolean(ReportUtils.IGNORE_ODOMETER);
SummaryReport result = new SummaryReport();
- Device device = Context.getDeviceManager().getDeviceById(deviceId);
result.setDeviceId(deviceId);
- result.setDeviceName(device.getName());
+ result.setDeviceName(Context.getDeviceManager().getDeviceById(deviceId).getName());
Collection<Position> positions = Context.getDataManager().getPositions(deviceId, from, to);
if (positions != null && !positions.isEmpty()) {
Position firstPosition = null;
@@ -64,11 +61,10 @@ public final class Summary {
result.setMaxSpeed(position.getSpeed());
}
boolean ignoreOdometer = false;
- if (device.getAttributes().containsKey(ReportUtils.IGNORE_ODOMETER)) {
- ignoreOdometer = Boolean.parseBoolean(device.getAttributes()
- .get(ReportUtils.IGNORE_ODOMETER).toString());
- } else {
- ignoreOdometer = ignoreOdometerConfig;
+ String ignoreOdometerAttribute = Context.getDeviceManager()
+ .lookupConfigAttribute(deviceId, "report.ignoreOdometer");
+ if (ignoreOdometerAttribute != null) {
+ ignoreOdometer = Boolean.parseBoolean(ignoreOdometerAttribute);
}
result.setDistance(ReportUtils.calculateDistance(firstPosition, previousPosition, !ignoreOdometer));
result.setAverageSpeed(speedSum / positions.size());