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') 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 From 4eddccadb9eb0fd14590d55766d2efdbc9152d6b Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 2 Aug 2017 14:33:08 +0500 Subject: Add comment --- src/org/traccar/database/DataManager.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/org') diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 531d21817..ea90d4d67 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -267,6 +267,7 @@ public class DataManager { private static String getObjectsTableName(Class clazz) { String result = Introspector.decapitalize(clazz.getSimpleName()); + // Add "s" ending if object name is not plural already if (!result.endsWith("s")) { result += "s"; } -- cgit v1.2.3