aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-03-08 23:38:48 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-03-08 23:38:48 +1300
commit2879646bc58467939349c367a7763cd1eb11fde2 (patch)
tree5b2a7cc9e4bee6af36d87e1775d272326b0af55c
parent3e76be5531f89fb906598435096e3eff54f86944 (diff)
downloadtrackermap-server-2879646bc58467939349c367a7763cd1eb11fde2.tar.gz
trackermap-server-2879646bc58467939349c367a7763cd1eb11fde2.tar.bz2
trackermap-server-2879646bc58467939349c367a7763cd1eb11fde2.zip
Add select group permissions query
-rw-r--r--debug.xml6
-rw-r--r--src/org/traccar/database/DataManager.java10
-rw-r--r--src/org/traccar/database/PermissionsManager.java6
3 files changed, 18 insertions, 4 deletions
diff --git a/debug.xml b/debug.xml
index 102272cb3..413c020eb 100644
--- a/debug.xml
+++ b/debug.xml
@@ -113,10 +113,14 @@
DELETE FROM users WHERE id = :id;
</entry>
- <entry key='database.getPermissionsAll'>
+ <entry key='database.selectDevicePermissions'>
SELECT userId, deviceId FROM user_device;
</entry>
+ <entry key='database.selectGroupPermissions'>
+ SELECT userId, groupId FROM user_group;
+ </entry>
+
<entry key='database.selectDevicesAll'>
SELECT * FROM devices;
</entry>
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 5b4524f2e..9a8a14615 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -39,6 +39,7 @@ import org.traccar.Config;
import org.traccar.helper.Log;
import org.traccar.model.Device;
import org.traccar.model.Group;
+import org.traccar.model.GroupPermission;
import org.traccar.model.MiscFormatter;
import org.traccar.model.DevicePermission;
import org.traccar.model.Position;
@@ -222,11 +223,16 @@ public class DataManager implements IdentityManager {
.executeUpdate();
}
- public Collection<DevicePermission> getPermissions() throws SQLException {
- return QueryBuilder.create(dataSource, getQuery("database.getPermissionsAll"))
+ public Collection<DevicePermission> getDevicePermissions() throws SQLException {
+ return QueryBuilder.create(dataSource, getQuery("database.selectDevicePermissions"))
.executeQuery(DevicePermission.class);
}
+ public Collection<GroupPermission> getGroupPermissions() throws SQLException {
+ return QueryBuilder.create(dataSource, getQuery("database.selectGroupPermissions"))
+ .executeQuery(GroupPermission.class);
+ }
+
public Collection<Device> getAllDevices() throws SQLException {
return QueryBuilder.create(dataSource, getQuery("database.selectDevicesAll"))
.executeQuery(Device.class);
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 854732fa2..0ed8227b4 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.Set;
import org.traccar.helper.Log;
import org.traccar.model.DevicePermission;
+import org.traccar.model.GroupPermission;
import org.traccar.model.Server;
import org.traccar.model.User;
@@ -64,9 +65,12 @@ public class PermissionsManager {
for (User user : dataManager.getUsers()) {
users.put(user.getId(), user);
}
- for (DevicePermission permission : dataManager.getPermissions()) {
+ for (DevicePermission permission : dataManager.getDevicePermissions()) {
getDevicePermissions(permission.getUserId()).add(permission.getDeviceId());
}
+ for (GroupPermission permission : dataManager.getGroupPermissions()) {
+ getGroupPermissions(permission.getUserId()).add(permission.getGroupId());
+ }
} catch (SQLException error) {
Log.warning(error);
}