aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/ExtendedObjectManager.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-21 09:59:27 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-21 09:59:27 +0500
commit839e741653c9b61e573fa1cdd0dad0641c79bcec (patch)
tree69ef63138122eb0d8cdebe38f678e1d0e2ff82df /src/org/traccar/database/ExtendedObjectManager.java
parente00fbfa466b17e94f59e6ff8fefb83f08999b3ec (diff)
downloadtrackermap-server-839e741653c9b61e573fa1cdd0dad0641c79bcec.tar.gz
trackermap-server-839e741653c9b61e573fa1cdd0dad0641c79bcec.tar.bz2
trackermap-server-839e741653c9b61e573fa1cdd0dad0641c79bcec.zip
Abolish permissions classes and get permissions as Map from DB
Diffstat (limited to 'src/org/traccar/database/ExtendedObjectManager.java')
-rw-r--r--src/org/traccar/database/ExtendedObjectManager.java33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/org/traccar/database/ExtendedObjectManager.java b/src/org/traccar/database/ExtendedObjectManager.java
index caad989c2..fce32fb41 100644
--- a/src/org/traccar/database/ExtendedObjectManager.java
+++ b/src/org/traccar/database/ExtendedObjectManager.java
@@ -25,9 +25,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.traccar.Context;
import org.traccar.helper.Log;
-import org.traccar.model.BaseDevicePermission;
-import org.traccar.model.BaseGroupPermission;
-import org.traccar.model.BaseUserPermission;
import org.traccar.model.Device;
import org.traccar.model.BaseModel;
@@ -37,17 +34,9 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
private final Map<Long, Set<Long>> deviceItemsWithGroups = new ConcurrentHashMap<>();
private final Map<Long, Set<Long>> groupItems = new ConcurrentHashMap<>();
- private Class<? extends BaseDevicePermission> devicePermissionClass;
- private Class<? extends BaseGroupPermission> groupPermissionClass;
-
protected ExtendedObjectManager(DataManager dataManager,
- Class<? extends BaseModel> baseClass,
- Class<? extends BaseUserPermission> permissionClass,
- Class<? extends BaseDevicePermission> devicePermissionClass,
- Class<? extends BaseGroupPermission> groupPermissionClass) {
- super(dataManager, baseClass, permissionClass);
- this.devicePermissionClass = devicePermissionClass;
- this.groupPermissionClass = groupPermissionClass;
+ Class<? extends BaseModel> baseClass) {
+ super(dataManager, baseClass);
}
public final Set<Long> getGroupItems(long groupId) {
@@ -89,24 +78,24 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
if (getDataManager() != null) {
try {
- Collection<? extends BaseGroupPermission> databaseGroupPermissions =
- getDataManager().getObjects(groupPermissionClass);
+ Collection<Map<String, Long>> databaseGroupPermissions =
+ getDataManager().getPermissions("Group", getBaseClassName());
clearGroupItems();
- for (BaseGroupPermission groupPermission : databaseGroupPermissions) {
- getGroupItems(groupPermission.getGroupId()).add(groupPermission.getSlaveId());
+ for (Map<String, Long> groupPermission : databaseGroupPermissions) {
+ getGroupItems(groupPermission.get("groupId")).add(groupPermission.get(getBaseClassIdName()));
}
- Collection<? extends BaseDevicePermission> databaseDevicePermissions =
- getDataManager().getObjects(devicePermissionClass);
+ Collection<Map<String, Long>> databaseDevicePermissions =
+ getDataManager().getPermissions("Device", getBaseClassName());
Collection<Device> allDevices = Context.getDeviceManager().getAllDevices();
clearDeviceItems();
deviceItemsWithGroups.clear();
- for (BaseDevicePermission devicePermission : databaseDevicePermissions) {
- getDeviceItems(devicePermission.getDeviceId()).add(devicePermission.getSlaveId());
- getAllDeviceItems(devicePermission.getDeviceId()).add(devicePermission.getSlaveId());
+ for (Map<String, Long> devicePermission : databaseDevicePermissions) {
+ getDeviceItems(devicePermission.get("deviceId")).add(devicePermission.get(getBaseClassIdName()));
+ getAllDeviceItems(devicePermission.get("deviceId")).add(devicePermission.get(getBaseClassIdName()));
}
for (Device device : allDevices) {