diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-25 16:20:15 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-25 16:20:15 +1200 |
commit | 4a31e34ca62d4b1941d3bc329afc127ef7263f34 (patch) | |
tree | 09b9ad0420a4819a350bcdcffeeee2342c5d2483 /src/org/traccar/database | |
parent | 866c3073ef48a24d86834a391a4d3d91209a6eed (diff) | |
parent | b4841fa0a6293c0b895cf6bb65c6c2d871c78397 (diff) | |
download | trackermap-server-4a31e34ca62d4b1941d3bc329afc127ef7263f34.tar.gz trackermap-server-4a31e34ca62d4b1941d3bc329afc127ef7263f34.tar.bz2 trackermap-server-4a31e34ca62d4b1941d3bc329afc127ef7263f34.zip |
Merge pull request #2104 from ninioe/master
Added support for Alarm notifications & positions history cleaner & show alarms in report & Mute button & unlock UI files (for windows)
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index be77a3d36..04d0d44ea 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -304,6 +304,32 @@ public class DataManager { .executeQuery(Position.class); } + public void clearPositionsHistory() throws SQLException { + int histDays = config.getInteger("database.positionsHistoryDays"); + if (histDays == 0) { + return; + } + + String sql = getQuery("database.clearPositionsHistory"); + if (sql == null) { + return; + } + + for (Device device : getAllDevices()) { + Date lastUpdate = device.getLastUpdate(); + if (lastUpdate != null) { + + Date dateBefore = new Date(lastUpdate.getTime() - histDays * 24 * 3600 * 1000); + + QueryBuilder.create(dataSource, sql) + .setLong("positionId", device.getPositionId()) + .setLong("deviceId", device.getId()) + .setDate("serverTime", dateBefore) + .executeUpdate(); + } + } + } + public Server getServer() throws SQLException { return QueryBuilder.create(dataSource, getQuery("database.selectServers")) .executeQuerySingle(Server.class); |