aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java')
-rw-r--r--src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java b/src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java
index 372e5dd..8ee9d63 100644
--- a/src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java
+++ b/src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java
@@ -1,5 +1,6 @@
package org.traccar.web.server.database;
+import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@@ -11,6 +12,7 @@ import javax.servlet.http.HttpSession;
import org.traccar.web.client.database.DatabaseService;
import org.traccar.web.shared.model.Device;
+import org.traccar.web.shared.model.Position;
import org.traccar.web.shared.model.User;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@@ -77,4 +79,19 @@ public class DatabaseServiceImpl extends RemoteServiceServlet implements Databas
return null;
}
+ @Override
+ public List<Position> getPositions(Device device, Date from, Date to) {
+ TypedQuery<Position> query = entityManager.createQuery(
+ "SELECT x FROM Position x WHERE x.device = :device AND x.time BETWEEN :from AND :to", Position.class);
+ query.setParameter("device", device);
+ query.setParameter("from", from);
+ query.setParameter("to", to);
+
+ List<Position> positions = new LinkedList<Position>();
+ for (Position position : query.getResultList()) {
+ positions.add(position);
+ }
+ return positions;
+ }
+
}