aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-11-21 23:00:40 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2012-11-21 23:00:40 +1300
commit28b819aca170785d0958449b07a332b23b532903 (patch)
tree6c59b0c7b205e2fbff7b40e064f4120edae6dbd1 /src/main
parent02d84970e58aae0a0e81f6224cd3ce4a96702fb9 (diff)
downloadtrackermap-web-28b819aca170785d0958449b07a332b23b532903.tar.gz
trackermap-web-28b819aca170785d0958449b07a332b23b532903.tar.bz2
trackermap-web-28b819aca170785d0958449b07a332b23b532903.zip
Select positions interface
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/web/client/Traccar.java28
-rw-r--r--src/main/java/org/traccar/web/client/database/DatabaseService.java4
-rw-r--r--src/main/java/org/traccar/web/client/database/DatabaseServiceAsync.java4
-rw-r--r--src/main/java/org/traccar/web/server/database/DatabaseServiceImpl.java17
-rw-r--r--src/main/java/org/traccar/web/shared/model/Device.java5
5 files changed, 54 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/web/client/Traccar.java b/src/main/java/org/traccar/web/client/Traccar.java
index 34a185d4..ecb9cb5f 100644
--- a/src/main/java/org/traccar/web/client/Traccar.java
+++ b/src/main/java/org/traccar/web/client/Traccar.java
@@ -1,8 +1,11 @@
package org.traccar.web.client;
+import org.traccar.web.client.login.LoginController;
+
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.util.SC;
-import org.traccar.web.client.login.LoginController;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
/**
* Entry point class
@@ -18,10 +21,27 @@ public class Traccar implements EntryPoint, LoginController.LoginHandler {
*/
@Override
public void onModuleLoad() {
- new LoginController().login(this);
+ //new LoginController().login(this);
+
+ /*try {
+ GlobalDatabaseService.getInstance().getPositions(
+ new Device(1), new Date(1325430000000L), new Date(1325437200000L),
+ new AsyncCallback<List<Position>>() {
+ @Override
+ public void onFailure(Throwable throwable) {
+ SC.warn("onFailure");
+ }
+ @Override
+ public void onSuccess(List<Position> positions) {
+ SC.warn("onSuccess");
+ }
+ });
+ } catch (Exception error) {
+ SC.warn(error.getMessage());
+ }*/
- /*devicePanel = new DevicePanel();
+ devicePanel = new DevicePanel();
devicePanel.setWidth("20%");
devicePanel.setShowResizeBar(true);
@@ -43,7 +63,7 @@ public class Traccar implements EntryPoint, LoginController.LoginHandler {
mainLayout.setHeight100();
mainLayout.addMember(hLayout);
mainLayout.addMember(archivePanel);
- mainLayout.draw();*/
+ mainLayout.draw();
}
@Override
diff --git a/src/main/java/org/traccar/web/client/database/DatabaseService.java b/src/main/java/org/traccar/web/client/database/DatabaseService.java
index 0a41ce90..3c6cf095 100644
--- a/src/main/java/org/traccar/web/client/database/DatabaseService.java
+++ b/src/main/java/org/traccar/web/client/database/DatabaseService.java
@@ -1,8 +1,10 @@
package org.traccar.web.client.database;
+import java.util.Date;
import java.util.List;
import org.traccar.web.shared.model.Device;
+import org.traccar.web.shared.model.Position;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@@ -16,4 +18,6 @@ public interface DatabaseService extends RemoteService {
List<Device> getDevices();
+ List<Position> getPositions(Device device, Date from, Date to);
+
}
diff --git a/src/main/java/org/traccar/web/client/database/DatabaseServiceAsync.java b/src/main/java/org/traccar/web/client/database/DatabaseServiceAsync.java
index 6cf6fc48..c68a35f7 100644
--- a/src/main/java/org/traccar/web/client/database/DatabaseServiceAsync.java
+++ b/src/main/java/org/traccar/web/client/database/DatabaseServiceAsync.java
@@ -1,8 +1,10 @@
package org.traccar.web.client.database;
+import java.util.Date;
import java.util.List;
import org.traccar.web.shared.model.Device;
+import org.traccar.web.shared.model.Position;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -14,4 +16,6 @@ public interface DatabaseServiceAsync {
void getDevices(AsyncCallback<List<Device>> callback);
+ void getPositions(Device device, Date from, Date to, AsyncCallback<List<Position>> callback);
+
}
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 372e5ddc..8ee9d63d 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;
+ }
+
}
diff --git a/src/main/java/org/traccar/web/shared/model/Device.java b/src/main/java/org/traccar/web/shared/model/Device.java
index 15d5cd93..3a7b05eb 100644
--- a/src/main/java/org/traccar/web/shared/model/Device.java
+++ b/src/main/java/org/traccar/web/shared/model/Device.java
@@ -15,6 +15,11 @@ public class Device implements Serializable {
public Device() {
}
+ // Constructor for testing
+ public Device(long id) {
+ this.id = id;
+ }
+
@Id
@GeneratedValue
private long id;