From 6f8651f11bb0c08bc70fb3b3462202cb273b2569 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 2 Aug 2017 12:22:22 +0500 Subject: Avoid unneeded log record and table name constructions --- src/org/traccar/database/DataManager.java | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/org/traccar/database/DataManager.java') 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 { -- cgit v1.2.3