рефакторинг публикации компонентов
This commit is contained in:
@@ -15,6 +15,7 @@ public class AppendBugReportField extends ClientPass<ComponentsServer, BugReport
|
||||
String oldValue;
|
||||
String addition;
|
||||
String newValue;
|
||||
BugReport actual;
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Append.png";
|
||||
@@ -23,15 +24,13 @@ public class AppendBugReportField extends ClientPass<ComponentsServer, BugReport
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
protected boolean canUpdate() {
|
||||
return target.canModify(Global.mainModule.getAccount(), Log);
|
||||
}
|
||||
@Override
|
||||
protected ComponentsServer getServer() {
|
||||
return Global.componentsServer;
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
actual = null;
|
||||
if (getServer().db.getTable(BugReport.class).getUI().CheckCurrent(Log)) {
|
||||
target = getServer().db.getTable(BugReport.class).getUI().getCurrent();
|
||||
if (!target.CheckNotDraft(Log))
|
||||
@@ -45,13 +44,18 @@ public class AppendBugReportField extends ClientPass<ComponentsServer, BugReport
|
||||
addition = Utils_.Brackets(Utils_.print_date(
|
||||
new Date())) + " " + Global.mainModule.getAccount().name
|
||||
+ " : " + addition;
|
||||
return canUpdate();
|
||||
if (canUpdate() && (SendRequest(ServerCode.AppendBugReportTextField, "", new BugReportAdditionJson(target, fieldName, addition)))) {
|
||||
actual = (BugReport) request.target;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected boolean canUpdate() {
|
||||
return target.canModify(Global.mainModule.getAccount(), Log);
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
BugReport actual = (BugReport) getServer().ClientRequest(ServerCode.AppendBugReportTextField, "", new BugReportAdditionJson(target, fieldName, addition));
|
||||
target.SynchronizeFields(actual);
|
||||
Global.componentsServer.db.Update(target);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ import _VisualDVM.Repository.Server.ComponentsServer;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
|
||||
import java.util.Vector;
|
||||
public class GetComponentsActualVersions extends ClientPass<ComponentsServer,Object> {
|
||||
public class GetComponentsActualVersions extends ClientPass<ComponentsServer, Object> {
|
||||
Vector<ComponentVersionsInfoJson> versions;
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Components.png";
|
||||
@@ -18,12 +19,20 @@ public class GetComponentsActualVersions extends ClientPass<ComponentsServer,Obj
|
||||
return Global.componentsServer;
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
versions = null;
|
||||
Vector<String> types = new Vector<>();
|
||||
for (ComponentType key: Global.components.Data.keySet())
|
||||
for (ComponentType key : Global.components.Data.keySet())
|
||||
types.add(key.toString());
|
||||
Vector<ComponentVersionsInfoJson> versions = (Vector<ComponentVersionsInfoJson>) getServer().ClientRequest(ServerCode.GetComponentsVersionsInfo, "", types);
|
||||
for (ComponentVersionsInfoJson info: versions){
|
||||
if (SendRequest(ServerCode.GetComponentsVersionsInfo, "", types)) {
|
||||
versions = (Vector<ComponentVersionsInfoJson>) request.target;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
for (ComponentVersionsInfoJson info : versions) {
|
||||
Global.components.get(info.componentType).unpackActualVersion(info.actual_version);
|
||||
Global.components.get(info.componentType).unpackMinimalVersion(info.minimal_version);
|
||||
}
|
||||
|
||||
@@ -3,17 +3,18 @@ import Common.Utils.Utils_;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
import _VisualDVM.Passes.Server.ComponentsRepositoryPass;
|
||||
import _VisualDVM.Passes.Server.ClientPass;
|
||||
import _VisualDVM.Repository.Component.Component;
|
||||
import _VisualDVM.Repository.Component.ComponentType;
|
||||
import _VisualDVM.Repository.Component.Json.ComponentPublicationInfoJson;
|
||||
import _VisualDVM.Repository.Component.UI.PublishForm;
|
||||
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 java.util.Date;
|
||||
public class PublishComponent extends ComponentsRepositoryPass<Component> {
|
||||
public class PublishComponent extends ClientPass<ComponentsServer, Component> {
|
||||
String version_mail_header = "";
|
||||
String version_text = "";
|
||||
PublishForm f = new PublishForm();
|
||||
@@ -22,8 +23,8 @@ public class PublishComponent extends ComponentsRepositoryPass<Component> {
|
||||
return "/Common/icons/Publish.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
protected ComponentsServer getServer() {
|
||||
return Global.componentsServer;
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
@@ -41,7 +42,6 @@ public class PublishComponent extends ComponentsRepositoryPass<Component> {
|
||||
;
|
||||
if (Global.components.getUI().CheckCurrent(Log)) {
|
||||
target = Global.components.getUI().getCurrent();
|
||||
target.needs_update_minimal_version = false;
|
||||
f.fields.cbUpdateMinimalVersion.setSelected(false);
|
||||
f.fields.lMinimalVersion.setText(String.valueOf(target.minimal_version));
|
||||
f.fields.lPublishingVersion.setText(String.valueOf(target.version));
|
||||
@@ -56,42 +56,27 @@ public class PublishComponent extends ComponentsRepositoryPass<Component> {
|
||||
f.fields.cbAssemblyOnServer.setSelected(false);
|
||||
}
|
||||
if (f.ShowDialog(getDescription())) {
|
||||
target.needs_update_minimal_version = f.fields.cbUpdateMinimalVersion.isSelected();
|
||||
return true;
|
||||
String change_description = (f.Result == null) ? "не указаны" : f.Result;
|
||||
String change_record_header = String.join(" ",
|
||||
Utils_.Brackets(Utils_.print_date(new Date())) + ":",
|
||||
Global.mainModule.getAccount().name + Utils_.RBrackets(Global.mainModule.getAccount().email),
|
||||
"публикует версию", Utils_.DQuotes(target.version)
|
||||
);
|
||||
String change_record = String.join("\n", change_record_header, "Изменения:",
|
||||
change_description,
|
||||
RepositoryServer.separator, ""
|
||||
);
|
||||
//--
|
||||
ComponentPublicationInfoJson info=new ComponentPublicationInfoJson(target);
|
||||
info.changeRecord = change_record;
|
||||
info.needsUpdateMinimalVersion = f.fields.cbUpdateMinimalVersion.isSelected();
|
||||
//--
|
||||
return SendRequest(ServerCode.UpdateComponent, "",info);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
String change_description = (f.Result == null) ? "не указаны" : f.Result;
|
||||
String change_record_header = String.join(" ",
|
||||
Utils_.Brackets(Utils_.print_date(new Date())) + ":",
|
||||
Global.mainModule.getAccount().name + Utils_.RBrackets(Global.mainModule.getAccount().email),
|
||||
"публикует версию", Utils_.DQuotes(target.version)
|
||||
);
|
||||
String change_record = String.join("\n", change_record_header, "Изменения:",
|
||||
change_description,
|
||||
RepositoryServer.separator, ""
|
||||
);
|
||||
String packed =
|
||||
target.getComponentType().toString() + "\n" +
|
||||
target.getFileName() + "\n" +
|
||||
target.getVersionText() + "\n" +
|
||||
change_record;
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.PublishComponent,
|
||||
packed, Utils_.fileToBytes(target.getFile())
|
||||
));
|
||||
if (target.needs_update_minimal_version) {
|
||||
packed = target.getComponentType().toString() + "\n" +
|
||||
target.getVersionText() + "\n";
|
||||
//--
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.UpdateComponentMinimalVersion,
|
||||
packed, Utils_.fileToBytes(target.getFile())
|
||||
));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
target.actual_version = target.version;
|
||||
target.CheckIfNeedsUpdateOrPublish();
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package _VisualDVM.Passes.Server;
|
||||
import Common.Passes.Pass;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Repository.RepositoryServer;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
||||
|
||||
import java.io.Serializable;
|
||||
public abstract class ClientPass <S extends RepositoryServer,T> extends Pass<T> {
|
||||
protected RepositoryPass request;
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
@@ -11,4 +17,30 @@ public abstract class ClientPass <S extends RepositoryServer,T> extends Pass<T>
|
||||
return "";
|
||||
}
|
||||
protected abstract S getServer();
|
||||
protected boolean SendRequest(ServerCode code_in, String arg_in, Serializable object_in, int delay){
|
||||
request = null;
|
||||
request = new RepositoryPass(getServer()) {
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return code_in.getDescription();
|
||||
}
|
||||
@Override
|
||||
protected int getTimeout() {
|
||||
return delay;
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(code_in, arg_in,object_in));
|
||||
target = server_response.object;
|
||||
}
|
||||
@Override
|
||||
protected boolean validate() {
|
||||
return Log.isEmpty();
|
||||
}
|
||||
};
|
||||
return request.Do();
|
||||
}
|
||||
protected boolean SendRequest(ServerCode code_in,String arg_in, Serializable object_in){
|
||||
return SendRequest(code_in,arg_in, object_in, Global.properties.SocketTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user