2024-09-19 17:37:34 +03:00
|
|
|
|
package Visual_DVM_2021.Passes.All;
|
|
|
|
|
|
import Common.Constants;
|
|
|
|
|
|
import Common.Current;
|
|
|
|
|
|
import Common.Global;
|
|
|
|
|
|
import Common.UI.UI;
|
|
|
|
|
|
import Common.UI.VisualCache.ConfigurationCache;
|
|
|
|
|
|
import Common.UI.VisualCache.VisualCaches;
|
|
|
|
|
|
import Common.Utils.Index;
|
|
|
|
|
|
import ProjectData.LanguageName;
|
|
|
|
|
|
import TestingSystem.Common.Group.Group;
|
|
|
|
|
|
import TestingSystem.Common.Test.Test;
|
|
|
|
|
|
import TestingSystem.Common.TestingServer;
|
|
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
|
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforTest_json;
|
|
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforTestingSet_json;
|
|
|
|
|
|
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
|
|
|
|
|
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
|
|
|
|
|
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
|
|
|
|
|
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
|
|
|
|
|
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.Server.PublishServerObject;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
public class StartSelectedSAPFORConfigurations extends PublishServerObject<TestingServer, SapforPackage> {
|
|
|
|
|
|
Vector<SapforConfiguration> configurations;
|
|
|
|
|
|
SapforTestingSet_json testingSet; //то, что добавляем.
|
|
|
|
|
|
//--
|
|
|
|
|
|
protected LinkedHashMap<String, Test> testsByDescriptions = null;
|
|
|
|
|
|
protected File sapfor = null;
|
|
|
|
|
|
//--
|
|
|
|
|
|
protected Vector<SapforTask> new_tasks = null;
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
|
return "/icons/Start.png";
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
public StartSelectedSAPFORConfigurations() {
|
|
|
|
|
|
super(Global.testingServer, SapforPackage.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
|
//--
|
|
|
|
|
|
testsByDescriptions = new LinkedHashMap<>();
|
|
|
|
|
|
//--
|
|
|
|
|
|
new_tasks= new Vector<>();
|
|
|
|
|
|
//--
|
|
|
|
|
|
if (!Current.getAccount().CheckRegistered(Log)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!Current.Check(Log, Current.ServerSapfor)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!Current.getServerSapfor().state.equals(ServerSapforState.Done)) {
|
|
|
|
|
|
Log.Writeln_("Выбранная версия SAPFOR не собрана!");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
configurations = Global.testingServer.db.sapforConfigurations.getCheckedOrCurrent();
|
|
|
|
|
|
if (configurations.isEmpty()) {
|
|
|
|
|
|
Log.Writeln_("Не отмечено ни одной конфигурации, или отсутствует текущая конфигурация.");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2024-09-20 01:52:39 +03:00
|
|
|
|
int max_kernels = 1;
|
2024-09-19 17:37:34 +03:00
|
|
|
|
for (SapforConfiguration configuration : configurations) {
|
2024-09-20 01:52:39 +03:00
|
|
|
|
max_kernels = Math.max(configuration.kernels, max_kernels);
|
2024-09-22 23:10:27 +03:00
|
|
|
|
if (!(configuration.validate(Log)))
|
2024-09-19 17:37:34 +03:00
|
|
|
|
return false;
|
|
|
|
|
|
//-
|
|
|
|
|
|
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(configuration);
|
|
|
|
|
|
//--
|
2024-09-23 21:16:52 +03:00
|
|
|
|
Vector<Test>tests= cache.getTests();
|
|
|
|
|
|
for (Test test:tests){
|
|
|
|
|
|
String l_description = test.description.toLowerCase();
|
|
|
|
|
|
if (testsByDescriptions.containsKey(l_description)) {
|
|
|
|
|
|
Log.Writeln_("В пакет не могут входить тесты с одинаковыми именами (без учета регистра):" + test.description.toLowerCase());
|
2024-09-19 17:37:34 +03:00
|
|
|
|
return false;
|
2024-09-23 21:16:52 +03:00
|
|
|
|
}else {
|
|
|
|
|
|
testsByDescriptions.put(l_description, test);
|
|
|
|
|
|
}
|
2024-09-19 17:37:34 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-20 01:52:39 +03:00
|
|
|
|
target = new SapforPackage(Current.getAccount(), Current.getServerSapfor(), max_kernels);
|
2024-09-19 17:37:34 +03:00
|
|
|
|
//--
|
|
|
|
|
|
testingSet = new SapforTestingSet_json();
|
|
|
|
|
|
testingSet.id = target.package_json.getMaxSetId();
|
|
|
|
|
|
for (Test test : testsByDescriptions.values()) {
|
|
|
|
|
|
SapforTest_json test_json = new SapforTest_json();
|
|
|
|
|
|
test_json.id = test.id;
|
|
|
|
|
|
test_json.description = test.description;
|
|
|
|
|
|
test_json.group_description = Global.testingServer.db.groups.get(test.group_id).description;
|
|
|
|
|
|
testingSet.tests.add(test_json);
|
|
|
|
|
|
}
|
|
|
|
|
|
for (SapforConfiguration configuration : configurations) {
|
|
|
|
|
|
//--
|
|
|
|
|
|
SapforConfiguration_json configuration_json = new SapforConfiguration_json();
|
|
|
|
|
|
configuration_json.id = configuration.id;
|
|
|
|
|
|
configuration_json.name = configuration.description;
|
|
|
|
|
|
configuration_json.flags = configuration.getFlags();
|
|
|
|
|
|
Vector<PassCode_2021> codes = configuration.getPassCodes();
|
|
|
|
|
|
//--- коррекцию кода нельзя вызвать если инклуды есть. в общем случае.
|
|
|
|
|
|
if (!codes.firstElement().equals(PassCode_2021.SPF_InsertIncludesPass))
|
|
|
|
|
|
configuration_json.codes.add(PassCode_2021.SPF_CorrectCodeStylePass); //всегда добавляется.
|
|
|
|
|
|
//--
|
|
|
|
|
|
configuration_json.codes.addAll(codes);
|
|
|
|
|
|
//--->>
|
|
|
|
|
|
testingSet.configurations.add(configuration_json);
|
|
|
|
|
|
//-->>
|
|
|
|
|
|
}
|
|
|
|
|
|
new_tasks = target.getActualTestingSetTasks(testingSet);
|
|
|
|
|
|
if (new_tasks.size() == 0) {
|
|
|
|
|
|
Log.Writeln_("Не сформировано ни одной новой задачи.\n" +
|
|
|
|
|
|
"Задачи уже присутствуют в пакете, или не отмечено ни одного теста.");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (UI.Question("Будет добавлено " + new_tasks.size() + " задач. Продолжить")){
|
|
|
|
|
|
target.saveConfigurationsAsJson(configurations);
|
|
|
|
|
|
target.package_json.testingSets.add(testingSet);
|
|
|
|
|
|
for (SapforTask task : new_tasks) {
|
|
|
|
|
|
task.id = target.package_json.getMaxTaskId();
|
|
|
|
|
|
target.package_json.tasks.add(task);
|
|
|
|
|
|
}
|
|
|
|
|
|
target.tasksCount += new_tasks.size();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
//
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|