157 lines
7.2 KiB
Java
157 lines
7.2 KiB
Java
|
|
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;
|
|||
|
|
import TestingSystem.Common.Group.Group;
|
|||
|
|
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;
|
|||
|
|
import Visual_DVM_2021.Passes.AddObjectPass;
|
|||
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|||
|
|
|
|||
|
|
import java.util.Vector;
|
|||
|
|
public class CloneSapforPackage extends AddObjectPass<SapforPackage> {
|
|||
|
|
SapforPackage src;
|
|||
|
|
public CloneSapforPackage() {
|
|||
|
|
super(SapforPackage.class);
|
|||
|
|
}
|
|||
|
|
@Override
|
|||
|
|
public String getIconPath() {
|
|||
|
|
return "/icons/MultiFiles.png";
|
|||
|
|
}
|
|||
|
|
@Override
|
|||
|
|
protected Database getDb() {
|
|||
|
|
return Global.testingServer.db;
|
|||
|
|
}
|
|||
|
|
@Override
|
|||
|
|
protected boolean canStart(Object... args) throws Exception {
|
|||
|
|
src = null;
|
|||
|
|
if (!Current.getAccount().CheckRegistered(Log)) {
|
|||
|
|
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_("Возможно повторить только завершенный пакет!");
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
@Override
|
|||
|
|
protected void body() throws Exception {
|
|||
|
|
// Utils.CheckAndCleanDirectory(target.getLocalWorkspace());
|
|||
|
|
// target.saveJson();
|
|||
|
|
Global.testingServer.db.sapforPackages.Data.put(target.id, target);
|
|||
|
|
}
|
|||
|
|
}
|