aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/SimpleObjectManager.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/SimpleObjectManager.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/SimpleObjectManager.java')
-rw-r--r--src/org/traccar/database/SimpleObjectManager.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/org/traccar/database/SimpleObjectManager.java b/src/org/traccar/database/SimpleObjectManager.java
index aae407b56..c4fc0e97a 100644
--- a/src/org/traccar/database/SimpleObjectManager.java
+++ b/src/org/traccar/database/SimpleObjectManager.java
@@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.traccar.Context;
import org.traccar.helper.Log;
-import org.traccar.model.BaseUserPermission;
import org.traccar.model.BaseModel;
public abstract class SimpleObjectManager {
@@ -37,14 +36,14 @@ public abstract class SimpleObjectManager {
private final Map<Long, Set<Long>> userItems = new ConcurrentHashMap<>();
private Class<? extends BaseModel> baseClass;
- private Class<? extends BaseUserPermission> permissionClass;
+ private String baseClassName;
+ private String baseClassIdName;
- protected SimpleObjectManager(DataManager dataManager,
- Class<? extends BaseModel> baseClass,
- Class<? extends BaseUserPermission> permissionClass) {
+ protected SimpleObjectManager(DataManager dataManager, Class<? extends BaseModel> baseClass) {
this.dataManager = dataManager;
this.baseClass = baseClass;
- this.permissionClass = permissionClass;
+ baseClassName = baseClass.getSimpleName();
+ baseClassIdName = baseClassName.substring(0, 1).toLowerCase() + baseClassName.substring(1) + "Id";
}
protected final DataManager getDataManager() {
@@ -55,6 +54,14 @@ public abstract class SimpleObjectManager {
return baseClass;
}
+ protected final String getBaseClassName() {
+ return baseClassName;
+ }
+
+ protected final String getBaseClassIdName() {
+ return baseClassIdName;
+ }
+
public final BaseModel getById(long itemId) {
return items.get(itemId);
}
@@ -104,8 +111,8 @@ public abstract class SimpleObjectManager {
if (dataManager != null) {
try {
clearUserItems();
- for (BaseUserPermission permission : dataManager.getObjects(this.permissionClass)) {
- getUserItems(permission.getUserId()).add(permission.getSlaveId());
+ for (Map<String, Long> permission : dataManager.getPermissions(baseClassName, "Permission")) {
+ getUserItems(permission.get("userId")).add(permission.get(baseClassIdName));
}
} catch (SQLException error) {
Log.warning(error);