v++
Оптимизация актуальности задач.
This commit is contained in:
60
src/Visual_DVM_2021/Passes/All/ActualizeDVMPackages.java
Normal file
60
src/Visual_DVM_2021/Passes/All/ActualizeDVMPackages.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.DVM.Tasks.TestRunTask;
|
||||
import TestingSystem.DVM.TasksPackage.TasksPackage;
|
||||
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
import javafx.util.Pair;
|
||||
|
||||
import java.util.Vector;
|
||||
public class ActualizeDVMPackages extends TestingSystemPass<Vector<Pair<Long, TasksPackageState>>> {
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
target = new Vector<>();
|
||||
for (TasksPackage tasksPackage : Global.testingServer.account_db.packages.Data.values()) {
|
||||
if (tasksPackage.state.isActive())
|
||||
target.add(new Pair<>(tasksPackage.id, tasksPackage.state));
|
||||
}
|
||||
return !target.isEmpty();
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.ActualizeDVMPackages, Current.getAccount().email, target));
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
int i = 0;
|
||||
Vector<Pair<TasksPackage, Vector<TestRunTask>>> res = (Vector<Pair<TasksPackage, Vector<TestRunTask>>>) response.object;
|
||||
Global.testingServer.account_db.BeginTransaction();
|
||||
for (Pair<TasksPackage, Vector<TestRunTask>> pair : res) {
|
||||
TasksPackage tasksPackage = pair.getKey();
|
||||
Global.testingServer.account_db.UpdateWithCheck(tasksPackage);
|
||||
if (tasksPackage.state.equals(TasksPackageState.Done)) {
|
||||
++i;
|
||||
for (TestRunTask task : pair.getValue()) {
|
||||
Global.testingServer.account_db.UpdateWithCheck(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
Global.testingServer.account_db.Commit();
|
||||
/*
|
||||
if (i == target.size()) {
|
||||
UI.testingBar.autorefreshButton.doClick();
|
||||
System.out.println("All packages are not active");
|
||||
}
|
||||
*/
|
||||
}
|
||||
@Override
|
||||
protected void showDone() throws Exception {
|
||||
Global.testingServer.account_db.packages.RefreshUI();
|
||||
Global.testingServer.account_db.testRunTasks.ShowUI();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user