создание пакета из нескольких старых
This commit is contained in:
@@ -5,7 +5,8 @@ import Common.Database.Database;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import TestingSystem.Common.Group.Group;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.Common.TasksPackageState;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
||||
@@ -14,15 +15,58 @@ import TestingSystem.SAPFOR.Json.SapforTest_json;
|
||||
import TestingSystem.SAPFOR.Json.SapforTestingSet_json;
|
||||
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
import Visual_DVM_2021.Passes.AddObjectPass;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
|
||||
import java.util.Vector;
|
||||
public class CloneSapforPackage extends AddObjectPass<SapforPackage> {
|
||||
SapforPackage src;
|
||||
Vector<SapforPackage> srcPackages;
|
||||
//--
|
||||
Vector<String> inexistingTests;
|
||||
Vector<String> inexistingConfigurations;
|
||||
//--
|
||||
public CloneSapforPackage() {
|
||||
super(SapforPackage.class);
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/MultiFiles.png";
|
||||
@@ -33,125 +77,110 @@ public class CloneSapforPackage extends AddObjectPass<SapforPackage> {
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
src = null;
|
||||
if (!Current.getAccount().CheckRegistered(Log)) {
|
||||
srcPackages = new Vector<>();
|
||||
if (!Current.getAccount().CheckRegistered(Log))
|
||||
return false;
|
||||
//--
|
||||
if (!Current.Check(Log, Current.ServerSapfor))
|
||||
return false;
|
||||
//--
|
||||
if (Global.testingServer.db.sapforPackages.getCheckedCount() > 0) {
|
||||
srcPackages = Global.testingServer.db.sapforPackages.getCheckedItems();
|
||||
} else {
|
||||
if (Current.Check(Log, Current.SapforPackage)) {
|
||||
srcPackages.add(Current.getSapforPackage());
|
||||
} else return false;
|
||||
}
|
||||
if (Current.Check(Log, Current.ServerSapfor, Current.SapforPackage)) {
|
||||
//-
|
||||
for (SapforPackage sapforPackage : Global.testingServer.db.sapforPackages.Data.values()) {
|
||||
if (sapforPackage.state.equals(TasksPackageState.Draft)) {
|
||||
Log.Writeln_("Может существовать только один пакет, готовящийся к публикации.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//--
|
||||
src = Current.getSapforPackage();
|
||||
if (!src.state.equals(TasksPackageState.Done)) {
|
||||
Log.Writeln_("Возможно повторить только завершенный пакет!");
|
||||
//--
|
||||
for (SapforPackage sapforPackage : Global.testingServer.db.sapforPackages.Data.values()) {
|
||||
if (sapforPackage.state.equals(TasksPackageState.Draft)) {
|
||||
Log.Writeln_("Может существовать только один пакет, готовящийся к публикации.");
|
||||
return false;
|
||||
}
|
||||
if (!src.isLoaded())
|
||||
passes.get(PassCode_2021.DownloadSapforPackage).Do(src);
|
||||
//-
|
||||
if (!src.isLoaded())
|
||||
return false;
|
||||
//----
|
||||
Vector<String> inexistingTests = new Vector<>();
|
||||
Vector<String> 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.tasksCount = 0;
|
||||
//--
|
||||
src.readJson();
|
||||
target.package_json = new SapforPackage_json();
|
||||
///-------------------------------
|
||||
target.package_json.kernels = target.kernels;
|
||||
target.package_json.sapfor_drv = target.drv;
|
||||
//--
|
||||
Vector<String> testsNames = new Vector<>();
|
||||
//--
|
||||
for (SapforTestingSet_json src_testingSet : src.package_json.testingSets) {
|
||||
int tests_count = 0;
|
||||
int configurations_count = 0;
|
||||
//--
|
||||
SapforTestingSet_json testingSet = new SapforTestingSet_json();
|
||||
testingSet.id = target.package_json.getMaxSetId();
|
||||
//--
|
||||
for (SapforTest_json src_TestJson : src_testingSet.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;
|
||||
//--
|
||||
testingSet.tests.add(testJson);
|
||||
//--
|
||||
testsNames.add(test.description);
|
||||
tests_count++;
|
||||
}else {
|
||||
inexistingTests.add(String.valueOf(src_TestJson.id));
|
||||
}
|
||||
}
|
||||
//--
|
||||
for (SapforConfiguration_json src_configuration : src_testingSet.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;
|
||||
configurationJson.flags = src_configuration.flags;
|
||||
configurationJson.codes.addAll(src_configuration.codes);
|
||||
//--
|
||||
testingSet.configurations.add(configurationJson);
|
||||
configurations_count++;
|
||||
}else {
|
||||
inexistingConfigurations.add(String.valueOf(src_configuration.id));
|
||||
}
|
||||
}
|
||||
//--
|
||||
target.package_json.testingSets.add(testingSet);
|
||||
target.tasksCount += tests_count * configurations_count;
|
||||
target.testsNames += String.join(";", testsNames) + ";";
|
||||
}
|
||||
//--
|
||||
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()+ " конфигураций отсутствует;"))
|
||||
+"\nПродолжить");
|
||||
}
|
||||
return false;
|
||||
//--
|
||||
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) + " является черновиком.");
|
||||
return false;
|
||||
}
|
||||
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) {
|
||||
//--
|
||||
for (SapforTestingSet_json src : srcPackage.testingSets) {
|
||||
SapforTestingSet_json dst = cloneTestingSet(src);
|
||||
//--
|
||||
Vector<SapforTask> new_tasks = target.getActualTestingSetTasks(dst);
|
||||
if (!new_tasks.isEmpty()){
|
||||
target.package_json.testingSets.add(dst);
|
||||
target.package_json.tasks.addAll(new_tasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
target.tasksCount = target.package_json.tasks.size();
|
||||
target.testsNames = String.join(";", target.package_json.getTestsNames());
|
||||
//--
|
||||
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() + " задач. Продолжить"
|
||||
);
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
// Utils.CheckAndCleanDirectory(target.getLocalWorkspace());
|
||||
// target.saveJson();
|
||||
Global.testingServer.db.sapforPackages.Data.put(target.id, target);
|
||||
//--
|
||||
Utils.CheckAndCleanDirectory(target.getLocalWorkspace());
|
||||
target.saveJson();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user