aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-21 11:55:38 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-21 11:55:38 +0500
commitf77912f14ed17bfbe533b664b6b82154c80e3b58 (patch)
tree62ad0749e28740be85743caa097afac516768302 /src/org/traccar/database
parentb22735e5dbc22539a6bf9d36cff042094c50d927 (diff)
downloadtrackermap-server-f77912f14ed17bfbe533b664b6b82154c80e3b58.tar.gz
trackermap-server-f77912f14ed17bfbe533b664b6b82154c80e3b58.tar.bz2
trackermap-server-f77912f14ed17bfbe533b664b6b82154c80e3b58.zip
- Combine all permissions to one resource
- Add two helpers to BaseResource
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/DataManager.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 39a80ee72..9d8167acc 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -272,15 +272,17 @@ public class DataManager {
return object.substring(0, 1).toUpperCase() + object.replace("Id", "").substring(1);
}
- public void linkObject(Map<String, Long> permission, boolean link) throws SQLException {
- String query = "database." + (!link ? "un" : "") + "link";
- for (String key : permission.keySet()) {
- query += makeName(key);
- }
+ private String makeNameId(String object) {
+ return object.substring(0, 1).toLowerCase() + object.substring(1) + (object.indexOf("Id") == -1 ? "Id" : "");
+ }
+
+ public void linkObject(String owner, long ownerId, String property, long propertyId,
+ boolean link) throws SQLException {
+ String query = "database." + (!link ? "un" : "") + "link" + makeName(owner) + makeName(property);
QueryBuilder queryBuilder = QueryBuilder.create(dataSource, getQuery(query));
- for (String key : permission.keySet()) {
- queryBuilder.setLong(key, permission.get(key));
- }
+
+ queryBuilder.setLong(makeNameId(owner), ownerId);
+ queryBuilder.setLong(makeNameId(property), propertyId);
queryBuilder.executeUpdate();
}