рефакторинг дополнения полей багов

This commit is contained in:
2025-02-03 19:53:48 +03:00
parent e0f441d82a
commit 46f44f48b7
6 changed files with 56 additions and 48 deletions

View File

@@ -1,23 +1,16 @@
package _VisualDVM.Passes.All;
import Common.Database.Objects.DBObject;
import Common.Passes.Pass;
import Common.Properties;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Passes.Server.ClientPass;
import _VisualDVM.Repository.BugReport.BugReport;
import _VisualDVM.Repository.BugReport.Json.BugReportAdditionJson;
import _VisualDVM.Repository.EmailMessage;
import _VisualDVM.Repository.RepositoryServer;
import _VisualDVM.Repository.Server.ComponentsServer;
import _VisualDVM.Repository.Server.ServerCode;
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
import com.google.gson.JsonObject;
import javafx.util.Pair;
import java.io.File;
import java.util.Date;
public class AppendBugReportField extends ClientPass<ComponentsServer,BugReport> {
public class AppendBugReportField extends ClientPass<ComponentsServer, BugReport> {
String fieldName;
String oldValue;
String addition;
@@ -35,7 +28,7 @@ public class AppendBugReportField extends ClientPass<ComponentsServer,BugReport>
return "";
}
protected boolean canUpdate() {
return target.canModify(Global.mainModule.getAccount(),Log);
return target.canModify(Global.mainModule.getAccount(), Log);
}
@Override
protected ComponentsServer getServer() {
@@ -53,26 +46,19 @@ public class AppendBugReportField extends ClientPass<ComponentsServer,BugReport>
Log.Writeln_("Дополнение не может быть пустым.");
return false;
}
addition = Utils_.Brackets(Utils_.print_date(
new Date())) + " " + Global.mainModule.getAccount().name
+ " : " + addition;
return canUpdate();
}
return false;
}
@Override
protected void body() throws Exception {
//todo возможно оформить это единственной командой на сервере.
BugReport actual= getServer().getActual(target, BugReport.class);
BugReport actual =
(BugReport) getServer().ClientRequest(ServerCode.AppendBugReportTextField, "", new BugReportAdditionJson(target, fieldName, addition));
target.SynchronizeFields(actual);
oldValue = (String) BugReport.class.getField(fieldName).get(target);
newValue = oldValue + "\n" + Utils_.Brackets(Utils_.print_date(
new Date())) + " " + Global.mainModule.getAccount().name
+ " : " + addition;
//2. дописываем нужное поле.
BugReport.class.getField(fieldName).set(target, newValue);
//обновляем дату.
target.change_date = new Date().getTime();
Global.componentsServer.db.Update(target);
//3. отправляем на сервер
getServer().ClientRequest(ServerCode.UpdateBugReportField, fieldName, target);
}
@Override
protected void showFinish() throws Exception {
@@ -96,7 +82,7 @@ public class AppendBugReportField extends ClientPass<ComponentsServer,BugReport>
message_text = target.comment;
break;
}
EmailMessage message= new EmailMessage(
EmailMessage message = new EmailMessage(
message_header + " " + Utils_.Brackets(Global.mainModule.getAccount().name),
message_text
);