From f5a266953e53a7f1785bcb584759582621ec9de3 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Date: Sat, 21 Nov 2015 01:57:46 -0200 Subject: Add support to generic resources and refactor in classes to support types and commandpattern. --- src/org/traccar/database/DataManager.java | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/org/traccar/database/DataManager.java') diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 24a07a05c..767582604 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -379,4 +379,43 @@ public class DataManager implements IdentityManager { .executeUpdate(); } + public void add(Object entity) throws SQLException { + if (entity instanceof User) { + addUser((User) entity); + } else if (entity instanceof Device) { + addDevice((Device) entity); + } else if (entity instanceof Position) { + addPosition((Position) entity); + } + } + + public void update(Object entity) throws SQLException { + if (entity instanceof User) { + updateUser((User) entity); + } else if (entity instanceof Device) { + updateDevice((Device) entity); + } else if (entity instanceof Server) { + updateServer((Server) entity); + } + } + + public void remove(Object entity) throws SQLException { + if (entity instanceof User) { + removeUser((User) entity); + } else if (entity instanceof Device) { + removeDevice((Device) entity); + } + } + + public void link(Class clazz, long userId, long entityId) throws SQLException { + if (clazz.equals(Device.class)) { + linkDevice(userId, entityId); + } + } + + public void unlink(Class clazz, long userId, long entityId) throws SQLException { + if (clazz.equals(Device.class)) { + unlinkDevice(userId, entityId); + } + } } -- cgit v1.2.3