From d045c1e2174146ddc8ad8b2ef4442863f3d84a11 Mon Sep 17 00:00:00 2001 From: ninioe Date: Tue, 12 Jul 2016 16:04:40 +0300 Subject: Added support for Alarm popup & positions history cleaner 1. added support for Alarm and Alarm Type in popup and also in history records. can be muted with a toggle button in the UI 2. added a timer to clear positions history once a day. the default is to save positions history for 7 days if not defined in the configuration file. 3. prevent the lock of the UI files (js, html, css, etc..) for wondows developers in debug mode. It's easier to do changes to the UI without stopping the app each time. 4. tools: added support in test-generator.py to simulate Alert, also added minify.bat file to compile new js files for the UI using sencha SDK for windows developers --- src/org/traccar/database/DataManager.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/org/traccar/database') diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index b3f24383f..7fd672849 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -521,6 +521,31 @@ public class DataManager implements IdentityManager { .executeQuery(Position.class); } + //added by Erez + public void clearPositionsHistory() throws SQLException { + //SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd"); + String histDays = config.getString("database.positionsHistoryDays"); + if (histDays == null) { + histDays = "7"; + } + int n = Integer.parseInt(histDays); + + for (Device device : getAllDevices()) { + Date lastUpdate = device.getLastUpdate(); + if(lastUpdate != null){ + + Date dateBefore = new Date(lastUpdate.getTime() - n * 24 * 3600 * 1000 ); //Subtract n days + //String dt = s.format(dateBefore); + String sql = "DELETE FROM positions WHERE deviceid=:deviceId and servertime<:serverTime"; + + QueryBuilder.create(dataSource, sql) + .setLong("deviceId", device.getId()) + .setDate("serverTime", dateBefore) + .executeUpdate(); + } + } + } + public Server getServer() throws SQLException { return QueryBuilder.create(dataSource, getQuery("database.selectServers")) .executeQuerySingle(Server.class); -- cgit v1.2.3