aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-13 17:19:15 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-13 17:19:15 -0700
commite894c17cf14addb729a6c51712ef672cc2cd160b (patch)
tree2f9b239d3445bf60e26baab0dbf7658b6ec841f5 /src/main/java/org/traccar/api
parent75044332bebdd8bf3d77431a7008d617dc5f5986 (diff)
downloadtrackermap-server-e894c17cf14addb729a6c51712ef672cc2cd160b.tar.gz
trackermap-server-e894c17cf14addb729a6c51712ef672cc2cd160b.tar.bz2
trackermap-server-e894c17cf14addb729a6c51712ef672cc2cd160b.zip
Refactor getPositions method
Diffstat (limited to 'src/main/java/org/traccar/api')
-rw-r--r--src/main/java/org/traccar/api/resource/PositionResource.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/api/resource/PositionResource.java b/src/main/java/org/traccar/api/resource/PositionResource.java
index 2618a04cb..ae948ee14 100644
--- a/src/main/java/org/traccar/api/resource/PositionResource.java
+++ b/src/main/java/org/traccar/api/resource/PositionResource.java
@@ -17,9 +17,13 @@ package org.traccar.api.resource;
import org.traccar.Context;
import org.traccar.api.BaseResource;
+import org.traccar.helper.model.PositionUtil;
import org.traccar.model.Position;
import org.traccar.model.UserRestrictions;
import org.traccar.storage.StorageException;
+import org.traccar.storage.query.Columns;
+import org.traccar.storage.query.Condition;
+import org.traccar.storage.query.Request;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -29,7 +33,6 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -57,9 +60,10 @@ public class PositionResource extends BaseResource {
Context.getPermissionsManager().checkDevice(getUserId(), deviceId);
if (from != null && to != null) {
permissionsService.checkRestriction(getUserId(), UserRestrictions::getDisableReports);
- return Context.getDataManager().getPositions(deviceId, from, to);
+ return PositionUtil.getPositions(storage, deviceId, from, to);
} else {
- return Collections.singleton(Context.getDeviceManager().getLastPosition(deviceId));
+ return storage.getObjects(Position.class, new Request(
+ new Columns.All(), new Condition.LatestPositions(deviceId)));
}
}
}