aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/ExtendedObjectManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-07-27 17:00:45 +1200
committerGitHub <noreply@github.com>2017-07-27 17:00:45 +1200
commit495b2aa2d2b17bd1a5803ea0bd7dcc64bc81c598 (patch)
tree4b65fbe2d6081f31762a0d8aa790b9fcf81e81f7 /src/org/traccar/database/ExtendedObjectManager.java
parent194263a9dc8040ebcbf62c80733aca5097eb3e36 (diff)
parent49fa4893269b1732806f7176c279742291e02edf (diff)
downloadtrackermap-server-495b2aa2d2b17bd1a5803ea0bd7dcc64bc81c598.tar.gz
trackermap-server-495b2aa2d2b17bd1a5803ea0bd7dcc64bc81c598.tar.bz2
trackermap-server-495b2aa2d2b17bd1a5803ea0bd7dcc64bc81c598.zip
Merge pull request #3391 from Abyss777/refactor_drivers_groups
Split Drivers and Groups management
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;
}