2023-11-19 02:12:44 +03:00
|
|
|
package TestingSystem.Common;
|
2023-11-14 20:08:19 +03:00
|
|
|
import Common.Constants;
|
2023-09-17 22:13:42 +03:00
|
|
|
import Common.Database.SQLITE.SQLiteDatabase;
|
|
|
|
|
import GlobalData.Settings.SettingName;
|
2023-12-11 02:00:28 +03:00
|
|
|
import TestingSystem.DVM.DVMPackage.DVMPackageDBTable;
|
2023-11-19 02:12:44 +03:00
|
|
|
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfigurationDBTable;
|
|
|
|
|
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommandsDBTable;
|
|
|
|
|
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforsDBTable;
|
2023-11-19 18:49:50 +03:00
|
|
|
import TestingSystem.DVM.Configuration.ConfigurationDBTable;
|
2023-11-19 02:12:44 +03:00
|
|
|
import TestingSystem.Common.Group.GroupsDBTable;
|
|
|
|
|
import TestingSystem.Common.TSetting.TSetting;
|
|
|
|
|
import TestingSystem.Common.TSetting.TSettingsDBTable;
|
|
|
|
|
import TestingSystem.Common.Test.TestDBTable;
|
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
public class TestsDatabase extends SQLiteDatabase {
|
2023-12-11 02:00:28 +03:00
|
|
|
public TSettingsDBTable settings; //todo может быть перенести в properties. пользователю ни к чему это скачивать.
|
|
|
|
|
///--
|
2023-09-17 22:13:42 +03:00
|
|
|
public ConfigurationDBTable configurations;
|
|
|
|
|
public TestDBTable tests;
|
|
|
|
|
public GroupsDBTable groups;
|
2023-12-11 02:00:28 +03:00
|
|
|
public DVMPackageDBTable dvm_packages;
|
2023-09-17 22:13:42 +03:00
|
|
|
//--
|
|
|
|
|
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-09-17 22:13:42 +03:00
|
|
|
public TestsDatabase() {
|
2023-11-14 20:08:19 +03:00
|
|
|
super(Paths.get(System.getProperty("user.dir"), "Data", Constants.tests_db_name + ".sqlite").toFile());
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void initAllTables() throws Exception {
|
|
|
|
|
addTable(configurations = new ConfigurationDBTable());
|
|
|
|
|
addTable(groups = new GroupsDBTable());
|
|
|
|
|
addTable(tests = new TestDBTable());
|
2023-12-11 02:00:28 +03:00
|
|
|
addTable(dvm_packages = new DVMPackageDBTable());
|
2023-09-17 22:13:42 +03:00
|
|
|
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-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void Init() throws Exception {
|
2023-11-21 17:44:59 +03:00
|
|
|
if (!settings.containsKey(SettingName.DVMPackageMaxId))
|
|
|
|
|
Insert(new TSetting(SettingName.DVMPackageMaxId, 0));
|
|
|
|
|
//-
|
|
|
|
|
if (!settings.containsKey(SettingName.SAPFORPackageId))
|
|
|
|
|
Insert(new TSetting(SettingName.SAPFORPackageId, 0));
|
|
|
|
|
//-
|
2023-09-17 22:13:42 +03:00
|
|
|
if (!settings.containsKey(SettingName.TaskMaxId))
|
2023-11-19 21:55:09 +03:00
|
|
|
Insert(new TSetting(SettingName.TaskMaxId, 0));
|
2023-11-21 17:44:59 +03:00
|
|
|
//-
|
2023-09-17 22:13:42 +03:00
|
|
|
if (!settings.containsKey(SettingName.SapforTaskMaxId))
|
|
|
|
|
Insert(new TSetting(SettingName.SapforTaskMaxId, 0));
|
|
|
|
|
}
|
2023-11-16 16:20:20 +03:00
|
|
|
@Override
|
|
|
|
|
public PassCode_2021 getSynchronizePassCode() {
|
|
|
|
|
return PassCode_2021.SynchronizeTests;
|
|
|
|
|
}
|
2023-11-21 17:44:59 +03:00
|
|
|
public long IncKey(SettingName settingName) throws Exception{
|
|
|
|
|
TSetting setting = settings.get(settingName);
|
2023-09-17 22:13:42 +03:00
|
|
|
long res = setting.value;
|
|
|
|
|
setting.value++;
|
|
|
|
|
Update(setting);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
}
|