mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-10-31 07:50:09 +01:00
BackupOperation usage replaced with transaction:
Database#backup, BackupOperations removed
This commit is contained in:
parent
2be3b2cf34
commit
6f0ccae59b
@ -21,6 +21,7 @@ import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.db.DBType;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.SQLiteDB;
|
||||
import com.djrapitops.plan.db.access.transactions.BackupCopyTransaction;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -136,7 +137,7 @@ public class ManageBackupCommand extends CommandNode {
|
||||
return;
|
||||
}
|
||||
backupDB.init();
|
||||
copyFromDB.backup().backup(backupDB);
|
||||
backupDB.executeTransaction(new BackupCopyTransaction(copyFromDB));
|
||||
} catch (DBException e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
} finally {
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.db.DBType;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.transactions.BackupCopyTransaction;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -111,7 +112,7 @@ public class ManageMoveCommand extends CommandNode {
|
||||
try {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
fromDatabase.backup().backup(toDatabase);
|
||||
toDatabase.executeTransaction(new BackupCopyTransaction(fromDatabase));
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
|
||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.command.commands.manage;
|
||||
import com.djrapitops.plan.db.DBType;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.SQLiteDB;
|
||||
import com.djrapitops.plan.db.access.transactions.BackupCopyTransaction;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -123,7 +124,7 @@ public class ManageRestoreCommand extends CommandNode {
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
database.backup().restore(backupDB);
|
||||
database.executeTransaction(new BackupCopyTransaction(backupDB));
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
|
@ -53,9 +53,6 @@ public interface Database {
|
||||
*/
|
||||
void executeTransaction(Transaction transaction);
|
||||
|
||||
@Deprecated
|
||||
BackupOperations backup();
|
||||
|
||||
@Deprecated
|
||||
CheckOperations check();
|
||||
|
||||
|
@ -89,7 +89,6 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
private final PingTable pingTable;
|
||||
private final SettingsTable settingsTable;
|
||||
|
||||
private final SQLBackupOps backupOps;
|
||||
private final SQLCheckOps checkOps;
|
||||
private final SQLFetchOps fetchOps;
|
||||
private final SQLRemoveOps removeOps;
|
||||
@ -134,7 +133,6 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
pingTable = new PingTable(this);
|
||||
settingsTable = new SettingsTable(this);
|
||||
|
||||
backupOps = new SQLBackupOps(this);
|
||||
checkOps = new SQLCheckOps(this);
|
||||
fetchOps = new SQLFetchOps(this);
|
||||
removeOps = new SQLRemoveOps(this);
|
||||
@ -467,11 +465,6 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
return settingsTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackupOperations backup() {
|
||||
return backupOps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckOperations check() {
|
||||
return checkOps;
|
||||
|
@ -1,27 +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 com.djrapitops.plan.db.Database;
|
||||
|
||||
public interface BackupOperations {
|
||||
|
||||
void backup(Database toDatabase);
|
||||
|
||||
void restore(Database fromDatabase);
|
||||
|
||||
}
|
@ -1,39 +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.Database;
|
||||
import com.djrapitops.plan.db.SQLDB;
|
||||
import com.djrapitops.plan.db.access.transactions.BackupCopyTransaction;
|
||||
import com.djrapitops.plan.system.database.databases.operation.BackupOperations;
|
||||
|
||||
public class SQLBackupOps extends SQLOps implements BackupOperations {
|
||||
|
||||
public SQLBackupOps(SQLDB db) {
|
||||
super(db);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void backup(Database toDatabase) {
|
||||
toDatabase.executeTransaction(new BackupCopyTransaction(db));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore(Database fromDatabase) {
|
||||
db.executeTransaction(new BackupCopyTransaction(fromDatabase));
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.data.time.GMTimes;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.db.access.Query;
|
||||
import com.djrapitops.plan.db.access.transactions.BackupCopyTransaction;
|
||||
import com.djrapitops.plan.db.access.transactions.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.db.access.transactions.RemovePlayerTransaction;
|
||||
import com.djrapitops.plan.db.patches.Patch;
|
||||
@ -712,7 +713,7 @@ public abstract class CommonDBTest {
|
||||
|
||||
saveAllData(db);
|
||||
|
||||
db.backup().backup(backup);
|
||||
backup.executeTransaction(new BackupCopyTransaction(db));
|
||||
|
||||
assertQueryResultIsEqual(db, backup, LargeFetchQueries.fetchAllCommonUserInformation());
|
||||
assertQueryResultIsEqual(db, backup, LargeFetchQueries.fetchPerServerUserInformation());
|
||||
|
Loading…
Reference in New Issue
Block a user