aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/ExtendedObjectManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database/ExtendedObjectManager.java')
-rw-r--r--src/org/traccar/database/ExtendedObjectManager.java24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/org/traccar/database/ExtendedObjectManager.java b/src/org/traccar/database/ExtendedObjectManager.java
index 2833b3bae..16785cb37 100644
--- a/src/org/traccar/database/ExtendedObjectManager.java
+++ b/src/org/traccar/database/ExtendedObjectManager.java
@@ -30,13 +30,13 @@ import org.traccar.model.Group;
import org.traccar.model.Permission;
import org.traccar.model.BaseModel;
-public abstract class ExtendedObjectManager extends SimpleObjectManager {
+public abstract class ExtendedObjectManager<T extends BaseModel> extends SimpleObjectManager<T> {
private final Map<Long, Set<Long>> deviceItems = new ConcurrentHashMap<>();
private final Map<Long, Set<Long>> deviceItemsWithGroups = new ConcurrentHashMap<>();
private final Map<Long, Set<Long>> groupItems = new ConcurrentHashMap<>();
- protected ExtendedObjectManager(DataManager dataManager, Class<? extends BaseModel> baseClass) {
+ protected ExtendedObjectManager(DataManager dataManager, Class<T> baseClass) {
super(dataManager, baseClass);
refreshExtendedPermissions();
}
@@ -48,10 +48,6 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
return groupItems.get(groupId);
}
- protected final void clearGroupItems() {
- groupItems.clear();
- }
-
public final Set<Long> getDeviceItems(long deviceId) {
if (!deviceItems.containsKey(deviceId)) {
deviceItems.put(deviceId, new HashSet<Long>());
@@ -59,10 +55,6 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
return deviceItems.get(deviceId);
}
- protected final void clearDeviceItems() {
- deviceItems.clear();
- }
-
public Set<Long> getAllDeviceItems(long deviceId) {
if (!deviceItemsWithGroups.containsKey(deviceId)) {
deviceItemsWithGroups.put(deviceId, new HashSet<Long>());
@@ -83,16 +75,15 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
Collection<Permission> databaseGroupPermissions =
getDataManager().getPermissions(Group.class, getBaseClass());
- clearGroupItems();
+ groupItems.clear();
for (Permission groupPermission : databaseGroupPermissions) {
getGroupItems(groupPermission.getOwnerId()).add(groupPermission.getPropertyId());
}
Collection<Permission> databaseDevicePermissions =
getDataManager().getPermissions(Device.class, getBaseClass());
- Collection<Device> allDevices = Context.getDeviceManager().getAllDevices();
- clearDeviceItems();
+ deviceItems.clear();
deviceItemsWithGroups.clear();
for (Permission devicePermission : databaseDevicePermissions) {
@@ -100,12 +91,13 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
getAllDeviceItems(devicePermission.getOwnerId()).add(devicePermission.getPropertyId());
}
- for (Device device : allDevices) {
+ for (Device device : Context.getDeviceManager().getAllDevices()) {
long groupId = device.getGroupId();
while (groupId != 0) {
getAllDeviceItems(device.getId()).addAll(getGroupItems(groupId));
- if (Context.getDeviceManager().getGroupById(groupId) != null) {
- groupId = Context.getDeviceManager().getGroupById(groupId).getGroupId();
+ Group group = (Group) Context.getGroupsManager().getById(groupId);
+ if (group != null) {
+ groupId = group.getGroupId();
} else {
groupId = 0;
}