aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/SimpleObjectManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database/SimpleObjectManager.java')
-rw-r--r--src/org/traccar/database/SimpleObjectManager.java16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/org/traccar/database/SimpleObjectManager.java b/src/org/traccar/database/SimpleObjectManager.java
index c4fc0e97a..0db8af658 100644
--- a/src/org/traccar/database/SimpleObjectManager.java
+++ b/src/org/traccar/database/SimpleObjectManager.java
@@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.traccar.Context;
import org.traccar.helper.Log;
import org.traccar.model.BaseModel;
+import org.traccar.model.User;
public abstract class SimpleObjectManager {
@@ -36,14 +37,12 @@ public abstract class SimpleObjectManager {
private final Map<Long, Set<Long>> userItems = new ConcurrentHashMap<>();
private Class<? extends BaseModel> baseClass;
- private String baseClassName;
private String baseClassIdName;
protected SimpleObjectManager(DataManager dataManager, Class<? extends BaseModel> baseClass) {
this.dataManager = dataManager;
this.baseClass = baseClass;
- baseClassName = baseClass.getSimpleName();
- baseClassIdName = baseClassName.substring(0, 1).toLowerCase() + baseClassName.substring(1) + "Id";
+ baseClassIdName = DataManager.makeNameId(baseClass);
}
protected final DataManager getDataManager() {
@@ -54,10 +53,6 @@ public abstract class SimpleObjectManager {
return baseClass;
}
- protected final String getBaseClassName() {
- return baseClassName;
- }
-
protected final String getBaseClassIdName() {
return baseClassIdName;
}
@@ -111,8 +106,9 @@ public abstract class SimpleObjectManager {
if (dataManager != null) {
try {
clearUserItems();
- for (Map<String, Long> permission : dataManager.getPermissions(baseClassName, "Permission")) {
- getUserItems(permission.get("userId")).add(permission.get(baseClassIdName));
+ for (Map<String, Long> permission : dataManager.getPermissions(User.class, baseClass)) {
+ getUserItems(permission.get(DataManager.makeNameId(User.class)))
+ .add(permission.get(baseClassIdName));
}
} catch (SQLException error) {
Log.warning(error);
@@ -133,7 +129,7 @@ public abstract class SimpleObjectManager {
public void removeItem(long itemId) throws SQLException {
BaseModel item = getById(itemId);
if (item != null) {
- dataManager.removeObject(item.getClass(), itemId);
+ dataManager.removeObject(baseClass, itemId);
removeCachedItem(itemId);
}
refreshUserItems();