рефакторинг. запаковка адресатов багов в json
This commit is contained in:
@@ -41,7 +41,8 @@ public class PublishBugReport extends Pass<BugReport> {
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
target.targets = BugReport.getPackedTargets();
|
||||
// target.targets = BugReport.getPackedTargets();
|
||||
target.saveRecipientsAsJson(Global.componentsServer.db.subscribers.getUI().getSelectedItems());
|
||||
target.change_date = new Date().getTime();
|
||||
Global.componentsServer.db.Update(target);
|
||||
target.state = BugReportState.active;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package _VisualDVM.Passes.All;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Repository.BugReport.BugReport;
|
||||
import _VisualDVM.Repository.BugReport.Json.RecipientsJson;
|
||||
public class SaveBugReportRecipients extends UpdateBugReportField {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
@@ -11,6 +14,6 @@ public class SaveBugReportRecipients extends UpdateBugReportField {
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
return super.canStart("targets", BugReport.getPackedTargets());
|
||||
return super.canStart("packedRecipientsJson", Utils_.gson.toJson(new RecipientsJson(Global.componentsServer.db.subscribers.getUI().getSelectedItems())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.rDBObject;
|
||||
import Common.Utils.TextLog;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Repository.BugReport.Json.RecipientJson;
|
||||
import _VisualDVM.Repository.BugReport.Json.RecipientsJson;
|
||||
import _VisualDVM.Repository.Component.ComponentType;
|
||||
import _VisualDVM.Repository.Component.ComponentsSet;
|
||||
import _VisualDVM.Repository.RepositoryServer;
|
||||
@@ -12,6 +13,7 @@ import _VisualDVM.Repository.Subscribes.Subscriber;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
@@ -22,7 +24,8 @@ public class BugReport extends rDBObject {
|
||||
public long sapfor_version = -1;
|
||||
public String sapfor_settings = "";
|
||||
public String comment = "";
|
||||
public String targets = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String packedRecipientsJson = "";
|
||||
public String executor = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String executor_address = "";
|
||||
@@ -55,12 +58,6 @@ public class BugReport extends rDBObject {
|
||||
state = BugReportState.draft;
|
||||
owner = Global.mainModule.getProject().Home;
|
||||
}
|
||||
public static String getPackedTargets() {
|
||||
Vector<String> selected = new Vector<>();
|
||||
for (Subscriber subscriber : Global.componentsServer.db.subscribers.Data.values())
|
||||
if (subscriber.isSelected()) selected.add(subscriber.address);
|
||||
return String.join("\n", selected);
|
||||
}
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
@@ -68,7 +65,7 @@ public class BugReport extends rDBObject {
|
||||
change_date = b.change_date;
|
||||
description = b.description;
|
||||
comment = b.comment;
|
||||
targets = b.targets;
|
||||
packedRecipientsJson = b.packedRecipientsJson;
|
||||
state = b.state;
|
||||
percentage = b.percentage;
|
||||
//-
|
||||
@@ -84,14 +81,6 @@ public class BugReport extends rDBObject {
|
||||
owner = b.owner;
|
||||
}
|
||||
//--
|
||||
public Vector<String> getRecipients() {
|
||||
Vector<String> res = new Vector<>();
|
||||
String[] data = targets.split("\n");
|
||||
for (String a : data)
|
||||
if (a.length() > 0)
|
||||
res.add(a);
|
||||
return res;
|
||||
}
|
||||
public File getArchiveFile() {
|
||||
return Paths.get(System.getProperty("user.dir"), "Bugs", id + ".zip").toFile();
|
||||
}
|
||||
@@ -101,10 +90,7 @@ public class BugReport extends rDBObject {
|
||||
return (data.length > 0) ? data[0] : "";
|
||||
} else return "";
|
||||
}
|
||||
public void CheckSubscribers() {
|
||||
for (Subscriber subscriber : Global.componentsServer.db.subscribers.Data.values())
|
||||
subscriber.Select(targets.contains(subscriber.address));
|
||||
}
|
||||
|
||||
public boolean CheckNotDraft(TextLog log) {
|
||||
if (state.equals(BugReportState.draft)) {
|
||||
log.Writeln_("Отчёт об ошибке является черновиком");
|
||||
@@ -157,4 +143,21 @@ public class BugReport extends rDBObject {
|
||||
public boolean isNoneProject() {
|
||||
return project_version.isEmpty();
|
||||
}
|
||||
//--->
|
||||
public void CheckSubscribers() {
|
||||
for (Subscriber subscriber : Global.componentsServer.db.subscribers.Data.values())
|
||||
subscriber.Select(packedRecipientsJson.contains(subscriber.address));
|
||||
}
|
||||
public void saveRecipientsAsJson(Vector<Subscriber> subscribers) {
|
||||
packedRecipientsJson = Utils_.gson.toJson(new RecipientsJson(subscribers));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
12
src/_VisualDVM/Repository/BugReport/Json/RecipientJson.java
Normal file
12
src/_VisualDVM/Repository/BugReport/Json/RecipientJson.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package _VisualDVM.Repository.BugReport.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
|
||||
import com.google.gson.annotations.Expose;
|
||||
public class RecipientJson {
|
||||
@Expose
|
||||
public String address;
|
||||
public RecipientJson(String addres_in) {
|
||||
address= addres_in;
|
||||
}
|
||||
public RecipientJson() {
|
||||
}
|
||||
}
|
||||
20
src/_VisualDVM/Repository/BugReport/Json/RecipientsJson.java
Normal file
20
src/_VisualDVM/Repository/BugReport/Json/RecipientsJson.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package _VisualDVM.Repository.BugReport.Json;
|
||||
import _VisualDVM.Repository.Subscribes.Subscriber;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Json.ConfigurationJson;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class RecipientsJson {
|
||||
@Expose
|
||||
public List<RecipientJson> array = new Vector<>();
|
||||
public RecipientsJson() {
|
||||
}
|
||||
//при создании пакета.
|
||||
public RecipientsJson(Vector<? extends Subscriber> subscribers) {
|
||||
array = new Vector<>();
|
||||
for (Subscriber subscriber : subscribers)
|
||||
array.add(new RecipientJson(subscriber.address));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import Common.Utils.InterruptThread;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Repository.BugReport.BugReport;
|
||||
import _VisualDVM.Repository.Server.DiagnosticSignalHandler;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
||||
|
||||
Reference in New Issue
Block a user