aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/DataManager.java
diff options
context:
space:
mode:
authorRafael Guterres <guterresrafael@gmail.com>2015-11-27 03:32:59 -0200
committerRafael Guterres <guterresrafael@gmail.com>2015-11-27 03:32:59 -0200
commitc57bd2d472467b1b3a45aee1b97c9a0aeef5958a (patch)
tree26fae20adf1970b5834f06393a3c703c972f39b1 /src/org/traccar/database/DataManager.java
parent77cd23da84ebebcf99a97a8aef88aa9a4884ca40 (diff)
downloadtrackermap-server-c57bd2d472467b1b3a45aee1b97c9a0aeef5958a.tar.gz
trackermap-server-c57bd2d472467b1b3a45aee1b97c9a0aeef5958a.tar.bz2
trackermap-server-c57bd2d472467b1b3a45aee1b97c9a0aeef5958a.zip
Initial implementation of new api with jax-rs.
Revert servlets to old api and remove plurals. Fix findbugs for header origin.
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-rw-r--r--src/org/traccar/database/DataManager.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 530ec1779..c98a5ede7 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -31,6 +31,7 @@ import java.util.Map;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import org.traccar.Config;
+import org.traccar.helper.Clazz;
import org.traccar.helper.DriverDelegate;
import org.traccar.helper.Log;
import org.traccar.model.Device;
@@ -385,6 +386,24 @@ public class DataManager implements IdentityManager {
.executeUpdate();
}
+ public <T> Collection<T> get(Class<T> clazz) throws SQLException {
+ if (clazz.equals(User.class)) {
+ return (Collection<T>) getUsers();
+ } else if (clazz.equals(Device.class)) {
+ return (Collection<T>) getAllDevices();
+ }
+ return null;
+ }
+
+ public <T> T get(T entity) throws Exception {
+ if (entity instanceof User) {
+ return (T) getUser(Clazz.getId(entity));
+ } else if (entity instanceof Device) {
+ return (T) getDeviceById(Clazz.getId(entity));
+ }
+ return null;
+ }
+
public void add(Object entity) throws SQLException {
if (entity instanceof User) {
addUser((User) entity);