2023-09-17 22:13:42 +03:00
|
|
|
package TestingSystem;
|
|
|
|
|
import Common.Database.SQLITE.SQLiteDatabase;
|
|
|
|
|
import GlobalData.Settings.SettingName;
|
2023-10-03 15:07:17 +03:00
|
|
|
import SapforTestingSystem.SapforConfiguration.SapforConfigurationDBTable;
|
|
|
|
|
import SapforTestingSystem.SapforConfigurationCommand.SapforConfigurationCommandsDBTable;
|
2023-10-08 01:06:55 +03:00
|
|
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
2023-10-03 15:07:17 +03:00
|
|
|
import SapforTestingSystem.ServerSapfor.ServerSapforsDBTable;
|
2023-09-17 22:13:42 +03:00
|
|
|
import TestingSystem.Configuration.UI.ConfigurationDBTable;
|
|
|
|
|
import TestingSystem.Group.GroupsDBTable;
|
|
|
|
|
import TestingSystem.MachineMaxKernels.MachineMaxKernelsDBTable;
|
|
|
|
|
import TestingSystem.TSetting.TSetting;
|
|
|
|
|
import TestingSystem.TSetting.TSettingsDBTable;
|
|
|
|
|
import TestingSystem.Test.TestDBTable;
|
|
|
|
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
public class TestsDatabase extends SQLiteDatabase {
|
|
|
|
|
public ConfigurationDBTable configurations;
|
|
|
|
|
public TestDBTable tests;
|
|
|
|
|
public GroupsDBTable groups;
|
|
|
|
|
public MachineMaxKernelsDBTable machinesMaxKernels;
|
|
|
|
|
public TSettingsDBTable settings;
|
|
|
|
|
//--
|
|
|
|
|
public SapforConfigurationDBTable sapforConfigurations;
|
|
|
|
|
public SapforConfigurationCommandsDBTable sapforConfigurationCommands;
|
2023-10-04 00:25:36 +03:00
|
|
|
//----
|
2023-10-03 15:07:17 +03:00
|
|
|
public ServerSapforsDBTable serverSapfors;
|
2023-10-04 00:25:36 +03:00
|
|
|
//--
|
2023-10-08 01:57:25 +03:00
|
|
|
// public SapforTasksPackagesDBTable sapforTasksPackages;
|
2023-10-08 01:06:55 +03:00
|
|
|
// public SapforTasksPackagesDBTable sapforTasksPackages;
|
2023-09-17 22:13:42 +03:00
|
|
|
//--
|
|
|
|
|
public TestsDatabase() {
|
|
|
|
|
super(Paths.get(System.getProperty("user.dir"), "Data", TasksDatabase.tests_db_name + ".sqlite").toFile());
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void initAllTables() throws Exception {
|
|
|
|
|
addTable(configurations = new ConfigurationDBTable());
|
|
|
|
|
addTable(groups = new GroupsDBTable());
|
|
|
|
|
addTable(tests = new TestDBTable());
|
|
|
|
|
addTable(machinesMaxKernels = new MachineMaxKernelsDBTable());
|
|
|
|
|
addTable(settings = new TSettingsDBTable());
|
|
|
|
|
//-
|
|
|
|
|
addTable(sapforConfigurations = new SapforConfigurationDBTable());
|
|
|
|
|
addTable(sapforConfigurationCommands = new SapforConfigurationCommandsDBTable());
|
2023-10-03 15:07:17 +03:00
|
|
|
addTable(serverSapfors = new ServerSapforsDBTable());
|
2023-10-08 01:57:25 +03:00
|
|
|
// addTable(sapforTasksPackages = new SapforTasksPackagesDBTable());
|
2023-10-08 01:06:55 +03:00
|
|
|
// addTable(sapforTasksPackages = new SapforTasksPackagesDBTable());
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void Init() throws Exception {
|
|
|
|
|
if (!settings.containsKey(SettingName.TaskMaxId))
|
|
|
|
|
Insert(new TSetting(SettingName.TaskMaxId, 63128));
|
|
|
|
|
if (!settings.containsKey(SettingName.SapforTaskMaxId))
|
|
|
|
|
Insert(new TSetting(SettingName.SapforTaskMaxId, 0));
|
|
|
|
|
}
|
|
|
|
|
public long IncMaxTaskId() throws Exception {
|
|
|
|
|
TSetting setting = settings.get(SettingName.TaskMaxId);
|
|
|
|
|
long res = setting.value;
|
|
|
|
|
setting.value++;
|
|
|
|
|
Update(setting);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
public long IncSapforMaxTaskId() throws Exception {
|
|
|
|
|
TSetting setting = settings.get(SettingName.SapforTaskMaxId);
|
|
|
|
|
long res = setting.value;
|
|
|
|
|
setting.value++;
|
|
|
|
|
Update(setting);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2023-10-08 01:06:55 +03:00
|
|
|
public SapforTasksPackage getFirstActiveSapforScenario() {
|
2023-10-08 01:57:25 +03:00
|
|
|
/*
|
2023-10-08 01:06:55 +03:00
|
|
|
SapforTasksPackage first_active = null;
|
|
|
|
|
SapforTasksPackage first_queued = null;
|
|
|
|
|
if (!sapforTasksPackages.Data.isEmpty()) {
|
|
|
|
|
for (SapforTasksPackage s : sapforTasksPackages.Data.values()) {
|
|
|
|
|
switch (s.state) {
|
|
|
|
|
case Done:
|
|
|
|
|
case Aborted:
|
|
|
|
|
break;
|
|
|
|
|
case Queued:
|
|
|
|
|
if (first_queued == null) first_queued = s;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (first_active == null) first_active = s; //это и будет первый активный.
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (first_active != null) return first_active;
|
|
|
|
|
if (first_queued != null) {
|
|
|
|
|
first_queued.state = TasksPackageState.PackageStart;
|
|
|
|
|
try {
|
|
|
|
|
Update(first_queued);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return first_queued;
|
|
|
|
|
}
|
2023-10-08 01:57:25 +03:00
|
|
|
*/
|
2023-10-08 01:06:55 +03:00
|
|
|
return null;
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|