2025-02-18 16:21:20 +03:00
|
|
|
package _VisualDVM.ComponentsServer;
|
2023-09-17 22:13:42 +03:00
|
|
|
import Common.Database.SQLITE.SQLiteDatabase;
|
2025-03-27 12:45:55 +03:00
|
|
|
import Common.Utils.Vector_;
|
2025-02-18 16:21:20 +03:00
|
|
|
import _VisualDVM.ComponentsServer.BugReport.BugReport;
|
|
|
|
|
import _VisualDVM.ComponentsServer.BugReport.BugReportsDBTable;
|
2025-03-27 12:45:55 +03:00
|
|
|
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingJson;
|
|
|
|
|
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingsJson;
|
|
|
|
|
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
|
|
|
|
|
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSettingsDBTable;
|
2025-02-19 22:47:56 +03:00
|
|
|
import _VisualDVM.ComponentsServer.Recipient.RecipientsDataSet;
|
2024-10-14 15:19:13 +03:00
|
|
|
import _VisualDVM.Passes.PassCode;
|
2025-03-27 12:45:55 +03:00
|
|
|
import _VisualDVM.ProjectData.SapforData.SapforProperties;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
public class BugReportsDatabase extends SQLiteDatabase {
|
|
|
|
|
public BugReportsDBTable bugReports;
|
2025-03-27 12:45:55 +03:00
|
|
|
public BugReportSettingsDBTable bugReportSettings;
|
2025-02-19 22:47:56 +03:00
|
|
|
public RecipientsDataSet recipients = new RecipientsDataSet();
|
2023-09-17 22:13:42 +03:00
|
|
|
public BugReportsDatabase() {
|
2025-01-18 01:36:02 +03:00
|
|
|
super(Paths.get(System.getProperty("user.dir"), "Data", "bug_reports.sqlite").toFile());
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void initAllTables() throws Exception {
|
|
|
|
|
addTable(bugReports = new BugReportsDBTable());
|
2025-03-27 12:45:55 +03:00
|
|
|
addTable(bugReportSettings = new BugReportSettingsDBTable());
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void Init() throws Exception {
|
|
|
|
|
DeleteDrafts();
|
|
|
|
|
}
|
2023-11-16 16:20:20 +03:00
|
|
|
@Override
|
2024-10-09 23:37:58 +03:00
|
|
|
public PassCode getSynchronizePassCode() {
|
|
|
|
|
return PassCode.SynchronizeBugReports;
|
2023-11-16 16:20:20 +03:00
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
public void DeleteDrafts() throws Exception {
|
|
|
|
|
Vector<BugReport> drafts = bugReports.getAllDrafts();
|
|
|
|
|
for (BugReport draft : drafts)
|
|
|
|
|
Delete(draft);
|
|
|
|
|
}
|
2025-02-18 23:45:24 +03:00
|
|
|
@Override
|
2025-02-04 16:22:42 +03:00
|
|
|
public void DropUI() {
|
2025-02-18 23:45:24 +03:00
|
|
|
super.DropUI();
|
2025-02-04 16:22:42 +03:00
|
|
|
bugReports.ClearUI();
|
2025-02-19 22:47:56 +03:00
|
|
|
recipients.ClearUI();
|
2025-02-04 16:22:42 +03:00
|
|
|
}
|
2025-02-18 23:45:24 +03:00
|
|
|
@Override
|
2025-02-04 16:22:42 +03:00
|
|
|
public void ResetUI() {
|
|
|
|
|
bugReports.ShowUI();
|
2025-02-19 22:47:56 +03:00
|
|
|
recipients.ShowUI(); //todo временно.
|
2025-02-18 23:45:24 +03:00
|
|
|
super.ResetUI();
|
2025-02-04 16:22:42 +03:00
|
|
|
}
|
2025-03-27 12:45:55 +03:00
|
|
|
public void Patch() throws Exception {
|
|
|
|
|
Vector<BugReportSetting> settings = new Vector<>();
|
|
|
|
|
//--
|
|
|
|
|
for (BugReport bugReport : bugReports.Data.values()) {
|
|
|
|
|
//--
|
|
|
|
|
if (!bugReport.project_version.isEmpty()) {
|
|
|
|
|
if (bugReport.visualiser_version < 1134) {
|
|
|
|
|
VisualiserSettingsJson visualiserSettingsJson = bugReport.getSettingsJson();
|
|
|
|
|
for (VisualiserSettingJson visualiserSettingJson : visualiserSettingsJson.array) {
|
|
|
|
|
BugReportSetting bugReportSetting = new BugReportSetting();
|
|
|
|
|
bugReportSetting.bugreport_id = bugReport.id;
|
|
|
|
|
bugReportSetting.name = visualiserSettingJson.name;
|
|
|
|
|
bugReportSetting.value = visualiserSettingJson.value;
|
|
|
|
|
settings.add(bugReportSetting);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
SapforProperties sapforProperties = bugReport.getPropertiesJson();
|
|
|
|
|
Vector<BugReportSetting> settings_= sapforProperties.toBugReportSettings();
|
|
|
|
|
for (BugReportSetting bugReportSetting: settings_)
|
|
|
|
|
bugReportSetting.bugreport_id = bugReport.id;
|
|
|
|
|
settings.addAll(settings_);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//--
|
|
|
|
|
}
|
|
|
|
|
BeginTransaction();
|
|
|
|
|
for (BugReportSetting bugReportSetting : settings)
|
|
|
|
|
Insert(bugReportSetting);
|
|
|
|
|
Commit();
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|