From 68d65c07482ddce62335f0e26452ad15ea2b39a9 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 14 Dec 2018 17:03:46 +0200 Subject: [PATCH] Removed unused Table code - Deprecated Table#execute and Table#executeUnsafe - Removed Table#addColumns and Table#removeColumns - Removed now unused tables.move.TransferTable --- .../database/databases/sql/tables/Table.java | 29 +++-------- .../sql/tables/move/TransferTable.java | 50 ------------------- 2 files changed, 6 insertions(+), 73 deletions(-) delete mode 100644 Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/TransferTable.java diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java index 4c6e7eb61..7136a228a 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java @@ -55,7 +55,7 @@ public abstract class Table { protected void createTable(String sql) throws DBInitException { try { - execute(sql); + db.execute(sql); } catch (DBOpException e) { throw new DBInitException("Failed to create table: " + tableName, e); } @@ -82,7 +82,9 @@ public abstract class Table { * * @param statementString Statement to execute in the database. * @return true if rows were updated. + * @deprecated Use {@code db.execute(statements)} */ + @Deprecated protected boolean execute(String statementString) { return db.execute(statementString); } @@ -91,7 +93,9 @@ public abstract class Table { * Used to execute statements while possible exceptions are suppressed. * * @param statements SQL statements to setUp + * @deprecated Use {@code db.executeUnsafe(statements)} */ + @Deprecated protected void executeUnsafe(String... statements) { db.executeUnsafe(statements); } @@ -113,28 +117,7 @@ public abstract class Table { * Removes all data from the table. */ public void removeAllData() { - execute("DELETE FROM " + tableName); - } - - protected void addColumns(String... columnInfo) { - for (int i = 0; i < columnInfo.length; i++) { - columnInfo[i] = "ALTER TABLE " + tableName + " ADD " + (supportsMySQLQueries ? "" : "COLUMN ") + columnInfo[i]; - } - executeUnsafe(columnInfo); - } - - protected void removeColumns(String... columnNames) { - if (supportsMySQLQueries) { - StringBuilder sqlBuild = new StringBuilder(); - sqlBuild.append("ALTER TABLE ").append(tableName); - for (int i = 0; i < columnNames.length; i++) { - sqlBuild.append(" DROP COLUMN ").append(columnNames[i]); - if (i < columnNames.length - 1) { - sqlBuild.append(","); - } - } - executeUnsafe(sqlBuild.toString()); - } + db.execute("DELETE FROM " + tableName); } @Override diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/TransferTable.java b/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/TransferTable.java deleted file mode 100644 index adc97472d..000000000 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/TransferTable.java +++ /dev/null @@ -1,50 +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 . - */ -package com.djrapitops.plan.system.database.databases.sql.tables.move; - -import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; -import com.djrapitops.plan.system.database.databases.sql.tables.Table; - -/** - * Abstract table used for transferring a whole table to a new table. - * - * @author Rsl1122 - */ -public class TransferTable extends Table { - - public TransferTable(SQLDB db) { - super("", db); - } - - @Override - public void createTable() { - throw new IllegalStateException("Method not supposed to be used on this table."); - } - - protected void renameTable(String from, String to) { - String sql = supportsMySQLQueries ? - "RENAME TABLE " + from + " TO " + to : - "ALTER TABLE " + from + " RENAME TO " + to; - execute(sql); - } - - protected void dropTable(String name) { - execute(TableSqlParser.dropTable(name)); - } - -} \ No newline at end of file