diff options
author | soshial <soshial@gmail.com> | 2021-09-10 09:22:55 +0200 |
---|---|---|
committer | soshial <soshial@gmail.com> | 2021-09-10 09:22:55 +0200 |
commit | 2a5bf04563ecc8b09f07a0007335bbd111f9c0a2 (patch) | |
tree | 0d4b074c4d73f436f89411ed4f12abac3f39fbe4 /src/main/java/org/traccar/database | |
parent | f2c949998733734543be2ec795b2aa9b909b0044 (diff) | |
download | trackermap-server-2a5bf04563ecc8b09f07a0007335bbd111f9c0a2.tar.gz trackermap-server-2a5bf04563ecc8b09f07a0007335bbd111f9c0a2.tar.bz2 trackermap-server-2a5bf04563ecc8b09f07a0007335bbd111f9c0a2.zip |
add support for relative filtering
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r-- | src/main/java/org/traccar/database/DataManager.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/database/DataManager.java b/src/main/java/org/traccar/database/DataManager.java index 15137ad91..3f702f78a 100644 --- a/src/main/java/org/traccar/database/DataManager.java +++ b/src/main/java/org/traccar/database/DataManager.java @@ -328,6 +328,42 @@ public class DataManager { .executeQuery(Position.class); } + public Position getPositionByTime(long deviceId, Date date) throws SQLException { + Collection<Position> positions = QueryBuilder.create(dataSource, getQuery("database.selectPositionByTime")) + .setLong("deviceId", deviceId) + .setDate("time", date) + .executeQuery(Position.class); + if (positions.isEmpty()) { + return null; + } else { + return positions.iterator().next(); + } + } + + public Position getPrevPosition(long deviceId, Date date) throws SQLException { + Collection<Position> positions = QueryBuilder.create(dataSource, getQuery("database.selectPrevPosition")) + .setLong("deviceId", deviceId) + .setDate("time", date) + .executeQuery(Position.class); + if (positions.isEmpty()) { + return null; + } else { + return positions.iterator().next(); + } + } + + public Position getNextPosition(long deviceId, Date date) throws SQLException { + Collection<Position> positions = QueryBuilder.create(dataSource, getQuery("database.selectNextPosition")) + .setLong("deviceId", deviceId) + .setDate("time", date) + .executeQuery(Position.class); + if (positions.isEmpty()) { + return null; + } else { + return positions.iterator().next(); + } + } + public void updateLatestPosition(Position position) throws SQLException { QueryBuilder.create(dataSource, getQuery("database.updateLatestPosition")) .setDate("now", new Date()) |