2023-09-17 22:13:42 +03:00
|
|
|
|
package GlobalData;
|
|
|
|
|
|
import Common.Current;
|
|
|
|
|
|
import Common.Database.DBObject;
|
|
|
|
|
|
import Common.Database.DataSet;
|
|
|
|
|
|
import Common.Database.SQLITE.SQLiteDatabase;
|
|
|
|
|
|
import Common.Global;
|
|
|
|
|
|
import Common.UI.DataSetControlForm;
|
|
|
|
|
|
import GlobalData.Account.Account;
|
|
|
|
|
|
import GlobalData.Account.AccountsDBTable;
|
|
|
|
|
|
import GlobalData.Compiler.CompilersDBTable;
|
|
|
|
|
|
import GlobalData.Credentials.Credentials;
|
|
|
|
|
|
import GlobalData.Credentials.CredentialsDBTable;
|
|
|
|
|
|
import GlobalData.DBLastProject.LastProjectsDBTable;
|
|
|
|
|
|
import GlobalData.DVMParameter.DVMParameterDBTable;
|
|
|
|
|
|
import GlobalData.EnvironmentValue.EnvironmentValuesDBTable;
|
|
|
|
|
|
import GlobalData.FormsParams.FormsDBTable;
|
|
|
|
|
|
import GlobalData.FormsParams.MainFormParamsDBTable;
|
|
|
|
|
|
import GlobalData.Grid.GridsDBTable;
|
|
|
|
|
|
import GlobalData.Machine.MachinesDBTable;
|
|
|
|
|
|
import GlobalData.Makefile.MakefilesDBTable;
|
|
|
|
|
|
import GlobalData.Module.ModulesDBTable;
|
|
|
|
|
|
import GlobalData.RemoteSapfor.RemoteSapforsDBTable;
|
|
|
|
|
|
import GlobalData.RunConfiguration.RunConfigurationsDBTable;
|
|
|
|
|
|
import GlobalData.SapforProfile.SapforProfile;
|
|
|
|
|
|
import GlobalData.SapforProfile.SapforProfilesDBTable;
|
|
|
|
|
|
import GlobalData.SapforProfileSetting.SapforProfileSetting;
|
|
|
|
|
|
import GlobalData.SapforProfileSetting.SapforProfileSettingsDBTable;
|
|
|
|
|
|
import GlobalData.Settings.DBSetting;
|
|
|
|
|
|
import GlobalData.Settings.SettingName;
|
|
|
|
|
|
import GlobalData.Settings.SettingsDBTable;
|
|
|
|
|
|
import GlobalData.Splitter.SplittersDBTable;
|
|
|
|
|
|
import GlobalData.Tasks.CompilationTask.CompilationTasksDBTable;
|
|
|
|
|
|
import GlobalData.Tasks.RunTask.RunTasksDBTable;
|
|
|
|
|
|
import GlobalData.User.UsersDBTable;
|
|
|
|
|
|
import Repository.Component.ComponentType;
|
2023-09-21 20:55:14 +03:00
|
|
|
|
import SapforTestingSystem.SapforTask.SapforTaskResult;
|
2023-09-27 00:43:23 +03:00
|
|
|
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import TestingSystem.TaskKey.TaskKeysDBTable;
|
|
|
|
|
|
import Visual_DVM_2021.PassStats.PassStatsDBTable;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.Pass_2021;
|
|
|
|
|
|
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
|
|
|
|
|
|
|
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
|
|
|
|
|
|
public class GlobalDatabase extends SQLiteDatabase {
|
|
|
|
|
|
//---------СЕАНС----------------------------------------------
|
|
|
|
|
|
public MachinesDBTable machines;
|
|
|
|
|
|
public UsersDBTable users;
|
|
|
|
|
|
public CompilersDBTable compilers;
|
|
|
|
|
|
public RemoteSapforsDBTable remoteSapfors;
|
|
|
|
|
|
public MakefilesDBTable makefiles;
|
|
|
|
|
|
public ModulesDBTable modules;
|
|
|
|
|
|
public CompilationTasksDBTable compilationTasks;
|
|
|
|
|
|
public RunTasksDBTable runTasks;
|
|
|
|
|
|
public RunConfigurationsDBTable runConfigurations;
|
|
|
|
|
|
public EnvironmentValuesDBTable environmentValues;
|
|
|
|
|
|
public DVMParameterDBTable dvmParameters;
|
|
|
|
|
|
public CredentialsDBTable credentials;
|
|
|
|
|
|
//----- ДАННЫЕ ВИЗУАЛИЗАТОРА---------------------------------
|
|
|
|
|
|
public FormsDBTable forms;
|
|
|
|
|
|
public MainFormParamsDBTable mainFormParams;
|
|
|
|
|
|
public SettingsDBTable settings;
|
|
|
|
|
|
public LastProjectsDBTable lastProjects;
|
|
|
|
|
|
public AccountsDBTable accounts;
|
|
|
|
|
|
public PassStatsDBTable passStats;
|
|
|
|
|
|
public SplittersDBTable splitters;
|
|
|
|
|
|
public GridsDBTable grids;
|
|
|
|
|
|
//-
|
|
|
|
|
|
public TaskKeysDBTable tasksKeys;
|
|
|
|
|
|
//---------
|
2023-10-06 01:03:55 +03:00
|
|
|
|
// public SapforScenariosDBTable sapforScenarios;
|
|
|
|
|
|
// public SapforTasksPackagesDBTable sapforTasksPackages;
|
|
|
|
|
|
// public SapforTasksDBTable sapforTasks = null;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
public SapforProfilesDBTable sapforProfiles = null;
|
|
|
|
|
|
//---------
|
|
|
|
|
|
public SapforProfileSettingsDBTable sapforProfilesSettings = null;
|
|
|
|
|
|
//-
|
|
|
|
|
|
public GlobalDatabase() {
|
|
|
|
|
|
super(Paths.get(System.getProperty("user.dir"), "Data", Global.properties.GlobalDBName).toFile());
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void initAllTables() throws Exception {
|
|
|
|
|
|
addTable(machines = new MachinesDBTable());
|
|
|
|
|
|
addTable(users = new UsersDBTable());
|
|
|
|
|
|
addTable(compilers = new CompilersDBTable());
|
|
|
|
|
|
addTable(remoteSapfors = new RemoteSapforsDBTable());
|
|
|
|
|
|
addTable(makefiles = new MakefilesDBTable());
|
|
|
|
|
|
addTable(modules = new ModulesDBTable());
|
|
|
|
|
|
addTable(compilationTasks = new CompilationTasksDBTable());
|
|
|
|
|
|
addTable(runTasks = new RunTasksDBTable());
|
|
|
|
|
|
addTable(runConfigurations = new RunConfigurationsDBTable());
|
|
|
|
|
|
addTable(environmentValues = new EnvironmentValuesDBTable());
|
|
|
|
|
|
addTable(credentials = new CredentialsDBTable());
|
|
|
|
|
|
addTable(forms = new FormsDBTable());
|
|
|
|
|
|
addTable(settings = new SettingsDBTable());
|
|
|
|
|
|
addTable(mainFormParams = new MainFormParamsDBTable());
|
|
|
|
|
|
addTable(lastProjects = new LastProjectsDBTable());
|
|
|
|
|
|
addTable(accounts = new AccountsDBTable());
|
|
|
|
|
|
addTable(passStats = new PassStatsDBTable());
|
|
|
|
|
|
addTable(splitters = new SplittersDBTable());
|
|
|
|
|
|
addTable(dvmParameters = new DVMParameterDBTable());
|
|
|
|
|
|
addTable(grids = new GridsDBTable());
|
|
|
|
|
|
addTable(tasksKeys = new TaskKeysDBTable());
|
|
|
|
|
|
//--
|
2023-10-06 01:03:55 +03:00
|
|
|
|
// addTable(sapforScenarios = new SapforScenariosDBTable());
|
|
|
|
|
|
// addTable(sapforTasksPackages = new SapforTasksPackagesDBTable());
|
|
|
|
|
|
// addTable(sapforTasks = new SapforTasksDBTable());
|
2023-09-17 22:13:42 +03:00
|
|
|
|
//--
|
|
|
|
|
|
addTable(sapforProfiles = new SapforProfilesDBTable());
|
|
|
|
|
|
addTable(sapforProfilesSettings = new SapforProfileSettingsDBTable());
|
|
|
|
|
|
}
|
|
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void Init() throws Exception {
|
|
|
|
|
|
Current.set(Current.Account,
|
|
|
|
|
|
accounts.Data.isEmpty() ? Insert(new Account()) :
|
|
|
|
|
|
accounts.getFirstRecord()
|
|
|
|
|
|
);
|
|
|
|
|
|
Current.set(Current.Credentials,
|
|
|
|
|
|
credentials.Data.isEmpty() ? Insert(new Credentials()) :
|
|
|
|
|
|
credentials.getFirstRecord());
|
|
|
|
|
|
//настройки компонент
|
|
|
|
|
|
settings.AddAll();
|
|
|
|
|
|
runConfigurations.Patch();
|
|
|
|
|
|
}
|
|
|
|
|
|
public void SaveCredentials() throws Exception {
|
|
|
|
|
|
Credentials credentials = (Credentials) Current.get(Current.Credentials);
|
|
|
|
|
|
if (Current.HasMachine())
|
|
|
|
|
|
credentials.machine_id = Current.getMachine().id;
|
|
|
|
|
|
if (Current.HasUser())
|
|
|
|
|
|
credentials.user_id = Current.getUser().id;
|
|
|
|
|
|
if (Current.HasCompiler())
|
|
|
|
|
|
credentials.compiler_id = Current.getCompiler().id;
|
|
|
|
|
|
if (Current.HasMakefile())
|
|
|
|
|
|
credentials.makefile_id = Current.getMakefile().id;
|
|
|
|
|
|
if (Current.HasRunConfiguration())
|
|
|
|
|
|
credentials.runconfiguration_id = Current.getRunConfiguration().id;
|
|
|
|
|
|
if (Current.HasRemoteSapfor())
|
|
|
|
|
|
credentials.remotesapfor_id = Current.getRemoteSapfor().id;
|
|
|
|
|
|
Update(credentials);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void UpdateCredentials() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
Global.db.Update((DBObject) Current.get(Current.Credentials));
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
Global.Log.PrintException(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public long IncSapforMaxTaskId() {
|
|
|
|
|
|
long res = Global.properties.SapforTaskMaxId;
|
|
|
|
|
|
Global.properties.SapforTaskMaxId++;
|
|
|
|
|
|
Global.properties.Update();
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
2023-10-04 00:25:36 +03:00
|
|
|
|
/*
|
2023-09-27 00:43:23 +03:00
|
|
|
|
public LinkedHashMap<Long, SapforTask> getSapforPackageTasks(int package_id) throws Exception {
|
|
|
|
|
|
LinkedHashMap<Long, SapforTask> res = new LinkedHashMap<>();
|
|
|
|
|
|
for (SapforTask task : sapforTasks.Data.values()) {
|
2023-10-04 00:25:36 +03:00
|
|
|
|
if (task.sapfor_configuration_id == package_id) {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
res.put(task.id, task);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
2023-10-04 00:25:36 +03:00
|
|
|
|
*/
|
2023-09-27 00:43:23 +03:00
|
|
|
|
public DataSet<String, SapforTaskResult> getSapforPackagesMasterDataSet(SapforTasksPackage package_in) throws Exception {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
DataSet<String, SapforTaskResult> res = new DataSet<String, SapforTaskResult>(String.class, SapforTaskResult.class) {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected DataSetControlForm createUI() {
|
|
|
|
|
|
return new DataSetControlForm(this) {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void AdditionalInitColumns() {
|
|
|
|
|
|
columns.get(1).setRenderer(RendererStatusEnum);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void MouseAction2() throws Exception {
|
|
|
|
|
|
Pass_2021.passes.get(PassCode_2021.OpenSapforTest).Do(Current.SapforEtalonTaskResult);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void ShowCurrentObject() throws Exception {
|
|
|
|
|
|
System.out.println(Current.get(Current.SapforEtalonTaskResult));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String[] getUIColumnNames() {
|
|
|
|
|
|
return new String[]{
|
|
|
|
|
|
"Статус"
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Object getFieldAt(SapforTaskResult object, int columnIndex) {
|
|
|
|
|
|
switch (columnIndex) {
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
return object.task.state;
|
|
|
|
|
|
default:
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Current CurrentName() {
|
|
|
|
|
|
return Current.SapforEtalonTaskResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2023-10-04 00:25:36 +03:00
|
|
|
|
/*
|
2023-09-27 00:43:23 +03:00
|
|
|
|
for (SapforTask task : sapforTasks.Data.values())
|
2023-10-04 00:25:36 +03:00
|
|
|
|
if (task.sapfor_configuration_id == package_in.id)
|
2023-09-17 22:13:42 +03:00
|
|
|
|
res.put(task.test_description, new SapforTaskResult(package_in, task));
|
2023-10-04 00:25:36 +03:00
|
|
|
|
*/
|
2023-09-17 22:13:42 +03:00
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
2023-09-27 00:43:23 +03:00
|
|
|
|
public DataSet<String, SapforTaskResult> getSapforPackagesSlaveDataSet(SapforTasksPackage package_in) throws Exception {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
DataSet<String, SapforTaskResult> res = new DataSet<String, SapforTaskResult>(String.class, SapforTaskResult.class) {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected DataSetControlForm createUI() {
|
|
|
|
|
|
return new DataSetControlForm(this) {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void AdditionalInitColumns() {
|
|
|
|
|
|
columns.get(1).setRenderer(RendererStatusEnum);
|
|
|
|
|
|
columns.get(2).setRenderer(RendererStatusEnum);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void MouseAction2() throws Exception {
|
2023-09-27 00:43:23 +03:00
|
|
|
|
Pass_2021.passes.get(PassCode_2021.OpenSapforTest).Do(Current.SapforTaskResult);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void ShowCurrentObject() throws Exception {
|
|
|
|
|
|
System.out.println(Current.get(Current.SapforTaskResult));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String[] getUIColumnNames() {
|
|
|
|
|
|
return new String[]{
|
|
|
|
|
|
"Статус",
|
|
|
|
|
|
"Совпадение"
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Object getFieldAt(SapforTaskResult object, int columnIndex) {
|
|
|
|
|
|
switch (columnIndex) {
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
return object.task.state;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
return object.match_state;
|
|
|
|
|
|
default:
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public Current CurrentName() {
|
|
|
|
|
|
return Current.SapforTaskResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2023-10-04 00:25:36 +03:00
|
|
|
|
/*
|
2023-09-27 00:43:23 +03:00
|
|
|
|
for (SapforTask task : sapforTasks.Data.values())
|
2023-10-04 00:25:36 +03:00
|
|
|
|
if (task.sapfor_configuration_id == package_in.id)
|
2023-09-17 22:13:42 +03:00
|
|
|
|
res.put(task.test_description, new SapforTaskResult(package_in, task));
|
2023-10-04 00:25:36 +03:00
|
|
|
|
*/
|
2023-09-17 22:13:42 +03:00
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
//--
|
|
|
|
|
|
public LinkedHashMap<SettingName, String> getSapforSettingsForProfile() {
|
|
|
|
|
|
LinkedHashMap<SettingName, String> res = new LinkedHashMap<>();
|
|
|
|
|
|
for (DBSetting setting : Global.db.settings.getSettingsByOwner(ComponentType.SapforOptions))
|
|
|
|
|
|
if (setting.Visible)
|
|
|
|
|
|
res.put(setting.Name, setting.Value);
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
//проверить, есть ли профиль с таким же набором настроек.
|
|
|
|
|
|
public SapforProfile checkProfileForCurrentSettings() {
|
|
|
|
|
|
LinkedHashMap<SettingName, String> current_values = getSapforSettingsForProfile();
|
|
|
|
|
|
for (SapforProfile profile : sapforProfiles.Data.values()) {
|
|
|
|
|
|
//--получить все настройки профиля
|
|
|
|
|
|
LinkedHashMap<SettingName, String> profileValues = new LinkedHashMap<>();
|
|
|
|
|
|
for (SapforProfileSetting setting : sapforProfilesSettings.Data.values())
|
|
|
|
|
|
if (setting.sapforprofile_id == profile.id) profileValues.put(setting.name, setting.value);
|
|
|
|
|
|
//--
|
|
|
|
|
|
if (current_values.equals(profileValues)) return profile;
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void insertProfileSettings(SapforProfile profile) throws Exception {
|
|
|
|
|
|
LinkedHashMap<SettingName, String> current_values = getSapforSettingsForProfile();
|
|
|
|
|
|
for (SettingName name : current_values.keySet()) {
|
|
|
|
|
|
//--
|
|
|
|
|
|
SapforProfileSetting sapforProfileSetting = new SapforProfileSetting();
|
|
|
|
|
|
sapforProfileSetting.name = name;
|
|
|
|
|
|
sapforProfileSetting.value = current_values.get(name);
|
|
|
|
|
|
sapforProfileSetting.sapforprofile_id = profile.id;
|
|
|
|
|
|
//--
|
|
|
|
|
|
Insert(sapforProfileSetting);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void saveCurrentProfile(String name_in) throws Exception {
|
|
|
|
|
|
if (Global.db.checkProfileForCurrentSettings() == null) {
|
|
|
|
|
|
SapforProfile profile = new SapforProfile();
|
|
|
|
|
|
profile.description = name_in;
|
|
|
|
|
|
profile.creationDate = new Date().getTime();
|
|
|
|
|
|
Global.db.Insert(profile);
|
|
|
|
|
|
Global.db.insertProfileSettings(profile);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void rewriteProfileByDescription(String description_in) throws Exception {
|
|
|
|
|
|
SapforProfile old = null;
|
|
|
|
|
|
//ищем профиль с именем бага
|
|
|
|
|
|
for (SapforProfile p : Global.db.sapforProfiles.Data.values())
|
|
|
|
|
|
if (p.description.equalsIgnoreCase(description_in)) {
|
|
|
|
|
|
old = p;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (old != null) {
|
|
|
|
|
|
//удалить профиль с именем бага,если есть, чтобы не множить кроликов.
|
|
|
|
|
|
//при условии что не видно окна профилей!!
|
|
|
|
|
|
Global.db.Delete(old);
|
|
|
|
|
|
Global.db.DeleteByFK(old, SapforProfileSetting.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
//---
|
|
|
|
|
|
SapforProfile profile = new SapforProfile();
|
|
|
|
|
|
profile.description = description_in;
|
|
|
|
|
|
profile.creationDate = new Date().getTime();
|
|
|
|
|
|
Global.db.Insert(profile);
|
|
|
|
|
|
Global.db.insertProfileSettings(profile);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|