aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/Context.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-07-28 16:15:08 +1200
committerGitHub <noreply@github.com>2017-07-28 16:15:08 +1200
commitd3021c9ae11b177fe05b79e98f1e560e8c3cbaf5 (patch)
treebeb996f62fe8580360b823367aa04692d02dc3be /src/org/traccar/Context.java
parent5d6dec7818a8059c958fc896eb1de838fda52a8c (diff)
parent34d02fbb63eb3d0cfbbcf63de50561831b0ab38d (diff)
downloadtrackermap-server-d3021c9ae11b177fe05b79e98f1e560e8c3cbaf5.tar.gz
trackermap-server-d3021c9ae11b177fe05b79e98f1e560e8c3cbaf5.tar.bz2
trackermap-server-d3021c9ae11b177fe05b79e98f1e560e8c3cbaf5.zip
Merge pull request #3396 from Abyss777/combine_resources
Combine PUT/POST/DELETE functions in object resources
Diffstat (limited to 'src/org/traccar/Context.java')
-rw-r--r--src/org/traccar/Context.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index dfb8c5f47..306a37e83 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -28,6 +28,7 @@ import org.eclipse.jetty.util.URIUtil;
import org.traccar.database.AliasesManager;
import org.traccar.database.CalendarManager;
import org.traccar.database.AttributesManager;
+import org.traccar.database.BaseObjectManager;
import org.traccar.database.ConnectionManager;
import org.traccar.database.DataManager;
import org.traccar.database.DeviceManager;
@@ -51,6 +52,14 @@ import org.traccar.geocoder.OpenCageGeocoder;
import org.traccar.geocoder.Geocoder;
import org.traccar.geolocation.UnwiredGeolocationProvider;
import org.traccar.helper.Log;
+import org.traccar.model.Attribute;
+import org.traccar.model.BaseModel;
+import org.traccar.model.Calendar;
+import org.traccar.model.Device;
+import org.traccar.model.Driver;
+import org.traccar.model.Geofence;
+import org.traccar.model.Group;
+import org.traccar.model.User;
import org.traccar.geolocation.GoogleGeolocationProvider;
import org.traccar.geolocation.GeolocationProvider;
import org.traccar.geolocation.MozillaGeolocationProvider;
@@ -369,4 +378,23 @@ public final class Context {
identityManager = testIdentityManager;
}
+ public static <T extends BaseModel> BaseObjectManager<T> getManager(Class<T> clazz) {
+ if (clazz.equals(Device.class)) {
+ return (BaseObjectManager<T>) deviceManager;
+ } else if (clazz.equals(Group.class)) {
+ return (BaseObjectManager<T>) groupsManager;
+ } else if (clazz.equals(User.class)) {
+ return (BaseObjectManager<T>) usersManager;
+ } else if (clazz.equals(Calendar.class)) {
+ return (BaseObjectManager<T>) calendarManager;
+ } else if (clazz.equals(Attribute.class)) {
+ return (BaseObjectManager<T>) attributesManager;
+ } else if (clazz.equals(Geofence.class)) {
+ return (BaseObjectManager<T>) geofenceManager;
+ } else if (clazz.equals(Driver.class)) {
+ return (BaseObjectManager<T>) driversManager;
+ }
+ return null;
+ }
+
}