aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-05-30 12:07:43 +0500
committerAbyss777 <abyss@fox5.ru>2016-05-30 12:07:43 +0500
commit80119f59a0d4b89396f5d7d57ba2d80257a8da79 (patch)
treef8a55519dac687f9d9f1518f16c148310a915353 /src/org/traccar/database
parent6e00239038002aa383cce39be7f53b85f3d03a94 (diff)
downloadtrackermap-server-80119f59a0d4b89396f5d7d57ba2d80257a8da79.tar.gz
trackermap-server-80119f59a0d4b89396f5d7d57ba2d80257a8da79.tar.bz2
trackermap-server-80119f59a0d4b89396f5d7d57ba2d80257a8da79.zip
- Style fixes (use lower camel case in all cases)
- Added TYPE_prefix for event.type strings - Removed commented code - Removed "database.selectLastEvents" because it is not cross-database. Do the same via code.
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/ConnectionManager.java4
-rw-r--r--src/org/traccar/database/DataManager.java12
2 files changed, 8 insertions, 8 deletions
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index d6728357c..9e0da8485 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -90,9 +90,9 @@ public class ConnectionManager {
device.setMotion(status);
} else {
if (!status.equals(device.getStatus())) {
- Event event = new Event(Event.DEVICE_OFFLINE, deviceId);
+ Event event = new Event(Event.TYPE_DEVICE_OFFLINE, deviceId);
if (status.equals(Device.STATUS_ONLINE)) {
- event.setType(Event.DEVICE_ONLINE);
+ event.setType(Event.TYPE_DEVICE_ONLINE);
}
updateEvent(event);
}
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index fcb8899bc..dffb8937c 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -43,6 +43,7 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -510,12 +511,11 @@ public class DataManager implements IdentityManager {
.executeQuery(Event.class);
}
- public Collection<Event> getLastEvents(long deviceId, String type, long interval) throws SQLException {
- return QueryBuilder.create(dataSource, getQuery("database.selectLastEvents"))
- .setLong("deviceId", deviceId)
- .setString("type", type)
- .setLong("interval", interval)
- .executeQuery(Event.class);
+ public Collection<Event> getLastEvents(long deviceId, String type, int interval) throws SQLException {
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.SECOND, -interval);
+ Date to = calendar.getTime();
+ return getEvents(deviceId, type, new Date(), to);
}
}