2023-12-31 17:36:20 +03:00
|
|
|
|
package Visual_DVM_2021.Passes.All;
|
|
|
|
|
|
import Common.Constants;
|
|
|
|
|
|
import Common.Current;
|
|
|
|
|
|
import Common.Database.Database;
|
|
|
|
|
|
import Common.Global;
|
|
|
|
|
|
import Common.UI.UI;
|
|
|
|
|
|
import Common.Utils.Utils;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
import Repository.Server.ServerCode;
|
|
|
|
|
|
import Repository.Server.ServerExchangeUnit_2021;
|
2023-12-31 17:36:20 +03:00
|
|
|
|
import TestingSystem.Common.TasksPackageState;
|
|
|
|
|
|
import TestingSystem.Common.Test.Test;
|
|
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
|
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforPackage_json;
|
|
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforTest_json;
|
|
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforTestingSet_json;
|
|
|
|
|
|
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
|
|
|
|
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
2023-12-31 17:36:20 +03:00
|
|
|
|
import Visual_DVM_2021.Passes.AddObjectPass;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
2023-12-31 17:36:20 +03:00
|
|
|
|
|
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
public class CloneSapforPackage extends AddObjectPass<SapforPackage> {
|
2024-03-08 01:17:54 +03:00
|
|
|
|
Vector<SapforPackage> srcPackages;
|
|
|
|
|
|
//--
|
|
|
|
|
|
Vector<String> inexistingTests;
|
|
|
|
|
|
Vector<String> inexistingConfigurations;
|
|
|
|
|
|
//--
|
2023-12-31 17:36:20 +03:00
|
|
|
|
public CloneSapforPackage() {
|
|
|
|
|
|
super(SapforPackage.class);
|
|
|
|
|
|
}
|
2024-03-08 01:17:54 +03:00
|
|
|
|
protected SapforTestingSet_json cloneTestingSet(SapforTestingSet_json src) {
|
|
|
|
|
|
SapforTestingSet_json dst = new SapforTestingSet_json();
|
|
|
|
|
|
dst.id = target.package_json.getMaxSetId();
|
|
|
|
|
|
//--
|
|
|
|
|
|
for (SapforTest_json src_TestJson : src.tests) {
|
|
|
|
|
|
if (Global.testingServer.db.tests.containsKey(src_TestJson.id)) {
|
|
|
|
|
|
System.out.println("test=" + src_TestJson.id);
|
|
|
|
|
|
Test test = Global.testingServer.db.tests.get(src_TestJson.id);
|
|
|
|
|
|
SapforTest_json testJson = new SapforTest_json();
|
|
|
|
|
|
//--
|
|
|
|
|
|
testJson.id = test.id;
|
|
|
|
|
|
testJson.description = test.description;
|
|
|
|
|
|
testJson.group_description = src_TestJson.group_description;
|
|
|
|
|
|
//--
|
|
|
|
|
|
dst.tests.add(testJson);
|
|
|
|
|
|
//--
|
|
|
|
|
|
} else {
|
|
|
|
|
|
inexistingTests.add(String.valueOf(src_TestJson.id));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
for (SapforConfiguration_json src_configuration : src.configurations) {
|
|
|
|
|
|
if (Global.testingServer.db.sapforConfigurations.containsKey(src_configuration.id)) {
|
|
|
|
|
|
System.out.println("configuration=" + src_configuration.id);
|
|
|
|
|
|
SapforConfiguration configuration = Global.testingServer.db.sapforConfigurations.get(src_configuration.id);
|
|
|
|
|
|
SapforConfiguration_json configurationJson = new SapforConfiguration_json();
|
|
|
|
|
|
//--
|
|
|
|
|
|
configurationJson.id = configuration.id;
|
2024-03-08 02:45:49 +03:00
|
|
|
|
configurationJson.name = configuration.description;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
configurationJson.flags = src_configuration.flags;
|
|
|
|
|
|
configurationJson.codes.addAll(src_configuration.codes);
|
|
|
|
|
|
//--
|
|
|
|
|
|
dst.configurations.add(configurationJson);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
inexistingConfigurations.add(String.valueOf(src_configuration.id));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return dst;
|
|
|
|
|
|
}
|
2023-12-31 17:36:20 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
|
return "/icons/MultiFiles.png";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected Database getDb() {
|
|
|
|
|
|
return Global.testingServer.db;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2024-03-08 01:17:54 +03:00
|
|
|
|
srcPackages = new Vector<>();
|
|
|
|
|
|
if (!Current.getAccount().CheckRegistered(Log))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
//--
|
|
|
|
|
|
if (!Current.Check(Log, Current.ServerSapfor))
|
2023-12-31 17:36:20 +03:00
|
|
|
|
return false;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
//--
|
2024-03-22 23:08:51 +03:00
|
|
|
|
srcPackages = Global.testingServer.db.sapforPackages.getCheckedOrCurrent();
|
2024-03-24 18:02:29 +03:00
|
|
|
|
if (srcPackages.isEmpty()) {
|
2024-03-22 23:08:51 +03:00
|
|
|
|
Log.Writeln_("Не отмечено или не выбрано ни одного пакета SAPFOR");
|
|
|
|
|
|
return false;
|
2023-12-31 17:36:20 +03:00
|
|
|
|
}
|
2024-03-22 23:08:51 +03:00
|
|
|
|
// todo изменить чтобы можно было.
|
2024-03-08 01:17:54 +03:00
|
|
|
|
for (SapforPackage sapforPackage : Global.testingServer.db.sapforPackages.Data.values()) {
|
|
|
|
|
|
if (sapforPackage.state.equals(TasksPackageState.Draft)) {
|
|
|
|
|
|
Log.Writeln_("Может существовать только один пакет, готовящийся к публикации.");
|
2023-12-31 17:36:20 +03:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2024-03-08 01:17:54 +03:00
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
Vector<Integer> src_ids = new Vector<>();
|
|
|
|
|
|
Vector<SapforPackage_json> src_jsons = new Vector<>();
|
|
|
|
|
|
for (SapforPackage src : srcPackages) {
|
|
|
|
|
|
if (src.state.equals(TasksPackageState.Draft)) {
|
|
|
|
|
|
Log.Writeln_("Пакет " + Utils.Brackets(src.id) + " является черновиком.");
|
2023-12-31 17:36:20 +03:00
|
|
|
|
return false;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
}
|
|
|
|
|
|
src_ids.add(src.id);
|
|
|
|
|
|
}
|
|
|
|
|
|
TestingSystemPass getJsonsPass = new TestingSystemPass() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
|
return "Получить информацию о задачах исходных пакетов";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void ServerAction() throws Exception {
|
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.GetSapforPackagesJson, null, src_ids));
|
|
|
|
|
|
src_jsons.addAll((Vector<SapforPackage_json>) response.object);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
if (!getJsonsPass.Do())
|
|
|
|
|
|
return false;
|
|
|
|
|
|
//--
|
|
|
|
|
|
inexistingTests = new Vector<>();
|
|
|
|
|
|
inexistingConfigurations = new Vector<>();
|
|
|
|
|
|
//--
|
|
|
|
|
|
target = new SapforPackage();
|
|
|
|
|
|
target.id = Constants.Nan;
|
|
|
|
|
|
//-
|
|
|
|
|
|
target.sender_name = Current.getAccount().name;
|
|
|
|
|
|
target.sender_address = Current.getAccount().email;
|
|
|
|
|
|
//-
|
|
|
|
|
|
target.drv = Current.getServerSapfor().call_command;
|
|
|
|
|
|
target.version = Current.getServerSapfor().version;
|
|
|
|
|
|
target.kernels = Global.properties.TestingKernels;
|
|
|
|
|
|
target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
|
|
|
|
|
|
//--
|
|
|
|
|
|
target.sapforId = Current.getServerSapfor().id;
|
|
|
|
|
|
//--
|
|
|
|
|
|
target.kernels = Global.properties.TestingKernels;
|
|
|
|
|
|
target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
|
|
|
|
|
|
//--
|
|
|
|
|
|
target.package_json = new SapforPackage_json();
|
|
|
|
|
|
///-------------------------------
|
|
|
|
|
|
target.package_json.kernels = target.kernels;
|
|
|
|
|
|
target.package_json.sapfor_drv = target.drv;
|
|
|
|
|
|
//--
|
|
|
|
|
|
//- заполнение testing_set
|
|
|
|
|
|
for (SapforPackage_json srcPackage : src_jsons) {
|
2023-12-31 17:36:20 +03:00
|
|
|
|
//--
|
2024-03-08 01:17:54 +03:00
|
|
|
|
for (SapforTestingSet_json src : srcPackage.testingSets) {
|
|
|
|
|
|
SapforTestingSet_json dst = cloneTestingSet(src);
|
2023-12-31 17:36:20 +03:00
|
|
|
|
//--
|
2024-03-08 01:17:54 +03:00
|
|
|
|
Vector<SapforTask> new_tasks = target.getActualTestingSetTasks(dst);
|
2024-03-08 02:45:49 +03:00
|
|
|
|
if (!new_tasks.isEmpty()) {
|
2024-03-08 01:17:54 +03:00
|
|
|
|
target.package_json.testingSets.add(dst);
|
|
|
|
|
|
target.package_json.tasks.addAll(new_tasks);
|
2023-12-31 17:36:20 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-24 18:02:29 +03:00
|
|
|
|
for (SapforTask task : target.package_json.tasks) {
|
|
|
|
|
|
task.id = target.package_json.getMaxTaskId();
|
|
|
|
|
|
}
|
2024-03-08 01:17:54 +03:00
|
|
|
|
target.tasksCount = target.package_json.tasks.size();
|
|
|
|
|
|
target.testsNames = String.join(";", target.package_json.getTestsNames());
|
2024-03-08 02:45:49 +03:00
|
|
|
|
target.configurationsNames = String.join(";", target.package_json.getConfigurationsNames());
|
2024-03-08 01:17:54 +03:00
|
|
|
|
//--
|
|
|
|
|
|
for (String test_id : inexistingTests) {
|
|
|
|
|
|
System.out.println("Тест " + test_id + " не найден!");
|
|
|
|
|
|
}
|
|
|
|
|
|
for (String configiration_id : inexistingConfigurations) {
|
|
|
|
|
|
System.out.println("Конфигурация " + configiration_id + " не найдена!");
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
return inexistingTests.isEmpty() && inexistingConfigurations.isEmpty() ||
|
|
|
|
|
|
UI.Question(
|
|
|
|
|
|
(inexistingTests.isEmpty() ? "" : (inexistingTests.size() + " тестов отсутствует;")) +
|
|
|
|
|
|
(inexistingConfigurations.isEmpty() ? "" : (inexistingConfigurations.size() + " конфигураций отсутствует;")) +
|
|
|
|
|
|
"Будет добавлено " + target.package_json.tasks.size() + " задач. Продолжить"
|
|
|
|
|
|
);
|
2023-12-31 17:36:20 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void body() throws Exception {
|
|
|
|
|
|
Global.testingServer.db.sapforPackages.Data.put(target.id, target);
|
2024-03-08 01:17:54 +03:00
|
|
|
|
//--
|
2024-03-24 18:02:29 +03:00
|
|
|
|
// Utils.CheckAndCleanDirectory(target.getLocalWorkspace());
|
|
|
|
|
|
// target.saveJson();
|
2023-12-31 17:36:20 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|