aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGábor Somogyi <gabor.g.somogyi@gmail.com>2016-05-03 23:15:27 +0200
committerGábor Somogyi <gabor.g.somogyi@gmail.com>2016-05-03 23:15:27 +0200
commit1a605980b1a120614ccaeb56faac37b05a81a4e9 (patch)
tree1fa6bf7b360e4c829c8d1ddb51b4012e46f98933
parent572db06a7bbe15bbf98cd695d06b701ff8652b77 (diff)
downloadtraccar-server-1a605980b1a120614ccaeb56faac37b05a81a4e9.tar.gz
traccar-server-1a605980b1a120614ccaeb56faac37b05a81a4e9.tar.bz2
traccar-server-1a605980b1a120614ccaeb56faac37b05a81a4e9.zip
Removed database.selectLatestPosition
-rw-r--r--setup/unix/traccar.xml4
-rw-r--r--setup/windows/traccar.xml4
-rw-r--r--src/org/traccar/api/resource/SupportedCommandResource.java6
-rw-r--r--src/org/traccar/database/DataManager.java6
4 files changed, 3 insertions, 17 deletions
diff --git a/setup/unix/traccar.xml b/setup/unix/traccar.xml
index 8dfcf6386..2ddf6551f 100644
--- a/setup/unix/traccar.xml
+++ b/setup/unix/traccar.xml
@@ -152,10 +152,6 @@
SELECT * FROM positions WHERE deviceId = :deviceId AND fixTime BETWEEN :from AND :to ORDER BY fixTime;
</entry>
- <entry key='database.selectLatestPosition'>
- SELECT TOP 1 * FROM positions WHERE deviceId = :deviceId AND protocol IS NOT NULL;
- </entry>
-
<entry key='database.insertPosition'>
INSERT INTO positions (deviceId, protocol, serverTime, deviceTime, fixTime, valid, latitude, longitude, altitude, speed, course, address, attributes)
VALUES (:deviceId, :protocol, :now, :deviceTime, :fixTime, :valid, :latitude, :longitude, :altitude, :speed, :course, :address, :attributes);
diff --git a/setup/windows/traccar.xml b/setup/windows/traccar.xml
index 80351325b..bf1b216af 100644
--- a/setup/windows/traccar.xml
+++ b/setup/windows/traccar.xml
@@ -161,10 +161,6 @@
SELECT * FROM positions WHERE id IN (SELECT positionId FROM devices);
</entry>
- <entry key='database.selectLatestPosition'>
- SELECT TOP 1 * FROM positions WHERE deviceId = :deviceId AND protocol IS NOT NULL;
- </entry>
-
<entry key='database.updateLatestPosition'>
UPDATE devices SET positionId = :id WHERE id = :deviceId;
</entry>
diff --git a/src/org/traccar/api/resource/SupportedCommandResource.java b/src/org/traccar/api/resource/SupportedCommandResource.java
index 849447060..bf4fd4969 100644
--- a/src/org/traccar/api/resource/SupportedCommandResource.java
+++ b/src/org/traccar/api/resource/SupportedCommandResource.java
@@ -34,9 +34,9 @@ public class SupportedCommandResource extends BaseResource {
@GET
public Collection<SupportedCommand> get(@QueryParam("deviceId") long deviceId) throws SQLException {
Context.getPermissionsManager().checkDevice(getUserId(), deviceId);
- Position latestPosition = Context.getDataManager().getLatestPosition(deviceId);
- if (latestPosition != null) {
- return Context.getServerManager().getProtocolSuppportedCommands(latestPosition.getProtocol());
+ Position lastPosition = Context.getConnectionManager().getLastPosition(deviceId);
+ if (lastPosition != null) {
+ return Context.getServerManager().getProtocolSuppportedCommands(lastPosition.getProtocol());
} else {
return Collections.EMPTY_LIST;
}
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 3dba215f6..3732c82eb 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -472,12 +472,6 @@ public class DataManager implements IdentityManager {
.executeQuery(Position.class);
}
- public Position getLatestPosition(long deviceId) throws SQLException {
- return QueryBuilder.create(dataSource, getQuery("database.selectLatestPosition"))
- .setLong("deviceId", deviceId)
- .executeQuerySingle(Position.class);
- }
-
public Server getServer() throws SQLException {
return QueryBuilder.create(dataSource, getQuery("database.selectServers"))
.executeQuerySingle(Server.class);