Removed ServerTable#getServerUUID

This commit is contained in:
Rsl1122 2019-02-02 12:54:41 +02:00
parent 5776215c1e
commit eadc45d7ed
3 changed files with 7 additions and 25 deletions

View File

@ -181,29 +181,6 @@ public class ServerTable extends Table {
}); });
} }
public Optional<UUID> getServerUUID(String serverName) {
String sql = Select.from(tableName,
SERVER_UUID)
.where(NAME + "=?")
.toString();
return query(new QueryStatement<Optional<UUID>>(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, serverName);
}
@Override
public Optional<UUID> processResults(ResultSet set) throws SQLException {
if (set.next()) {
return Optional.of(UUID.fromString(set.getString(SERVER_UUID)));
} else {
return Optional.empty();
}
}
});
}
public Optional<Server> getServerInfo(UUID serverUUID) { public Optional<Server> getServerInfo(UUID serverUUID) {
String sql = Select.from(tableName, "*") String sql = Select.from(tableName, "*")
.where(SERVER_UUID + "=?") .where(SERVER_UUID + "=?")

View File

@ -80,7 +80,8 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
@Override @Override
public Optional<UUID> getServerUUID(String serverName) { public Optional<UUID> getServerUUID(String serverName) {
return serverTable.getServerUUID(serverName); return db.query(OptionalFetchQueries.fetchMatchingServerIdentifier(serverName))
.map(Server::getUuid);
} }
@Override @Override

View File

@ -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.ConnectionFailException;
import com.djrapitops.plan.api.exceptions.connection.NoServersException; import com.djrapitops.plan.api.exceptions.connection.NoServersException;
import com.djrapitops.plan.api.exceptions.connection.WebException; 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.database.DBSystem;
import com.djrapitops.plan.system.info.InfoSystem; 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.info.server.ServerInfo;
import com.djrapitops.plan.system.processing.Processing; import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.Request;
@ -109,7 +111,9 @@ public class ServerPageHandler implements PageHandler {
if (!target.isEmpty()) { if (!target.isEmpty()) {
try { try {
String serverName = target.get(0); String serverName = target.get(0);
Optional<UUID> serverUUIDOptional = dbSystem.getDatabase().fetch().getServerUUID(serverName); Optional<UUID> serverUUIDOptional = dbSystem.getDatabase()
.query(OptionalFetchQueries.fetchMatchingServerIdentifier(serverName))
.map(Server::getUuid);
if (serverUUIDOptional.isPresent()) { if (serverUUIDOptional.isPresent()) {
serverUUID = serverUUIDOptional.get(); serverUUID = serverUUIDOptional.get();
} }