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

This commit is contained in:
2024-12-01 20:52:27 +03:00
parent 216b595450
commit dd674dce48
10 changed files with 152 additions and 26 deletions

10
.idea/workspace.xml generated
View File

@@ -7,10 +7,16 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/Common/Utils/TimerTask.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/server_debug_properties/properties" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/Json/RecipientJson.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/Json/RecipientsJson.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/testing_debug_properties/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/UserConnection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/UserConnection.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/PublishBugReport.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/PublishBugReport.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" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/BugReport.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/BugReport/BugReport.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/RepositoryServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/RepositoryServer.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -3,7 +3,7 @@
"ServerAddress": "alex-freenas.ddns.net",
"ServerUserName": "testuser",
"ServerUserSHHPort": 2000,
"ComponentsServerPort": 7995,
"ComponentsServerPort": 7996,
"TestingServerPort": 7998,
"SocketTimeout": 5000,
"OldServer": false,

View File

@@ -0,0 +1,43 @@
{
"Mode": "Normal",
"ServerAddress": "alex-freenas.ddns.net",
"ServerUserName": "testuser",
"ServerUserSHHPort": 2000,
"ComponentsServerPort": 7996,
"TestingServerPort": 7998,
"SocketTimeout": 5000,
"OldServer": false,
"SMTPHost": "smtp.mail.ru",
"SMTPPort": 465,
"MailSocketPort": 465,
"collapseCredentials": false,
"collapseFileGraphs": false,
"collapseFileMessages": false,
"collapseProjectTrees": false,
"BackupWorkspace": "_sapfor_x64_backups",
"BackupHour": 5,
"BackupMinute": 0,
"EmailAdminsOnStart": false,
"AutoUpdateSearch": true,
"ConfirmPassesStart": true,
"ShowPassesDone": true,
"FocusPassesResult": true,
"ProjectDBName": "new_project_base.sqlite",
"BugReportsDBName": "bug_reports.sqlite",
"TestsDBName": "tests.sqlite",
"ComponentsWindowWidth": 924,
"ComponentsWindowHeight": 250,
"VisualiserPath": "C:\\Users\\misha\\Downloads",
"Sapfor_FPath": "E:\\_sapfor_x64\\Components\\Sapfor_F",
"Visualizer_2Path": "C:\\Users\\misha\\Documents",
"InstructionPath": "",
"PerformanceAnalyzerPath": "",
"ComponentsBackUpsCount": 10,
"AutoCheckTesting": true,
"CheckTestingIntervalSeconds": 10,
"EmailOnTestingProgress": true,
"eraseTestingWorkspaces": true,
"lastMachineId": 13,
"lastUserId": 34,
"lastCompilerId": 52
}

View File

@@ -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;

View File

@@ -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())));
}
}

View File

@@ -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;
}
}

View 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() {
}
}

View 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));
}
}

View File

@@ -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;

View File

@@ -0,0 +1,37 @@
{
"Mode": "Normal",
"ServerAddress": "alex-freenas.ddns.net",
"ServerUserName": "testuser",
"ServerUserSHHPort": 23,
"ComponentsServerPort": 7995,
"TestingServerPort": 7996,
"SocketTimeout": 5000,
"OldServer": false,
"SMTPHost": "smtp.mail.ru",
"SMTPPort": 465,
"MailSocketPort": 465,
"BackupWorkspace": "_sapfor_x64_backups",
"BackupHour": 5,
"BackupMinute": 0,
"EmailAdminsOnStart": false,
"AutoUpdateSearch": false,
"ConfirmPassesStart": true,
"ShowPassesDone": true,
"FocusPassesResult": true,
"GlobalDBName": "db7.sqlite",
"ProjectDBName": "new_project_base.sqlite",
"BugReportsDBName": "bug_reports.sqlite",
"TestsDBName": "tests.sqlite",
"ComponentsWindowWidth": 843,
"ComponentsWindowHeight": 250,
"VisualiserPath": "C:\\Users\\misha\\Downloads",
"Sapfor_FPath": "E:\\_sapfor_x64\\Components\\Sapfor_F",
"Visualizer_2Path": "C:\\Users\\misha\\Documents",
"InstructionPath": "",
"PerformanceAnalyzerPath": "",
"ComponentsBackUpsCount": 10,
"TestingKernels": 28,
"AutoCheckTesting": false,
"CheckTestingIntervalSeconds": 10,
"EmailOnTestingProgress": false
}