2023-12-16 11:35:37 +03:00
|
|
|
package Visual_DVM_2021.Passes.All;
|
|
|
|
|
import Common.Constants;
|
|
|
|
|
import Common.Current;
|
2023-12-16 15:34:29 +03:00
|
|
|
import Common.Global;
|
2023-12-16 11:35:37 +03:00
|
|
|
import Common.Utils.Utils;
|
|
|
|
|
import Repository.Server.ServerCode;
|
|
|
|
|
import Repository.Server.ServerExchangeUnit_2021;
|
|
|
|
|
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
|
|
|
|
import TestingSystem.DVM.TasksPackage.TasksPackageState;
|
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
|
|
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
|
|
|
|
import javafx.util.Pair;
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
public class DownloadDVMPackage extends TestingSystemPass<DVMPackage> {
|
|
|
|
|
@Override
|
|
|
|
|
public String getIconPath() {
|
2023-12-16 15:34:29 +03:00
|
|
|
return "/icons/ComponentsActual.png";
|
2023-12-16 11:35:37 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getButtonText() {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
File workspace;
|
|
|
|
|
File results_zip;
|
|
|
|
|
File results;
|
|
|
|
|
File loaded;
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
if (Current.Check(Log, Current.DVMPackage)){
|
|
|
|
|
//--
|
|
|
|
|
target = Current.getDVMPackage();
|
|
|
|
|
workspace = target.getLocalWorkspace();
|
|
|
|
|
results_zip = new File(workspace, "results.zip");
|
|
|
|
|
results = new File(workspace, "results");
|
|
|
|
|
loaded = new File(workspace, Constants.LOADED);
|
|
|
|
|
//--
|
|
|
|
|
if (!target.state.equals(TasksPackageState.Done)){
|
2023-12-16 15:34:29 +03:00
|
|
|
Log.Writeln_("Возможно скачать и отобразить задачи только завершённого пакета!");
|
2023-12-16 11:35:37 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (loaded.exists()){
|
2023-12-16 15:34:29 +03:00
|
|
|
/// Log.Writeln_("Пакет уже загружен");
|
|
|
|
|
Global.testingServer.db.dvmRunTasks.ShowDVMPackage(target);
|
2023-12-16 11:35:37 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void performPreparation() throws Exception {
|
|
|
|
|
Utils.CheckAndCleanDirectory(target.getLocalWorkspace());
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void ServerAction() throws Exception {
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.DownloadDVMPackage,"", target.id));
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void performDone() throws Exception {
|
|
|
|
|
super.performDone();
|
|
|
|
|
Pair<byte[], byte[]> packed = (Pair<byte[], byte[]>) response.object;
|
|
|
|
|
Utils.unpackFile(packed.getKey(), results_zip);
|
|
|
|
|
Utils.unpackFile(packed.getValue(), target.getJsonFile());
|
|
|
|
|
passes.get(PassCode_2021.UnzipFolderPass).Do(results_zip.getAbsolutePath(), workspace.getAbsolutePath());
|
|
|
|
|
FileUtils.writeStringToFile(loaded, new Date().toString());
|
|
|
|
|
}
|
2023-12-16 15:34:29 +03:00
|
|
|
@Override
|
|
|
|
|
protected void showDone() throws Exception {
|
|
|
|
|
Global.testingServer.db.dvmRunTasks.ShowDVMPackage(target);
|
|
|
|
|
}
|
2023-12-16 11:35:37 +03:00
|
|
|
}
|