aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-04-29 07:26:44 +0000
committerAnton Tananaev <anton.tananaev@gmail.com>2012-04-29 07:26:44 +0000
commit933639c9ae85204011b40540584bc2c2058e4a52 (patch)
tree3f6eaeff9e245888fc26349d95d4b572e2aefd7f /src/org/traccar/model
parent3291206a50732601dedec5aa4982a8d6db87e16e (diff)
downloadtrackermap-server-933639c9ae85204011b40540584bc2c2058e4a52.tar.gz
trackermap-server-933639c9ae85204011b40540584bc2c2058e4a52.tar.bz2
trackermap-server-933639c9ae85204011b40540584bc2c2058e4a52.zip
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r--src/org/traccar/model/DataManager.java4
-rw-r--r--src/org/traccar/model/DatabaseDataManager.java27
2 files changed, 23 insertions, 8 deletions
diff --git a/src/org/traccar/model/DataManager.java b/src/org/traccar/model/DataManager.java
index a7dbd6719..d0f290962 100644
--- a/src/org/traccar/model/DataManager.java
+++ b/src/org/traccar/model/DataManager.java
@@ -25,7 +25,7 @@ public interface DataManager {
/**
* Manage devices
*/
- public List getDevices() throws Exception;
+ public List<Device> getDevices() throws Exception;
public void addDevice(Device device) throws Exception;
public void addUpdate(Device device) throws Exception;
public void addRemove(Device device) throws Exception;
@@ -34,7 +34,7 @@ public interface DataManager {
/**
* Manage positions
*/
- public List getPositions(Long deviceId) throws Exception;
+ public List<Position> getPositions(Long deviceId) throws Exception;
public void addPosition(Position position) throws Exception;
}
diff --git a/src/org/traccar/model/DatabaseDataManager.java b/src/org/traccar/model/DatabaseDataManager.java
index 8e12f177c..7d90ac194 100644
--- a/src/org/traccar/model/DatabaseDataManager.java
+++ b/src/org/traccar/model/DatabaseDataManager.java
@@ -77,9 +77,9 @@ public class DatabaseDataManager implements DataManager {
queryAddPosition = new NamedParameterStatement(connection, query);
}
- public synchronized List getDevices() throws SQLException {
+ public synchronized List<Device> getDevices() throws SQLException {
- List deviceList = new LinkedList();
+ List<Device> deviceList = new LinkedList();
queryGetDevices.prepare();
ResultSet result = queryGetDevices.executeQuery();
@@ -101,9 +101,8 @@ public class DatabaseDataManager implements DataManager {
if ((devices == null) || (Calendar.getInstance().getTimeInMillis() - devicesLastUpdate.getTimeInMillis() > devicesRefreshDelay)) {
devices = new HashMap();
- List deviceList = getDevices();
- for (Object device: deviceList) {
- devices.put(((Device) device).getImei(), device);
+ for (Device device: getDevices()) {
+ devices.put(device.getImei(), device);
}
devicesLastUpdate = Calendar.getInstance();
}
@@ -111,7 +110,23 @@ public class DatabaseDataManager implements DataManager {
return (Device) devices.get(imei);
}
- public List getPositions(Long deviceId) { return null; } // TODO: implement
+ public List<Position> getPositions(Long deviceId) { // TODO: implement
+
+ List<Position> positionList = new LinkedList();
+
+ Position p = new Position();
+ p.setDeviceId(new Long(1));
+ p.setTime(new Date());
+ p.setValid(true);
+ p.setLatitude(1.0);
+ p.setLongitude(1.0);
+ p.setSpeed(1.0);
+ p.setCourse(1.0);
+
+ positionList.add(p);
+
+ return positionList;
+ }
public synchronized void addPosition(Position position) throws SQLException {