2023-12-11 01:24:30 +03:00
|
|
|
package TestingSystem.Common.TestingPackage;
|
2023-12-16 15:34:29 +03:00
|
|
|
import Common.Constants;
|
2023-12-11 01:24:30 +03:00
|
|
|
import Common.Database.DBObject;
|
2023-12-14 02:30:56 +03:00
|
|
|
import Common.Database.riDBObject;
|
2024-09-10 01:50:44 +03:00
|
|
|
import Common.Global;
|
2023-12-15 18:10:27 +03:00
|
|
|
import Common.Utils.Utils;
|
2024-09-10 01:50:44 +03:00
|
|
|
import TestingSystem.Common.Group.Group;
|
2023-12-17 19:19:59 +03:00
|
|
|
import TestingSystem.Common.TasksPackageState;
|
2024-09-10 01:50:44 +03:00
|
|
|
import TestingSystem.Common.Test.Test;
|
|
|
|
|
import TestingSystem.DVM.Configuration.Configuration;
|
2023-12-15 18:10:27 +03:00
|
|
|
import com.sun.org.glassfish.gmbal.Description;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
2024-09-10 01:50:44 +03:00
|
|
|
import java.util.Vector;
|
2023-12-15 18:10:27 +03:00
|
|
|
public abstract class TestingPackage<J> extends riDBObject {
|
|
|
|
|
public String PID = "";
|
2023-12-11 01:24:30 +03:00
|
|
|
public int tasksCount = 0; //Общее число задач
|
|
|
|
|
//--
|
|
|
|
|
public int kernels = 1;
|
|
|
|
|
public int needsEmail = 0;
|
|
|
|
|
//---
|
|
|
|
|
public String version = ""; //версия тестируемого объекта
|
|
|
|
|
public String drv = ""; //пусть к исполняемому файлы тестируемого объекта
|
|
|
|
|
//--
|
2023-12-11 18:29:15 +03:00
|
|
|
public int progress = 0; //прогресс выполнения
|
2023-12-15 14:02:12 +03:00
|
|
|
public long StartDate = 0;
|
|
|
|
|
public long ChangeDate = 0;
|
2024-04-08 01:30:46 +03:00
|
|
|
@Description("DEFAULT 0")
|
|
|
|
|
public int connectionErrosCount = 0;
|
2024-09-10 01:50:44 +03:00
|
|
|
//--
|
|
|
|
|
@Description("DEFAULT ''")
|
|
|
|
|
public String packedConfigurations = "";
|
|
|
|
|
@Description("DEFAULT ''")
|
|
|
|
|
public String packedGroups = "";
|
|
|
|
|
@Description("DEFAULT ''")
|
|
|
|
|
public String packedTests = "";
|
|
|
|
|
//--
|
2023-12-11 18:29:15 +03:00
|
|
|
public TasksPackageState state = TasksPackageState.Draft;
|
2023-12-11 01:24:30 +03:00
|
|
|
//--
|
|
|
|
|
@Override
|
|
|
|
|
public void SynchronizeFields(DBObject src) {
|
|
|
|
|
super.SynchronizeFields(src);
|
2023-12-15 18:10:27 +03:00
|
|
|
TestingPackage tp = (TestingPackage) src;
|
2023-12-11 01:24:30 +03:00
|
|
|
//--
|
2023-12-15 18:10:27 +03:00
|
|
|
tasksCount = tp.tasksCount;
|
|
|
|
|
needsEmail = tp.needsEmail;
|
|
|
|
|
version = tp.version;
|
|
|
|
|
drv = tp.drv;
|
|
|
|
|
PID = tp.PID;
|
|
|
|
|
kernels = tp.kernels;
|
|
|
|
|
progress = tp.progress;
|
|
|
|
|
StartDate = tp.StartDate;
|
|
|
|
|
ChangeDate = tp.ChangeDate;
|
2024-04-08 01:30:46 +03:00
|
|
|
connectionErrosCount = tp.connectionErrosCount;
|
2023-12-15 18:10:27 +03:00
|
|
|
state = tp.state;
|
2024-09-11 17:00:36 +03:00
|
|
|
//--
|
|
|
|
|
packedConfigurations=tp.packedConfigurations;
|
|
|
|
|
packedGroups=tp.packedGroups;
|
|
|
|
|
packedTests=tp.packedTests;
|
|
|
|
|
//--
|
2023-12-11 01:24:30 +03:00
|
|
|
}
|
2023-12-15 14:02:12 +03:00
|
|
|
public TestingPackage(TestingPackage p) {
|
|
|
|
|
SynchronizeFields(p);
|
|
|
|
|
}
|
|
|
|
|
public TestingPackage() {
|
|
|
|
|
}
|
2023-12-15 18:10:27 +03:00
|
|
|
public File getLocalWorkspace() {
|
2023-12-15 18:38:05 +03:00
|
|
|
return new File(getHomeDirectory(), String.valueOf(id));
|
2023-12-15 18:10:27 +03:00
|
|
|
}
|
2023-12-18 00:04:44 +03:00
|
|
|
public boolean isLoaded() {
|
|
|
|
|
return new File(getLocalWorkspace(), Constants.LOADED).exists();
|
|
|
|
|
}
|
2023-12-15 18:10:27 +03:00
|
|
|
//------------------------
|
|
|
|
|
@Description("IGNORED")
|
2023-12-16 15:34:29 +03:00
|
|
|
public J package_json = null;
|
2023-12-15 18:10:27 +03:00
|
|
|
public abstract Class getJsonClass();
|
2023-12-15 18:38:05 +03:00
|
|
|
public abstract File getHomeDirectory();
|
2023-12-15 18:10:27 +03:00
|
|
|
public File getJsonFile() {
|
|
|
|
|
return new File(getLocalWorkspace(), "package_json");
|
|
|
|
|
}
|
2023-12-16 15:34:29 +03:00
|
|
|
public File getLoadedFile() {
|
|
|
|
|
return new File(getLocalWorkspace(), Constants.LOADED);
|
|
|
|
|
}
|
2023-12-15 18:10:27 +03:00
|
|
|
public void saveJson() throws Exception {
|
|
|
|
|
Utils.jsonToFile(package_json, getJsonFile());
|
|
|
|
|
}
|
|
|
|
|
public void readJson() throws Exception {
|
|
|
|
|
package_json = (J) Utils.jsonFromFile(getJsonFile(), getJsonClass());
|
|
|
|
|
}
|
2023-12-15 14:02:12 +03:00
|
|
|
public void destructor() {
|
2023-12-15 18:10:27 +03:00
|
|
|
package_json = null;
|
2023-12-15 14:02:12 +03:00
|
|
|
}
|
2024-09-10 01:50:44 +03:00
|
|
|
public Vector<Configuration> getConfigurations() {
|
|
|
|
|
Vector<Configuration> res = new Vector<>();
|
|
|
|
|
for (int o_id : Utils.unpack(packedConfigurations))
|
|
|
|
|
if (Global.testingServer.db.configurations.containsKey(o_id))
|
|
|
|
|
res.add(Global.testingServer.db.configurations.get(o_id));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
public Vector<Group> getGroups() {
|
|
|
|
|
Vector<Group> res = new Vector<>();
|
|
|
|
|
for (int o_id : Utils.unpack(packedGroups))
|
|
|
|
|
if (Global.testingServer.db.groups.containsKey(o_id))
|
|
|
|
|
res.add(Global.testingServer.db.groups.get(o_id));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
public Vector<Test> getTests() {
|
|
|
|
|
Vector<Test> res = new Vector<>();
|
|
|
|
|
for (int o_id : Utils.unpack(packedTests))
|
|
|
|
|
if (Global.testingServer.db.tests.containsKey(o_id))
|
|
|
|
|
res.add(Global.testingServer.db.tests.get(o_id));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2024-09-11 17:00:36 +03:00
|
|
|
/*
|
2024-09-10 01:50:44 +03:00
|
|
|
public void printCGT() {
|
|
|
|
|
try {
|
|
|
|
|
System.out.println("package="+id);
|
|
|
|
|
Vector<Configuration> configurations = getConfigurations();
|
|
|
|
|
System.out.println("+");
|
|
|
|
|
|
|
|
|
|
Vector<Group> groups = getGroups();
|
|
|
|
|
Vector<Test> tests = getTests();
|
|
|
|
|
Vector<String> res = new Vector<>();
|
|
|
|
|
res.add("конфигурации: " + configurations.size());
|
|
|
|
|
for (Configuration configuration : configurations)
|
|
|
|
|
res.add(configuration.description);
|
|
|
|
|
|
|
|
|
|
res.add("группы: " + groups.size());
|
|
|
|
|
for (Group group : groups)
|
|
|
|
|
res.add(group.description);
|
|
|
|
|
//--
|
|
|
|
|
res.add("тесты: " + tests.size());
|
|
|
|
|
for (Test test : tests)
|
|
|
|
|
res.add(test.description);
|
|
|
|
|
//--
|
|
|
|
|
res.add("-------");
|
|
|
|
|
System.out.println(String.join("\n", res));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex){
|
|
|
|
|
System.out.println("```");
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-11 17:00:36 +03:00
|
|
|
*/
|
2024-09-10 01:50:44 +03:00
|
|
|
public void addConfigurations(Vector<Configuration> new_configurations){
|
|
|
|
|
Vector<String> res= Utils.unpack_s(packedConfigurations);
|
|
|
|
|
//---
|
|
|
|
|
System.out.println("old_configs "+res.size());
|
|
|
|
|
for(String id_: res){
|
|
|
|
|
System.out.println(Utils.Brackets(id_));
|
|
|
|
|
}
|
|
|
|
|
//---
|
|
|
|
|
for (Configuration configuration: new_configurations){
|
|
|
|
|
String id_ = String.valueOf(configuration.id);
|
|
|
|
|
if (!res.contains(id_))
|
|
|
|
|
res.add(id_);
|
|
|
|
|
}
|
|
|
|
|
packedConfigurations= String.join("\n", res );
|
|
|
|
|
System.out.println("new_configs="+res.size());
|
|
|
|
|
for(String id_: res){
|
|
|
|
|
System.out.println(Utils.Brackets(id_));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void addGroups(Vector<Group> new_groups){
|
|
|
|
|
Vector<String> res= Utils.unpack_s(packedGroups);
|
|
|
|
|
//---
|
|
|
|
|
for (Group group: new_groups){
|
|
|
|
|
String id_ = String.valueOf(group.id);
|
|
|
|
|
if (!res.contains(id_))
|
|
|
|
|
res.add(id_);
|
|
|
|
|
}
|
|
|
|
|
packedGroups= String.join("\n", res );
|
|
|
|
|
}
|
|
|
|
|
public void addTests(Vector<Test> new_tests){
|
|
|
|
|
Vector<String> res= Utils.unpack_s(packedTests);
|
|
|
|
|
//---
|
|
|
|
|
for (Test test: new_tests){
|
|
|
|
|
String id_ = String.valueOf(test.id);
|
|
|
|
|
if (!res.contains(id_))
|
|
|
|
|
res.add(id_);
|
|
|
|
|
}
|
|
|
|
|
packedTests= String.join("\n", res );
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------->>>
|
2023-12-11 01:24:30 +03:00
|
|
|
}
|