diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-13 17:19:15 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-13 17:19:15 -0700 |
commit | e894c17cf14addb729a6c51712ef672cc2cd160b (patch) | |
tree | 2f9b239d3445bf60e26baab0dbf7658b6ec841f5 /src/main/java/org/traccar/helper/model | |
parent | 75044332bebdd8bf3d77431a7008d617dc5f5986 (diff) | |
download | trackermap-server-e894c17cf14addb729a6c51712ef672cc2cd160b.tar.gz trackermap-server-e894c17cf14addb729a6c51712ef672cc2cd160b.tar.bz2 trackermap-server-e894c17cf14addb729a6c51712ef672cc2cd160b.zip |
Refactor getPositions method
Diffstat (limited to 'src/main/java/org/traccar/helper/model')
-rw-r--r-- | src/main/java/org/traccar/helper/model/PositionUtil.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/model/PositionUtil.java b/src/main/java/org/traccar/helper/model/PositionUtil.java index 644517dac..566e31bc5 100644 --- a/src/main/java/org/traccar/helper/model/PositionUtil.java +++ b/src/main/java/org/traccar/helper/model/PositionUtil.java @@ -17,6 +17,15 @@ package org.traccar.helper.model; import org.traccar.model.Position; import org.traccar.session.cache.CacheManager; +import org.traccar.storage.Storage; +import org.traccar.storage.StorageException; +import org.traccar.storage.query.Columns; +import org.traccar.storage.query.Condition; +import org.traccar.storage.query.Order; +import org.traccar.storage.query.Request; + +import java.util.Date; +import java.util.List; public final class PositionUtil { @@ -41,4 +50,14 @@ public final class PositionUtil { return distance; } + public static List<Position> getPositions( + Storage storage, long deviceId, Date from, Date to) throws StorageException { + return storage.getObjects(Position.class, new Request( + new Columns.All(), + new Condition.And( + new Condition.Equals("deviceId", "deviceId", deviceId), + new Condition.Between("fixTime", "from", from, "to", to)), + new Order("fixTime"))); + } + } |