aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/reports
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-13 09:39:22 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-13 09:39:22 -0700
commit33733f835e88a62c4a5259ab330723b88037adf1 (patch)
treef12c710dc4dd6c21a1434f3d699a2fcdd76bb0fa /src/main/java/org/traccar/reports
parentadbeacc62ecb91c94f6cfe7dea8e79b8f5e1c802 (diff)
downloadtrackermap-server-33733f835e88a62c4a5259ab330723b88037adf1.tar.gz
trackermap-server-33733f835e88a62c4a5259ab330723b88037adf1.tar.bz2
trackermap-server-33733f835e88a62c4a5259ab330723b88037adf1.zip
Simplify attribute check
Diffstat (limited to 'src/main/java/org/traccar/reports')
-rw-r--r--src/main/java/org/traccar/reports/SummaryReportProvider.java3
-rw-r--r--src/main/java/org/traccar/reports/common/ReportUtils.java7
2 files changed, 4 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/reports/SummaryReportProvider.java b/src/main/java/org/traccar/reports/SummaryReportProvider.java
index 02033b9e5..9415f3e81 100644
--- a/src/main/java/org/traccar/reports/SummaryReportProvider.java
+++ b/src/main/java/org/traccar/reports/SummaryReportProvider.java
@@ -79,8 +79,7 @@ public class SummaryReportProvider {
result.setSpentFuel(reportUtils.calculateFuel(firstPosition, previousPosition));
long durationMilliseconds;
- if (firstPosition.getAttributes().containsKey(Position.KEY_HOURS)
- && previousPosition.getAttributes().containsKey(Position.KEY_HOURS)) {
+ if (firstPosition.hasAttribute(Position.KEY_HOURS) && previousPosition.hasAttribute(Position.KEY_HOURS)) {
durationMilliseconds =
previousPosition.getLong(Position.KEY_HOURS) - firstPosition.getLong(Position.KEY_HOURS);
result.setEngineHours(durationMilliseconds);
diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java
index ce5e3d8d4..253a6a2b6 100644
--- a/src/main/java/org/traccar/reports/common/ReportUtils.java
+++ b/src/main/java/org/traccar/reports/common/ReportUtils.java
@@ -154,9 +154,9 @@ public class ReportUtils {
}
public String findDriver(Position firstPosition, Position lastPosition) {
- if (firstPosition.getAttributes().containsKey(Position.KEY_DRIVER_UNIQUE_ID)) {
+ if (firstPosition.hasAttribute(Position.KEY_DRIVER_UNIQUE_ID)) {
return firstPosition.getString(Position.KEY_DRIVER_UNIQUE_ID);
- } else if (lastPosition.getAttributes().containsKey(Position.KEY_DRIVER_UNIQUE_ID)) {
+ } else if (lastPosition.hasAttribute(Position.KEY_DRIVER_UNIQUE_ID)) {
return lastPosition.getString(Position.KEY_DRIVER_UNIQUE_ID);
}
return null;
@@ -298,8 +298,7 @@ public class ReportUtils {
stop.setDuration(stopDuration);
stop.setSpentFuel(calculateFuel(startStop, endStop));
- if (startStop.getAttributes().containsKey(Position.KEY_HOURS)
- && endStop.getAttributes().containsKey(Position.KEY_HOURS)) {
+ if (startStop.hasAttribute(Position.KEY_HOURS) && endStop.hasAttribute(Position.KEY_HOURS)) {
stop.setEngineHours(endStop.getLong(Position.KEY_HOURS) - startStop.getLong(Position.KEY_HOURS));
}