From a5c431069ca0dfe8240f0c8b43f0508189f8fc86 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 3 Aug 2016 10:05:40 +0500 Subject: - Added getGroupDevices to PermissionsManager - Implemented Route Report --- src/org/traccar/database/PermissionsManager.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/database/PermissionsManager.java') diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index 92fcc3ebd..3c2cc252b 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -41,6 +41,7 @@ public class PermissionsManager { private final Map> groupPermissions = new HashMap<>(); private final Map> devicePermissions = new HashMap<>(); private final Map> deviceUsers = new HashMap<>(); + private final Map> groupDevices = new HashMap<>(); public Set getGroupPermissions(long userId) { if (!groupPermissions.containsKey(userId)) { @@ -63,6 +64,13 @@ public class PermissionsManager { return deviceUsers.get(deviceId); } + public Set getGroupDevices(long groupId) { + if (!groupDevices.containsKey(groupId)) { + groupDevices.put(groupId, new HashSet()); + } + return groupDevices.get(groupId); + } + public PermissionsManager(DataManager dataManager) { this.dataManager = dataManager; refresh(); @@ -91,11 +99,17 @@ public class PermissionsManager { userDevicePermissions.add(device.getId()); } } - for (DevicePermission permission : dataManager.getDevicePermissions()) { getDevicePermissions(permission.getUserId()).add(permission.getDeviceId()); } + groupDevices.clear(); + for (Group group : Context.getDeviceManager().getAllGroups()) { + for (Device device : groupTree.getDevices(group.getId())) { + getGroupDevices(group.getId()).add(device.getId()); + } + } + } catch (SQLException error) { Log.warning(error); } -- cgit v1.2.3