2023-12-15 18:38:05 +03:00
|
|
|
|
package TestingSystem.SAPFOR.SapforPackage;
|
2023-12-15 18:10:27 +03:00
|
|
|
|
import Common.Constants;
|
2024-03-10 00:42:29 +03:00
|
|
|
|
import Common.Current;
|
2023-12-16 03:57:01 +03:00
|
|
|
|
import Common.Database.DBObject;
|
2023-12-15 18:38:05 +03:00
|
|
|
|
import Common.Global;
|
2024-09-24 00:24:28 +03:00
|
|
|
|
import Common.UI.VisualCache.ConfigurationCache;
|
|
|
|
|
|
import Common.UI.VisualCache.VisualCaches;
|
|
|
|
|
|
import Common.Utils.TextLog;
|
2024-03-07 18:56:47 +03:00
|
|
|
|
import Common.Utils.Utils;
|
2024-09-19 17:37:34 +03:00
|
|
|
|
import GlobalData.Account.Account;
|
|
|
|
|
|
import TestingSystem.Common.TasksPackageState;
|
2024-09-24 00:24:28 +03:00
|
|
|
|
import TestingSystem.Common.Test.Test;
|
2023-12-15 18:10:27 +03:00
|
|
|
|
import TestingSystem.Common.TestingPackage.TestingPackage;
|
2024-09-24 00:24:28 +03:00
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
2023-12-25 00:33:14 +03:00
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforPackage_json;
|
2024-09-24 00:24:28 +03:00
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforTest_json;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
import TestingSystem.SAPFOR.Json.SapforTestingSet_json;
|
2024-09-24 00:24:28 +03:00
|
|
|
|
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
2024-03-07 18:56:47 +03:00
|
|
|
|
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
2024-09-19 17:37:34 +03:00
|
|
|
|
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
2024-09-24 00:24:28 +03:00
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
2023-12-15 18:38:05 +03:00
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
2024-09-24 00:24:28 +03:00
|
|
|
|
import java.util.LinkedHashMap;
|
2024-03-08 01:17:54 +03:00
|
|
|
|
import java.util.Vector;
|
2023-12-25 00:33:14 +03:00
|
|
|
|
public class SapforPackage extends TestingPackage<SapforPackage_json> {
|
2023-12-15 18:10:27 +03:00
|
|
|
|
public int sapforId = Constants.Nan; // так как сапфор на машине.
|
2024-03-07 18:56:47 +03:00
|
|
|
|
public SapforPackage() {
|
2023-12-16 03:57:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
public SapforPackage(SapforPackage sapforPackage) {
|
|
|
|
|
|
SynchronizeFields(sapforPackage);
|
|
|
|
|
|
}
|
2024-09-20 01:52:39 +03:00
|
|
|
|
public SapforPackage(Account account, ServerSapfor serverSapfor, int kernels_in) {
|
2024-09-19 17:37:34 +03:00
|
|
|
|
id = Constants.Nan;
|
|
|
|
|
|
//-
|
|
|
|
|
|
sender_name = account.name;
|
|
|
|
|
|
sender_address = account.email;
|
|
|
|
|
|
//-
|
|
|
|
|
|
sapforId = serverSapfor.id;
|
|
|
|
|
|
//-
|
|
|
|
|
|
drv = serverSapfor.call_command;
|
|
|
|
|
|
version = serverSapfor.version;
|
2024-09-20 01:52:39 +03:00
|
|
|
|
kernels = kernels_in;//Global.properties.TestingKernels;
|
2024-09-19 17:37:34 +03:00
|
|
|
|
needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
|
|
|
|
|
|
///-------------------------------
|
|
|
|
|
|
package_json = new SapforPackage_json();
|
|
|
|
|
|
package_json.kernels = kernels;
|
|
|
|
|
|
package_json.sapfor_drv = serverSapfor.call_command;
|
|
|
|
|
|
//-
|
|
|
|
|
|
state = TasksPackageState.Queued;
|
|
|
|
|
|
//-
|
|
|
|
|
|
}
|
2023-12-16 03:57:01 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
public void SynchronizeFields(DBObject src) {
|
|
|
|
|
|
super.SynchronizeFields(src);
|
|
|
|
|
|
SapforPackage p = (SapforPackage) src;
|
|
|
|
|
|
sapforId = p.sapforId;
|
|
|
|
|
|
}
|
2023-12-15 18:10:27 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
public Class getJsonClass() {
|
2023-12-25 00:33:14 +03:00
|
|
|
|
return SapforPackage_json.class;
|
2023-12-15 18:10:27 +03:00
|
|
|
|
}
|
2023-12-15 18:38:05 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
public File getHomeDirectory() {
|
|
|
|
|
|
return Global.SapforPackagesDirectory;
|
|
|
|
|
|
}
|
2024-03-07 18:56:47 +03:00
|
|
|
|
//--
|
|
|
|
|
|
public void init() throws Exception {
|
|
|
|
|
|
for (SapforTask task : package_json.tasks)
|
|
|
|
|
|
task.sapfortaskspackage_id = id;
|
|
|
|
|
|
Utils.CheckAndCleanDirectory(getLocalWorkspace());
|
|
|
|
|
|
saveJson();
|
|
|
|
|
|
package_json = null; // объект больше не нужен.
|
|
|
|
|
|
}
|
2024-03-08 01:17:54 +03:00
|
|
|
|
//-проверка, какие задачи из набора, не пересекаются с уже имеющимися в пакете.
|
2024-09-19 17:37:34 +03:00
|
|
|
|
public Vector<SapforTask> getActualTestingSetTasks(SapforTestingSet_json testingSet) {
|
2024-03-08 01:17:54 +03:00
|
|
|
|
Vector<SapforTask> possible_tasks = testingSet.createTasks();
|
|
|
|
|
|
Vector<String> keys = package_json.getTasksKeys();
|
|
|
|
|
|
Vector<SapforTask> new_tasks = new Vector<>();
|
|
|
|
|
|
//----
|
|
|
|
|
|
for (SapforTask task : possible_tasks) {
|
|
|
|
|
|
String key = task.getUniqueKey();
|
|
|
|
|
|
if (!keys.contains(key)) {
|
|
|
|
|
|
keys.add(key);
|
|
|
|
|
|
new_tasks.add(task);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return new_tasks;
|
|
|
|
|
|
}
|
2024-03-10 00:42:29 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
public boolean isVisible() {
|
2024-09-19 17:37:34 +03:00
|
|
|
|
return (!SapforPackageDBTable.filterMyOnly || Current.getAccount().email.equals(sender_address)) &&
|
|
|
|
|
|
(!SapforPackageDBTable.filterActive || state.isActive())
|
2024-07-22 20:52:37 +03:00
|
|
|
|
;
|
2024-03-10 00:42:29 +03:00
|
|
|
|
}
|
2024-09-24 00:24:28 +03:00
|
|
|
|
//---------
|
|
|
|
|
|
//конструктор. если 0 задач по итогу,значит пакет не запускаем вообще, и смотрим журнал.
|
|
|
|
|
|
public SapforPackage(Account account, ServerSapfor serverSapfor, Vector<SapforConfiguration> configurations, TextLog Log) throws Exception{
|
|
|
|
|
|
id = Constants.Nan;
|
|
|
|
|
|
sender_name = account.name;
|
|
|
|
|
|
sender_address = account.email;
|
|
|
|
|
|
//-
|
|
|
|
|
|
sapforId = serverSapfor.id;
|
|
|
|
|
|
//-
|
|
|
|
|
|
drv = serverSapfor.call_command;
|
|
|
|
|
|
version = serverSapfor.version;
|
|
|
|
|
|
needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
|
|
|
|
|
|
///-------------------------------
|
|
|
|
|
|
package_json = new SapforPackage_json();
|
|
|
|
|
|
package_json.sapfor_drv = serverSapfor.call_command;
|
|
|
|
|
|
//-
|
|
|
|
|
|
state = TasksPackageState.Queued;
|
|
|
|
|
|
//--
|
|
|
|
|
|
boolean valid = true;
|
|
|
|
|
|
//проверка исходных данных тестов и групп
|
|
|
|
|
|
LinkedHashMap<String, Test> testsByDescriptions =new LinkedHashMap<>();
|
|
|
|
|
|
//--
|
|
|
|
|
|
kernels=1;
|
|
|
|
|
|
for (SapforConfiguration configuration : configurations) {
|
|
|
|
|
|
kernels = Math.max(configuration.kernels, kernels);
|
|
|
|
|
|
configuration.validate(Log);
|
|
|
|
|
|
//-
|
|
|
|
|
|
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(configuration);
|
|
|
|
|
|
//--
|
|
|
|
|
|
for (Test test : cache.getTests()) {
|
|
|
|
|
|
String l_description = test.description.toLowerCase();
|
|
|
|
|
|
if (testsByDescriptions.containsKey(l_description)) {
|
|
|
|
|
|
Log.Writeln_("В пакет не могут входить тесты с одинаковыми именами (без учета регистра):" + test.description.toLowerCase());
|
|
|
|
|
|
valid=false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
testsByDescriptions.put(l_description, test);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
valid= Log.isEmpty();
|
|
|
|
|
|
//формирование задач.
|
|
|
|
|
|
if (valid){
|
|
|
|
|
|
//--
|
|
|
|
|
|
tasksCount=0;
|
|
|
|
|
|
package_json.kernels = kernels;
|
|
|
|
|
|
//--
|
|
|
|
|
|
SapforTestingSet_json testingSet = new SapforTestingSet_json();
|
|
|
|
|
|
Vector<SapforTask> new_tasks = new Vector<>();
|
|
|
|
|
|
//--
|
|
|
|
|
|
testingSet.id = 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 = getActualTestingSetTasks(testingSet);
|
|
|
|
|
|
saveConfigurationsAsJson(configurations);
|
|
|
|
|
|
package_json.testingSets.add(testingSet);
|
|
|
|
|
|
for (SapforTask task : new_tasks) {
|
|
|
|
|
|
task.id = package_json.getMaxTaskId();
|
|
|
|
|
|
package_json.tasks.add(task);
|
|
|
|
|
|
}
|
|
|
|
|
|
tasksCount += new_tasks.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-15 18:10:27 +03:00
|
|
|
|
}
|