From bb86570acc87ca082663986c2f9207d55c434623 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 5 Jun 2012 23:46:50 +0400 Subject: Support old config (fix #12) --- opengts.cfg | 43 +++++++++++++++----------- src/org/traccar/model/DatabaseDataManager.java | 24 ++++++++++---- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/opengts.cfg b/opengts.cfg index 11dbbbb2f..a47ca865a 100644 --- a/opengts.cfg +++ b/opengts.cfg @@ -7,36 +7,38 @@ com.mysql.jdbc.Driver jdbc:mysql://localhost/gts?allowMultiQueries=true - user - password + root + root 300 - - id - Integer - imei - String - <--> SELECT imeiNumber AS id, imeiNumber AS imei FROM Device WHERE imeiNumber <> ''; - - device_id - Integer - time - Date - valid - Boolean - latitude - Double - longitude - Double - speed - Double - course - Double - power - Double (NULL for some protocols) - extended_info - String (XML) - <--> + + DO 0; + + + + DO 0; + + + + DO 0; + + + + DO 0; + + START TRANSACTION; UPDATE Device SET lastValidLatitude = :latitude, lastValidLongitude = :longitude, lastGPSTimestamp = UNIX_TIMESTAMP(:time), lastUpdateTime = UNIX_TIMESTAMP(NOW()) WHERE imeiNumber = :device_id; SELECT @accountID := accountID, @deviceID := deviceID FROM Device WHERE imeiNumber = :device_id; - INSERT INTO EventData VALUES (@accountID, @deviceID, UNIX_TIMESTAMP(:time), 0, :latitude, :longitude, 0, :speed, :course, 0, '', 0, '', '', '', 0, 0, 0, '0000000001', UNIX_TIMESTAMP(NOW())); + INSERT INTO EventData (accountID, deviceID, timestamp, statusCode, latitude, longitude, speedKPH, heading, altitude, rawData, creationTime) + VALUES (@accountID, @deviceID, UNIX_TIMESTAMP(:time), 0, :latitude, :longitude, :speed, :course, :altitude, '', UNIX_TIMESTAMP(NOW())); COMMIT; @@ -88,4 +90,9 @@ 5007 0 + + true + 5008 + 0 + diff --git a/src/org/traccar/model/DatabaseDataManager.java b/src/org/traccar/model/DatabaseDataManager.java index ed3335342..733f0a0ec 100644 --- a/src/org/traccar/model/DatabaseDataManager.java +++ b/src/org/traccar/model/DatabaseDataManager.java @@ -72,22 +72,34 @@ public class DatabaseDataManager implements DataManager { String query; query = properties.getProperty("database.selectDevice"); - queryGetDevices = new NamedParameterStatement(connection, query); + if (query != null) { + queryGetDevices = new NamedParameterStatement(connection, query); + } query = properties.getProperty("database.insertDevice"); - queryAddDevice = new NamedParameterStatement(connection, query); + if (query != null) { + queryAddDevice = new NamedParameterStatement(connection, query); + } query = properties.getProperty("database.updateDevice"); - queryUpdateDevice = new NamedParameterStatement(connection, query); + if (query != null) { + queryUpdateDevice = new NamedParameterStatement(connection, query); + } query = properties.getProperty("database.deleteDevice"); - queryRemoveDevice = new NamedParameterStatement(connection, query); + if (query != null) { + queryRemoveDevice = new NamedParameterStatement(connection, query); + } query = properties.getProperty("database.selectPosition"); - queryGetPositions = new NamedParameterStatement(connection, query); + if (query != null) { + queryGetPositions = new NamedParameterStatement(connection, query); + } query = properties.getProperty("database.insertPosition"); - queryAddPosition = new NamedParameterStatement(connection, query); + if (query != null) { + queryAddPosition = new NamedParameterStatement(connection, query); + } // Create database schema query = properties.getProperty("database.initialize"); -- cgit v1.2.3