package Visual_DVM_2021.Passes.All; import Common.Current; import Common.Database.Database; import Common.Global; import Common.UI.UI; import Common.Utils.Utils; import TestingSystem.Common.TestingServer; import TestingSystem.DVM.TasksPackage.TasksPackageState; import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage; import Visual_DVM_2021.Passes.DeleteServerObjects; import java.util.Vector; public class DeleteSapforTasksPackage extends DeleteServerObjects { public DeleteSapforTasksPackage() { super(Global.testingServer,SapforTasksPackage.class); } protected Database getDb() { return server.account_db; } protected String getEmail() { return Current.getAccount().email; } Vector to_delete; //--- public boolean checkActivity() { to_delete = new Vector<>(); for (Object key : target) { SapforTasksPackage tasksPackage = server.account_db.sapforTasksPackages.get(key); if (!tasksPackage.state.equals(TasksPackageState.Done) && !tasksPackage.state.equals(TasksPackageState.Aborted) ) { Log.Writeln_("Нельзя удалить активный пакет " + key + " !"); return false; } to_delete.add(tasksPackage); } return true; } @Override protected boolean canStart(Object... args) throws Exception { return super.canStart(args) && checkActivity(); } @Override protected void showPreparation() throws Exception { UI.getMainWindow().getTestingWindow().DropSapforComparison(); } @Override protected void performDone() throws Exception { super.performDone(); for (SapforTasksPackage tasksPackage: to_delete) Utils.delete_with_check(tasksPackage.getLocalWorkspace()); } }