From eadc45d7edc90cbecc6714e3837dbc07c0901a61 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 2 Feb 2019 12:54:41 +0200 Subject: [PATCH] Removed ServerTable#getServerUUID --- .../plan/db/sql/tables/ServerTable.java | 23 ------------------- .../databases/sql/operation/SQLFetchOps.java | 3 ++- .../webserver/pages/ServerPageHandler.java | 6 ++++- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/ServerTable.java b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/ServerTable.java index e94a1c7e0..0dcf70239 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/ServerTable.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/ServerTable.java @@ -181,29 +181,6 @@ public class ServerTable extends Table { }); } - public Optional getServerUUID(String serverName) { - String sql = Select.from(tableName, - SERVER_UUID) - .where(NAME + "=?") - .toString(); - - return query(new QueryStatement>(sql) { - @Override - public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, serverName); - } - - @Override - public Optional processResults(ResultSet set) throws SQLException { - if (set.next()) { - return Optional.of(UUID.fromString(set.getString(SERVER_UUID))); - } else { - return Optional.empty(); - } - } - }); - } - public Optional getServerInfo(UUID serverUUID) { String sql = Select.from(tableName, "*") .where(SERVER_UUID + "=?") diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index fc20c0f0b..a35fece85 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -80,7 +80,8 @@ public class SQLFetchOps extends SQLOps implements FetchOperations { @Override public Optional getServerUUID(String serverName) { - return serverTable.getServerUUID(serverName); + return db.query(OptionalFetchQueries.fetchMatchingServerIdentifier(serverName)) + .map(Server::getUuid); } @Override diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java index 58a997059..3ee8ca10f 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java @@ -20,8 +20,10 @@ import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException; import com.djrapitops.plan.api.exceptions.connection.NoServersException; import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.db.access.queries.OptionalFetchQueries; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.Processing; import com.djrapitops.plan.system.webserver.Request; @@ -109,7 +111,9 @@ public class ServerPageHandler implements PageHandler { if (!target.isEmpty()) { try { String serverName = target.get(0); - Optional serverUUIDOptional = dbSystem.getDatabase().fetch().getServerUUID(serverName); + Optional serverUUIDOptional = dbSystem.getDatabase() + .query(OptionalFetchQueries.fetchMatchingServerIdentifier(serverName)) + .map(Server::getUuid); if (serverUUIDOptional.isPresent()) { serverUUID = serverUUIDOptional.get(); }