package _VisualDVM.Passes.All;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Passes.Server.TestingServerPass;
import _VisualDVM.Repository.Server.ServerCode;
import _VisualDVM.TestingSystem.Common.Group.Group;
import _VisualDVM.TestingSystem.Common.TasksPackageState;
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage;
public class JoinSapforTestingVersionsToGroup extends TestingServerPass {
    Group group;
    SapforPackage sapforPackage;
    @Override
    public String getIconPath() {
        return "/Common/icons/Publish.png";
    }
    @Override
    protected boolean canStart(Object... args) throws Exception {
        if (Global.testingServer.db.CheckCurrent(Log, Group.class, SapforPackage.class)) {
            group = Global.testingServer.db.groups.getUI().getCurrent();
            sapforPackage = Global.testingServer.db.sapforPackages.getUI().getCurrent();
            if (!sapforPackage.state.equals(TasksPackageState.Done) && !sapforPackage.state.equals(TasksPackageState.DoneWithErrors)) {
                Log.Writeln_("Пакет не завершен!");
                return false;
            }
            return SendRequest(ServerCode.JoinSapforVersionsToGroup, group.id + "\n" + sapforPackage.id, null);
        }
        return false;
    }
    @Override
    protected void performFinish() throws Exception {
        Global.mainModule.getPass(PassCode.SynchronizeTests).Do();
    }
    @Override
    protected void FocusResult() {
        Global.mainModule.getUI().getMainWindow().FocusTests();
    }
}
