diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-21 18:41:49 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-21 18:41:49 +0500 |
commit | 69c46399ee0f6b3dd2b0589cb412e9e17f040369 (patch) | |
tree | 4d838e7c52df78acaae804eaa08911825edc0acd /src/org/traccar/database/SimpleObjectManager.java | |
parent | 55d91ec7a86777bb0427422c15c2b8a60aa00071 (diff) | |
download | trackermap-server-69c46399ee0f6b3dd2b0589cb412e9e17f040369.tar.gz trackermap-server-69c46399ee0f6b3dd2b0589cb412e9e17f040369.tar.bz2 trackermap-server-69c46399ee0f6b3dd2b0589cb412e9e17f040369.zip |
Use classes instead of constants everywhere
Diffstat (limited to 'src/org/traccar/database/SimpleObjectManager.java')
-rw-r--r-- | src/org/traccar/database/SimpleObjectManager.java | 16 |
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(); |