рефакторинг адресатов баг репортов

This commit is contained in:
2025-03-27 15:12:09 +03:00
parent 86b582dd1f
commit dcdbaa83cf
8 changed files with 135 additions and 35 deletions

9
.idea/workspace.xml generated
View File

@@ -7,7 +7,14 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/PublishBugReport.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/PublishBugReport.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/BugReportRecipient/BugReportRecipient.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/BugReportRecipient/BugReportRecipientsDBTable.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/BugReport/BugReport.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/BugReport/BugReport.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/BugReport/BugReportsDBTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/BugReport/BugReportsDBTable.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/BugReportsDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/BugReportsDatabase.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/ComponentsServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/ComponentsServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SaveBugReportRecipients.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SaveBugReportRecipients.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -4,12 +4,10 @@ import Common.Database.Objects.rDBObject;
import Common.Utils.TextLog;
import Common.Utils.Utils_;
import Common.Utils.Vector_;
import _VisualDVM.ComponentsServer.BugReport.Json.RecipientJson;
import _VisualDVM.ComponentsServer.BugReport.Json.RecipientsJson;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingsJson;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.Component.ComponentType;
import _VisualDVM.ComponentsServer.Recipient.Recipient;
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
import _VisualDVM.Constants;
import _VisualDVM.Global;
@@ -25,11 +23,12 @@ public class BugReport extends rDBObject {
public long visualiser_version = -1;
public long sapfor_version = -1;
public String comment = "";
@Description("DEFAULT ''")
@Description("IGNORE")
public String packedRecipientsJson = "";
@Description("IGNORE")
public String packedSettingsJson = ""; //todo вывести.
public Vector<BugReportSetting> settings=null;
public Vector<BugReportSetting> settings = null;
public Vector<BugReportRecipient> recipients = null;
public String executor = "";
@Description("DEFAULT ''")
public String executor_address = "";
@@ -71,7 +70,6 @@ public class BugReport extends rDBObject {
change_date = b.change_date;
description = b.description;
comment = b.comment;
packedRecipientsJson = b.packedRecipientsJson;
state = b.state;
percentage = b.percentage;
//-
@@ -80,8 +78,6 @@ public class BugReport extends rDBObject {
project_version = b.project_version;
visualiser_version = b.visualiser_version;
sapfor_version = b.sapfor_version;
// packedSettingsJson = b.packedSettingsJson;
//-
descriptionAdditionDraft = b.descriptionAdditionDraft;
commentAdditionDraft = b.commentAdditionDraft;
owner = b.owner;
@@ -157,20 +153,15 @@ public class BugReport extends rDBObject {
}
//--->
public void CheckRecipients() {
for (Recipient recipient : Global.componentsServer.db.recipients.Data.values())
recipient.Select(packedRecipientsJson.contains(recipient.email));
Global.componentsServer.db.recipients.getUI().SelectAll(false);
Vector<BugReportRecipient> recipients_ = state.equals(BugReportState.draft) ?
recipients : Global.componentsServer.db.getVectorByFK(this, BugReportRecipient.class);
if (recipients_!=null) {
for (BugReportRecipient bugReportRecipient : recipients_) {
if (Global.componentsServer.db.recipients.containsKey(bugReportRecipient.email))
Global.componentsServer.db.recipients.get(bugReportRecipient.email).Select(true);
}
public void saveRecipientsAsJson(Vector<Recipient> recipients) {
packedRecipientsJson = Utils_.gson.toJson(new RecipientsJson(recipients));
}
public Vector<String> getRecipients() {
Vector<String> res = new Vector<>();
if (packedRecipientsJson.isEmpty()) return res;
RecipientsJson recipients = Utils_.gson.fromJson(packedRecipientsJson, RecipientsJson.class);
for (RecipientJson recipientJson : recipients.array) {
res.add(recipientJson.address);
}
return res;
}
public VisualiserSettingsJson getSettingsJson() {
return packedSettingsJson.isEmpty() ? new VisualiserSettingsJson() : Utils_.gson.fromJson(packedSettingsJson, VisualiserSettingsJson.class);

View File

@@ -6,6 +6,7 @@ import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Visual.DataSetControlForm;
import _VisualDVM.ComponentsServer.BugReport.UI.BugReportsForm;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.DVMParameter.DVMParameter;
@@ -44,6 +45,7 @@ public class BugReportsDBTable extends DBTable<String, BugReport> {
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(BugReportSetting.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
res.put(BugReportRecipient.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
return res;
}
//-

View File

@@ -0,0 +1,25 @@
package _VisualDVM.ComponentsServer.BugReportRecipient;
import Common.Database.Objects.DBObject;
import Common.Database.Objects.iDBObject;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
public class BugReportRecipient extends iDBObject {
public String bugreport_id = "";
public String email ="";
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
BugReportRecipient src_= (BugReportRecipient) src;
bugreport_id = src_.bugreport_id;
email = src_.email;
}
public BugReportRecipient(){
}
public BugReportRecipient(BugReport bugReport, String email_in){
bugreport_id = bugReport.id;
email = email_in;
}
public BugReportRecipient(String email_in){
email = email_in;
}
}

View File

@@ -0,0 +1,11 @@
package _VisualDVM.ComponentsServer.BugReportRecipient;
import Common.Database.Tables.iDBTable;
public class BugReportRecipientsDBTable extends iDBTable<BugReportRecipient> {
public BugReportRecipientsDBTable() {
super(BugReportRecipient.class);
}
@Override
public boolean isEqual(BugReportRecipient o1, BugReportRecipient o2) {
return o1.bugreport_id.equals(o2.bugreport_id) && o1.email.equals(o2.email);
}
}

View File

@@ -1,21 +1,19 @@
package _VisualDVM.ComponentsServer;
import Common.Database.SQLITE.SQLiteDatabase;
import Common.Utils.Vector_;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReport.BugReportsDBTable;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingJson;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingsJson;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipientsDBTable;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSettingsDBTable;
import _VisualDVM.ComponentsServer.Recipient.RecipientsDataSet;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.ProjectData.SapforData.SapforProperties;
import java.nio.file.Paths;
import java.util.Vector;
public class BugReportsDatabase extends SQLiteDatabase {
public BugReportsDBTable bugReports;
public BugReportSettingsDBTable bugReportSettings;
public BugReportRecipientsDBTable bugReportRecipients;
public RecipientsDataSet recipients = new RecipientsDataSet();
public BugReportsDatabase() {
super(Paths.get(System.getProperty("user.dir"), "Data", "bug_reports.sqlite").toFile());
@@ -24,6 +22,7 @@ public class BugReportsDatabase extends SQLiteDatabase {
protected void initAllTables() throws Exception {
addTable(bugReports = new BugReportsDBTable());
addTable(bugReportSettings = new BugReportSettingsDBTable());
addTable(bugReportRecipients = new BugReportRecipientsDBTable());
}
@Override
public void Init() throws Exception {
@@ -50,7 +49,16 @@ public class BugReportsDatabase extends SQLiteDatabase {
recipients.ShowUI(); //todo временно.
super.ResetUI();
}
public void saveBugreportRecipients(BugReport bugReport) throws Exception {
if (bugReport.recipients != null) {
for (BugReportRecipient recipient : bugReport.recipients) {
recipient.bugreport_id = bugReport.id;
Insert(recipient);
}
}
}
public void Patch() throws Exception {
/*
Vector<BugReportSetting> settings = new Vector<>();
//--
for (BugReport bugReport : bugReports.Data.values()) {
@@ -79,5 +87,23 @@ public class BugReportsDatabase extends SQLiteDatabase {
for (BugReportSetting bugReportSetting : settings)
Insert(bugReportSetting);
Commit();
*/
//---
/*
Vector<BugReportRecipient> recipients = new Vector<>();
for (BugReport bugReport: bugReports.Data.values()){
RecipientsJson recipientsJson = Utils_.gson.fromJson(bugReport.packedRecipientsJson, RecipientsJson.class);
for (RecipientJson recipientJson: recipientsJson.array){
recipients.add(new BugReportRecipient(bugReport, recipientJson.address));
}
}
//-
BeginTransaction();
for (BugReportRecipient recipient: recipients){
Insert(recipient);
}
Commit();
*/
}
}

View File

@@ -5,6 +5,7 @@ import Common.Database.RepositoryRefuseException;
import Common.Utils.Utils_;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReport.Json.BugReportAdditionJson;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.Component.ComponentType;
import _VisualDVM.ComponentsServer.Component.Json.ComponentPublicationInfoJson;
@@ -18,6 +19,7 @@ import _VisualDVM.Passes.All.ZipFolderPass;
import _VisualDVM.ProjectData.LanguageName;
import _VisualDVM.Repository.EmailMessage;
import _VisualDVM.Repository.Server.RepositoryServer;
import _VisualDVM.TestingSystem.DVM.DVMConfigurationTest.DVMConfigurationTest;
import _VisualDVM.Utils;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
@@ -73,6 +75,20 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
db.Insert(setting);
}
}
if (bugReport.recipients!=null){
db.saveBugreportRecipients(bugReport);
}
}
}
@Override
protected void afterEditAction(DBObject object) throws Exception {
if (object instanceof BugReport){
BugReport bugReport = (BugReport) object;
if (bugReport.recipients!=null){
db.bugReportRecipients.ActualizeData(
db.getVectorByFK(bugReport, BugReportRecipient.class),
bugReport.recipients);
}
}
}
@Override
@@ -366,6 +382,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
@Override
public void StartAction() throws Exception {
super.StartAction();
// db.Patch();
db.Patch();
}
}

View File

@@ -1,19 +1,41 @@
package _VisualDVM.Passes.All;
import Common.Utils.Utils_;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReport.Json.RecipientsJson;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.ComponentsServer;
import _VisualDVM.ComponentsServer.Recipient.Recipient;
import _VisualDVM.Global;
public class SaveBugReportRecipients extends UpdateBugReportField {
import _VisualDVM.Passes.Server.EditServerObject;
import java.util.Date;
import java.util.Vector;
public class SaveBugReportRecipients extends EditServerObject<ComponentsServer, BugReport> {
public SaveBugReportRecipients() {
super(Global.componentsServer, BugReport.class);
}
@Override
public String getIconPath() {
return "/Common/icons/Save.png";
}
@Override
public String getButtonText() {
return "";
}
@Override
protected boolean canStart(Object... args) throws Exception {
return super.canStart("packedRecipientsJson",
Utils_.gson.toJson(new RecipientsJson(Global.componentsServer.db.recipients.getUI().getSelectedItems())));
if (server.db.bugReports.getUI().CheckCurrent(Log)){
target = server.db.bugReports.getUI().getCurrent();
target.recipients = new Vector<>();
for (Recipient recipient: server.db.recipients.getUI().getSelectedItems()){
target.recipients.add(new BugReportRecipient(recipient.email));
}
switch (target.state){
case draft:
break;
default:
for (BugReportRecipient recipient: target.recipients)
recipient.bugreport_id = target.id;
target.change_date = new Date().getTime();
return true;
}
}
return false;
}
}