aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-02 21:37:53 +1200
committerGitHub <noreply@github.com>2017-08-02 21:37:53 +1200
commit56110e53d7d86d6b7711a430b6acbc285a5f5605 (patch)
treed4e2e1e3b22f3c6dc0840d3ecfebb95311608aa2
parentd44c9c778773bd036e46303676652a0d408e7d8c (diff)
parent4eddccadb9eb0fd14590d55766d2efdbc9152d6b (diff)
downloadtrackermap-server-56110e53d7d86d6b7711a430b6acbc285a5f5605.tar.gz
trackermap-server-56110e53d7d86d6b7711a430b6acbc285a5f5605.tar.bz2
trackermap-server-56110e53d7d86d6b7711a430b6acbc285a5f5605.zip
Merge pull request #3407 from Abyss777/fix_get_request
Avoid unneeded log record and fix table name constructions
-rw-r--r--src/org/traccar/database/DataManager.java32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 709d2f057..ea90d4d67 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -222,11 +222,13 @@ public class DataManager {
}
}
String query = config.getString(queryName);
- if (query == null && generateQueries) {
- query = constructObjectQuery(action, clazz, extended);
- config.setString(queryName, query);
- } else {
- Log.info("Query not provided: " + queryName);
+ if (query == null) {
+ if (generateQueries) {
+ query = constructObjectQuery(action, clazz, extended);
+ config.setString(queryName, query);
+ } else {
+ Log.info("Query not provided: " + queryName);
+ }
}
return query;
@@ -242,11 +244,14 @@ public class DataManager {
queryName = "database.unlink" + owner.getSimpleName() + property.getSimpleName();
}
String query = config.getString(queryName);
- if (query == null && generateQueries) {
- query = constructPermissionQuery(action, owner, property.equals(User.class) ? ManagedUser.class : property);
- config.setString(queryName, query);
- } else {
- Log.info("Query not provided: " + queryName);
+ if (query == null) {
+ if (generateQueries) {
+ query = constructPermissionQuery(action, owner,
+ property.equals(User.class) ? ManagedUser.class : property);
+ config.setString(queryName, query);
+ } else {
+ Log.info("Query not provided: " + queryName);
+ }
}
return query;
@@ -261,7 +266,12 @@ public class DataManager {
}
private static String getObjectsTableName(Class<?> clazz) {
- return Introspector.decapitalize(clazz.getSimpleName()) + "s";
+ String result = Introspector.decapitalize(clazz.getSimpleName());
+ // Add "s" ending if object name is not plural already
+ if (!result.endsWith("s")) {
+ result += "s";
+ }
+ return result;
}
private void initDatabaseSchema() throws SQLException, LiquibaseException {