aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/ExtendedObjectManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-07-25 15:31:03 +1200
committerGitHub <noreply@github.com>2017-07-25 15:31:03 +1200
commit6253fa291c3a2962fef2076c0cbb0f4e1ca8a3b4 (patch)
tree8cba8784f507140e871e290229ab9841034a0c07 /src/org/traccar/database/ExtendedObjectManager.java
parentc8e5c5e3da63646fd7c84d4f522bc8d7e5109982 (diff)
parentf35961c2f4a3104a009d6e3cd6bc862e6810b998 (diff)
downloadtraccar-server-6253fa291c3a2962fef2076c0cbb0f4e1ca8a3b4.tar.gz
traccar-server-6253fa291c3a2962fef2076c0cbb0f4e1ca8a3b4.tar.bz2
traccar-server-6253fa291c3a2962fef2076c0cbb0f4e1ca8a3b4.zip
Merge pull request #3385 from Abyss777/optimize_managers
Few managers optimizations
Diffstat (limited to 'src/org/traccar/database/ExtendedObjectManager.java')
-rw-r--r--src/org/traccar/database/ExtendedObjectManager.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/org/traccar/database/ExtendedObjectManager.java b/src/org/traccar/database/ExtendedObjectManager.java
index 483c3a09e..2833b3bae 100644
--- a/src/org/traccar/database/ExtendedObjectManager.java
+++ b/src/org/traccar/database/ExtendedObjectManager.java
@@ -27,6 +27,7 @@ import org.traccar.Context;
import org.traccar.helper.Log;
import org.traccar.model.Device;
import org.traccar.model.Group;
+import org.traccar.model.Permission;
import org.traccar.model.BaseModel;
public abstract class ExtendedObjectManager extends SimpleObjectManager {
@@ -37,6 +38,7 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
protected ExtendedObjectManager(DataManager dataManager, Class<? extends BaseModel> baseClass) {
super(dataManager, baseClass);
+ refreshExtendedPermissions();
}
public final Set<Long> getGroupItems(long groupId) {
@@ -78,27 +80,24 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
if (getDataManager() != null) {
try {
- Collection<Map<String, Long>> databaseGroupPermissions =
+ Collection<Permission> databaseGroupPermissions =
getDataManager().getPermissions(Group.class, getBaseClass());
clearGroupItems();
- for (Map<String, Long> groupPermission : databaseGroupPermissions) {
- getGroupItems(groupPermission.get(DataManager.makeNameId(Group.class)))
- .add(groupPermission.get(getBaseClassIdName()));
+ for (Permission groupPermission : databaseGroupPermissions) {
+ getGroupItems(groupPermission.getOwnerId()).add(groupPermission.getPropertyId());
}
- Collection<Map<String, Long>> databaseDevicePermissions =
+ Collection<Permission> databaseDevicePermissions =
getDataManager().getPermissions(Device.class, getBaseClass());
Collection<Device> allDevices = Context.getDeviceManager().getAllDevices();
clearDeviceItems();
deviceItemsWithGroups.clear();
- for (Map<String, Long> devicePermission : databaseDevicePermissions) {
- getDeviceItems(devicePermission.get(DataManager.makeNameId(Device.class)))
- .add(devicePermission.get(getBaseClassIdName()));
- getAllDeviceItems(devicePermission.get(DataManager.makeNameId(Device.class)))
- .add(devicePermission.get(getBaseClassIdName()));
+ for (Permission devicePermission : databaseDevicePermissions) {
+ getDeviceItems(devicePermission.getOwnerId()).add(devicePermission.getPropertyId());
+ getAllDeviceItems(devicePermission.getOwnerId()).add(devicePermission.getPropertyId());
}
for (Device device : allDevices) {
@@ -113,7 +112,7 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
}
}
- } catch (SQLException error) {
+ } catch (SQLException | ClassNotFoundException error) {
Log.warning(error);
}
}