diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-24 17:02:39 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-24 17:02:39 +0500 |
commit | af00329fd0addf84071927dbc18cb0b4e5345f2b (patch) | |
tree | 8a8def831332ed70e63544b54c70bcf82e777fbb /src/org/traccar/database/ExtendedObjectManager.java | |
parent | d6c7cdf1e103c977ed94b737dc838d7ac22b9fa7 (diff) | |
download | trackermap-server-af00329fd0addf84071927dbc18cb0b4e5345f2b.tar.gz trackermap-server-af00329fd0addf84071927dbc18cb0b4e5345f2b.tar.bz2 trackermap-server-af00329fd0addf84071927dbc18cb0b4e5345f2b.zip |
Use Permission instead of Map
Diffstat (limited to 'src/org/traccar/database/ExtendedObjectManager.java')
-rw-r--r-- | src/org/traccar/database/ExtendedObjectManager.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/org/traccar/database/ExtendedObjectManager.java b/src/org/traccar/database/ExtendedObjectManager.java index a9dc7d28a..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 { @@ -79,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) { @@ -114,7 +112,7 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager { } } - } catch (SQLException error) { + } catch (SQLException | ClassNotFoundException error) { Log.warning(error); } } |