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

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>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment=""> <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> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -4,12 +4,10 @@ import Common.Database.Objects.rDBObject;
import Common.Utils.TextLog; import Common.Utils.TextLog;
import Common.Utils.Utils_; import Common.Utils.Utils_;
import Common.Utils.Vector_; 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.BugReport.Json.VisualiserSettingsJson;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting; import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.Component.ComponentType; import _VisualDVM.ComponentsServer.Component.ComponentType;
import _VisualDVM.ComponentsServer.Recipient.Recipient;
import _VisualDVM.ComponentsServer.UserAccount.UserAccount; import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
import _VisualDVM.Constants; import _VisualDVM.Constants;
import _VisualDVM.Global; import _VisualDVM.Global;
@@ -25,11 +23,12 @@ public class BugReport extends rDBObject {
public long visualiser_version = -1; public long visualiser_version = -1;
public long sapfor_version = -1; public long sapfor_version = -1;
public String comment = ""; public String comment = "";
@Description("DEFAULT ''") @Description("IGNORE")
public String packedRecipientsJson = ""; public String packedRecipientsJson = "";
@Description("IGNORE") @Description("IGNORE")
public String packedSettingsJson = ""; //todo вывести. public String packedSettingsJson = ""; //todo вывести.
public Vector<BugReportSetting> settings=null; public Vector<BugReportSetting> settings = null;
public Vector<BugReportRecipient> recipients = null;
public String executor = ""; public String executor = "";
@Description("DEFAULT ''") @Description("DEFAULT ''")
public String executor_address = ""; public String executor_address = "";
@@ -71,7 +70,6 @@ public class BugReport extends rDBObject {
change_date = b.change_date; change_date = b.change_date;
description = b.description; description = b.description;
comment = b.comment; comment = b.comment;
packedRecipientsJson = b.packedRecipientsJson;
state = b.state; state = b.state;
percentage = b.percentage; percentage = b.percentage;
//- //-
@@ -80,8 +78,6 @@ public class BugReport extends rDBObject {
project_version = b.project_version; project_version = b.project_version;
visualiser_version = b.visualiser_version; visualiser_version = b.visualiser_version;
sapfor_version = b.sapfor_version; sapfor_version = b.sapfor_version;
// packedSettingsJson = b.packedSettingsJson;
//-
descriptionAdditionDraft = b.descriptionAdditionDraft; descriptionAdditionDraft = b.descriptionAdditionDraft;
commentAdditionDraft = b.commentAdditionDraft; commentAdditionDraft = b.commentAdditionDraft;
owner = b.owner; owner = b.owner;
@@ -157,20 +153,15 @@ public class BugReport extends rDBObject {
} }
//---> //--->
public void CheckRecipients() { public void CheckRecipients() {
for (Recipient recipient : Global.componentsServer.db.recipients.Data.values()) Global.componentsServer.db.recipients.getUI().SelectAll(false);
recipient.Select(packedRecipientsJson.contains(recipient.email)); Vector<BugReportRecipient> recipients_ = state.equals(BugReportState.draft) ?
} recipients : Global.componentsServer.db.getVectorByFK(this, BugReportRecipient.class);
public void saveRecipientsAsJson(Vector<Recipient> recipients) { if (recipients_!=null) {
packedRecipientsJson = Utils_.gson.toJson(new RecipientsJson(recipients)); for (BugReportRecipient bugReportRecipient : recipients_) {
} if (Global.componentsServer.db.recipients.containsKey(bugReportRecipient.email))
public Vector<String> getRecipients() { Global.componentsServer.db.recipients.get(bugReportRecipient.email).Select(true);
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() { public VisualiserSettingsJson getSettingsJson() {
return packedSettingsJson.isEmpty() ? new VisualiserSettingsJson() : Utils_.gson.fromJson(packedSettingsJson, VisualiserSettingsJson.class); 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.Database.Tables.FKDataBehaviour;
import Common.Visual.DataSetControlForm; import Common.Visual.DataSetControlForm;
import _VisualDVM.ComponentsServer.BugReport.UI.BugReportsForm; import _VisualDVM.ComponentsServer.BugReport.UI.BugReportsForm;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting; import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.GlobalData.Compiler.Compiler; import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.DVMParameter.DVMParameter; import _VisualDVM.GlobalData.DVMParameter.DVMParameter;
@@ -44,6 +45,7 @@ public class BugReportsDBTable extends DBTable<String, BugReport> {
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() { public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>(); LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(BugReportSetting.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE)); res.put(BugReportSetting.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
res.put(BugReportRecipient.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
return res; 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; package _VisualDVM.ComponentsServer;
import Common.Database.SQLITE.SQLiteDatabase; import Common.Database.SQLITE.SQLiteDatabase;
import Common.Utils.Vector_;
import _VisualDVM.ComponentsServer.BugReport.BugReport; import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReport.BugReportsDBTable; import _VisualDVM.ComponentsServer.BugReport.BugReportsDBTable;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingJson; import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingsJson; import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipientsDBTable;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSettingsDBTable; import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSettingsDBTable;
import _VisualDVM.ComponentsServer.Recipient.RecipientsDataSet; import _VisualDVM.ComponentsServer.Recipient.RecipientsDataSet;
import _VisualDVM.Passes.PassCode; import _VisualDVM.Passes.PassCode;
import _VisualDVM.ProjectData.SapforData.SapforProperties;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Vector; import java.util.Vector;
public class BugReportsDatabase extends SQLiteDatabase { public class BugReportsDatabase extends SQLiteDatabase {
public BugReportsDBTable bugReports; public BugReportsDBTable bugReports;
public BugReportSettingsDBTable bugReportSettings; public BugReportSettingsDBTable bugReportSettings;
public BugReportRecipientsDBTable bugReportRecipients;
public RecipientsDataSet recipients = new RecipientsDataSet(); public RecipientsDataSet recipients = new RecipientsDataSet();
public BugReportsDatabase() { public BugReportsDatabase() {
super(Paths.get(System.getProperty("user.dir"), "Data", "bug_reports.sqlite").toFile()); 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 { protected void initAllTables() throws Exception {
addTable(bugReports = new BugReportsDBTable()); addTable(bugReports = new BugReportsDBTable());
addTable(bugReportSettings = new BugReportSettingsDBTable()); addTable(bugReportSettings = new BugReportSettingsDBTable());
addTable(bugReportRecipients = new BugReportRecipientsDBTable());
} }
@Override @Override
public void Init() throws Exception { public void Init() throws Exception {
@@ -50,7 +49,16 @@ public class BugReportsDatabase extends SQLiteDatabase {
recipients.ShowUI(); //todo временно. recipients.ShowUI(); //todo временно.
super.ResetUI(); 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 { public void Patch() throws Exception {
/*
Vector<BugReportSetting> settings = new Vector<>(); Vector<BugReportSetting> settings = new Vector<>();
//-- //--
for (BugReport bugReport : bugReports.Data.values()) { for (BugReport bugReport : bugReports.Data.values()) {
@@ -79,5 +87,23 @@ public class BugReportsDatabase extends SQLiteDatabase {
for (BugReportSetting bugReportSetting : settings) for (BugReportSetting bugReportSetting : settings)
Insert(bugReportSetting); Insert(bugReportSetting);
Commit(); 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 Common.Utils.Utils_;
import _VisualDVM.ComponentsServer.BugReport.BugReport; import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReport.Json.BugReportAdditionJson; import _VisualDVM.ComponentsServer.BugReport.Json.BugReportAdditionJson;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting; import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.Component.ComponentType; import _VisualDVM.ComponentsServer.Component.ComponentType;
import _VisualDVM.ComponentsServer.Component.Json.ComponentPublicationInfoJson; import _VisualDVM.ComponentsServer.Component.Json.ComponentPublicationInfoJson;
@@ -18,6 +19,7 @@ import _VisualDVM.Passes.All.ZipFolderPass;
import _VisualDVM.ProjectData.LanguageName; import _VisualDVM.ProjectData.LanguageName;
import _VisualDVM.Repository.EmailMessage; import _VisualDVM.Repository.EmailMessage;
import _VisualDVM.Repository.Server.RepositoryServer; import _VisualDVM.Repository.Server.RepositoryServer;
import _VisualDVM.TestingSystem.DVM.DVMConfigurationTest.DVMConfigurationTest;
import _VisualDVM.Utils; import _VisualDVM.Utils;
import javafx.util.Pair; import javafx.util.Pair;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@@ -73,6 +75,20 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
db.Insert(setting); 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 @Override
@@ -366,6 +382,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
@Override @Override
public void StartAction() throws Exception { public void StartAction() throws Exception {
super.StartAction(); super.StartAction();
// db.Patch(); db.Patch();
} }
} }

View File

@@ -1,19 +1,41 @@
package _VisualDVM.Passes.All; package _VisualDVM.Passes.All;
import Common.Utils.Utils_; import Common.Utils.Utils_;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReport.Json.RecipientsJson; import _VisualDVM.ComponentsServer.BugReport.Json.RecipientsJson;
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
import _VisualDVM.ComponentsServer.ComponentsServer;
import _VisualDVM.ComponentsServer.Recipient.Recipient;
import _VisualDVM.Global; 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 @Override
public String getIconPath() { public String getIconPath() {
return "/Common/icons/Save.png"; return "/Common/icons/Save.png";
} }
@Override @Override
public String getButtonText() {
return "";
}
@Override
protected boolean canStart(Object... args) throws Exception { protected boolean canStart(Object... args) throws Exception {
return super.canStart("packedRecipientsJson", if (server.db.bugReports.getUI().CheckCurrent(Log)){
Utils_.gson.toJson(new RecipientsJson(Global.componentsServer.db.recipients.getUI().getSelectedItems()))); 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;
} }
} }