aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-21 10:12:27 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-21 10:12:27 +0500
commitb22735e5dbc22539a6bf9d36cff042094c50d927 (patch)
treecbb651a162aa89bb3b448727a5e134be65c62089 /src/org/traccar
parent839e741653c9b61e573fa1cdd0dad0641c79bcec (diff)
downloadtraccar-server-b22735e5dbc22539a6bf9d36cff042094c50d927.tar.gz
traccar-server-b22735e5dbc22539a6bf9d36cff042094c50d927.tar.bz2
traccar-server-b22735e5dbc22539a6bf9d36cff042094c50d927.zip
Add helper function to generate request string name
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/database/DataManager.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 39ffe6552..39a80ee72 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -268,10 +268,14 @@ public class DataManager {
.executeUpdate());
}
+ private String makeName(String object) {
+ 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 += key.substring(0, 1).toUpperCase() + key.replace("Id", "").substring(1);
+ query += makeName(key);
}
QueryBuilder queryBuilder = QueryBuilder.create(dataSource, getQuery(query));
for (String key : permission.keySet()) {
@@ -286,10 +290,7 @@ public class DataManager {
}
public Collection<Map<String, Long>> getPermissions(String owner, String property) throws SQLException {
- String query = "database.select"
- + owner.substring(0, 1).toUpperCase() + owner.substring(1)
- + property.substring(0, 1).toUpperCase() + property.substring(1)
- + "s";
+ String query = "database.select" + makeName(owner) + makeName(property) + "s";
return QueryBuilder.create(dataSource, getQuery(query)).executeMapQuery(Long.class);
}