aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-08-02 12:22:22 +0500
committerAbyss777 <abyss@fox5.ru>2017-08-02 12:22:22 +0500
commit6f8651f11bb0c08bc70fb3b3462202cb273b2569 (patch)
tree51c766ff5e21118a4ef6ac7982b79053433076bc
parentd44c9c778773bd036e46303676652a0d408e7d8c (diff)
downloadtraccar-server-6f8651f11bb0c08bc70fb3b3462202cb273b2569.tar.gz
traccar-server-6f8651f11bb0c08bc70fb3b3462202cb273b2569.tar.bz2
traccar-server-6f8651f11bb0c08bc70fb3b3462202cb273b2569.zip
Avoid unneeded log record and table name constructions
-rw-r--r--src/org/traccar/database/DataManager.java31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 709d2f057..531d21817 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,11 @@ public class DataManager {
}
private static String getObjectsTableName(Class<?> clazz) {
- return Introspector.decapitalize(clazz.getSimpleName()) + "s";
+ String result = Introspector.decapitalize(clazz.getSimpleName());
+ if (!result.endsWith("s")) {
+ result += "s";
+ }
+ return result;
}
private void initDatabaseSchema() throws SQLException, LiquibaseException {