Removed CheckOperations

This commit is contained in:
Rsl1122 2019-02-02 11:34:53 +02:00
parent ea8a53029c
commit 9ec7318fac
6 changed files with 22 additions and 79 deletions

View File

@ -20,7 +20,10 @@ import com.djrapitops.plan.api.exceptions.database.DBException;
import com.djrapitops.plan.api.exceptions.database.DBInitException;
import com.djrapitops.plan.db.access.Query;
import com.djrapitops.plan.db.access.transactions.Transaction;
import com.djrapitops.plan.system.database.databases.operation.*;
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
import com.djrapitops.plan.system.database.databases.operation.RemoveOperations;
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
import com.djrapitops.plan.system.database.databases.operation.SearchOperations;
/**
* Interface for interacting with a Plan SQL database.
@ -53,9 +56,6 @@ public interface Database {
*/
void executeTransaction(Transaction transaction);
@Deprecated
CheckOperations check();
@Deprecated
FetchOperations fetch();

View File

@ -29,8 +29,14 @@ import com.djrapitops.plan.db.access.transactions.Transaction;
import com.djrapitops.plan.db.patches.*;
import com.djrapitops.plan.db.sql.tables.*;
import com.djrapitops.plan.db.tasks.PatchTask;
import com.djrapitops.plan.system.database.databases.operation.*;
import com.djrapitops.plan.system.database.databases.sql.operation.*;
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
import com.djrapitops.plan.system.database.databases.operation.RemoveOperations;
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
import com.djrapitops.plan.system.database.databases.operation.SearchOperations;
import com.djrapitops.plan.system.database.databases.sql.operation.SQLFetchOps;
import com.djrapitops.plan.system.database.databases.sql.operation.SQLRemoveOps;
import com.djrapitops.plan.system.database.databases.sql.operation.SQLSaveOps;
import com.djrapitops.plan.system.database.databases.sql.operation.SQLSearchOps;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.system.settings.paths.PluginSettings;
@ -81,7 +87,6 @@ public abstract class SQLDB extends AbstractDatabase {
private final ServerTable serverTable;
private final SettingsTable settingsTable;
private final SQLCheckOps checkOps;
private final SQLFetchOps fetchOps;
private final SQLRemoveOps removeOps;
private final SQLSearchOps searchOps;
@ -120,7 +125,6 @@ public abstract class SQLDB extends AbstractDatabase {
worldTimesTable = new WorldTimesTable(this);
settingsTable = new SettingsTable(this);
checkOps = new SQLCheckOps(this);
fetchOps = new SQLFetchOps(this);
removeOps = new SQLRemoveOps(this);
searchOps = new SQLSearchOps(this);
@ -394,12 +398,6 @@ public abstract class SQLDB extends AbstractDatabase {
return settingsTable;
}
@Override
@Deprecated
public CheckOperations check() {
return checkOps;
}
@Override
@Deprecated
public FetchOperations fetch() {

View File

@ -43,19 +43,23 @@ public class OptionalFetchQueries {
/* Static method class */
}
public static Query<Optional<Server>> fetchMatchingServerIdentifier(UUID serverUUID) {
return fetchMatchingServerIdentifier(serverUUID.toString());
}
public static Query<Optional<Server>> fetchMatchingServerIdentifier(String identifier) {
String sql = "SELECT * FROM " + ServerTable.TABLE_NAME +
" WHERE (" + ServerTable.SERVER_ID + "=?" +
" WHERE (LOWER(" + ServerTable.SERVER_UUID + ") LIKE LOWER(?)" +
" OR LOWER(" + ServerTable.NAME + ") LIKE LOWER(?)" +
" OR LOWER(" + ServerTable.SERVER_UUID + ") LIKE LOWER(?))" +
" OR " + ServerTable.SERVER_ID + "=?)" +
" AND " + ServerTable.INSTALLED + "=?" +
" LIMIT 1";
return new QueryStatement<Optional<Server>>(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setInt(1, NumberUtils.isParsable(identifier) ? Integer.parseInt(identifier) : -1);
statement.setString(1, identifier);
statement.setString(2, identifier);
statement.setString(3, identifier);
statement.setInt(3, NumberUtils.isParsable(identifier) ? Integer.parseInt(identifier) : -1);
statement.setBoolean(4, true);
}

View File

@ -1,26 +0,0 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.system.database.databases.operation;
import java.util.UUID;
@Deprecated
public interface CheckOperations {
@Deprecated
boolean isServerInDatabase(UUID serverUUID);
}

View File

@ -1,34 +0,0 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.system.database.databases.sql.operation;
import com.djrapitops.plan.db.SQLDB;
import com.djrapitops.plan.system.database.databases.operation.CheckOperations;
import java.util.UUID;
public class SQLCheckOps extends SQLOps implements CheckOperations {
public SQLCheckOps(SQLDB db) {
super(db);
}
@Override
public boolean isServerInDatabase(UUID serverUUID) {
return serverTable.getServerID(serverUUID).isPresent();
}
}

View File

@ -19,6 +19,7 @@ package com.djrapitops.plan.system.info.connection;
import com.djrapitops.plan.api.exceptions.connection.*;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.db.Database;
import com.djrapitops.plan.db.access.queries.OptionalFetchQueries;
import com.djrapitops.plan.system.info.request.InfoRequest;
import com.djrapitops.plan.system.info.request.SetupRequest;
import com.djrapitops.plan.system.webserver.Request;
@ -60,7 +61,7 @@ public class ConnectionIn {
UUID serverUUID = getServerUUID();
try {
if (database.check().isServerInDatabase(serverUUID)) {
if (!database.query(OptionalFetchQueries.fetchMatchingServerIdentifier(serverUUID)).isPresent()) {
return;
}
} catch (DBOpException e) {