2025-02-18 16:21:20 +03:00
|
|
|
|
package _VisualDVM.ComponentsServer.BugReport;
|
2024-10-07 00:58:29 +03:00
|
|
|
|
import Common.Database.Objects.DBObject;
|
|
|
|
|
|
import Common.Database.Objects.rDBObject;
|
2024-10-22 13:36:57 +03:00
|
|
|
|
import Common.Utils.TextLog;
|
|
|
|
|
|
import Common.Utils.Utils_;
|
2025-01-16 19:04:46 +03:00
|
|
|
|
import Common.Utils.Vector_;
|
2025-02-18 16:21:20 +03:00
|
|
|
|
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingsJson;
|
2025-03-27 15:12:09 +03:00
|
|
|
|
import _VisualDVM.ComponentsServer.BugReportRecipient.BugReportRecipient;
|
2025-03-27 12:45:55 +03:00
|
|
|
|
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
|
2025-02-18 16:21:20 +03:00
|
|
|
|
import _VisualDVM.ComponentsServer.Component.ComponentType;
|
2025-02-18 20:14:14 +03:00
|
|
|
|
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
2025-02-13 20:27:01 +03:00
|
|
|
|
import _VisualDVM.Constants;
|
2024-10-07 00:58:29 +03:00
|
|
|
|
import _VisualDVM.Global;
|
2025-01-16 19:04:46 +03:00
|
|
|
|
import _VisualDVM.ProjectData.SapforData.SapforProperties;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import com.sun.org.glassfish.gmbal.Description;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
2024-10-22 13:36:57 +03:00
|
|
|
|
import java.nio.file.Paths;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import java.util.Date;
|
2024-10-22 13:36:57 +03:00
|
|
|
|
import java.util.Vector;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
public class BugReport extends rDBObject {
|
|
|
|
|
|
public String project_version = "";
|
|
|
|
|
|
public long visualiser_version = -1;
|
|
|
|
|
|
public long sapfor_version = -1;
|
|
|
|
|
|
public String comment = "";
|
2025-03-27 15:12:09 +03:00
|
|
|
|
@Description("IGNORE")
|
2024-12-01 20:52:27 +03:00
|
|
|
|
public String packedRecipientsJson = "";
|
2025-03-27 12:45:55 +03:00
|
|
|
|
@Description("IGNORE")
|
|
|
|
|
|
public String packedSettingsJson = ""; //todo вывести.
|
2025-03-27 15:12:09 +03:00
|
|
|
|
public Vector<BugReportSetting> settings = null;
|
|
|
|
|
|
public Vector<BugReportRecipient> recipients = null;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
public String executor = "";
|
|
|
|
|
|
@Description("DEFAULT ''")
|
|
|
|
|
|
public String executor_address = "";
|
|
|
|
|
|
public BugReportState state;
|
|
|
|
|
|
public int percentage = 0;
|
|
|
|
|
|
//-
|
|
|
|
|
|
@Description("IGNORE")
|
|
|
|
|
|
public String descriptionAdditionDraft = "";
|
|
|
|
|
|
@Description("IGNORE")
|
|
|
|
|
|
public String commentAdditionDraft = "";
|
|
|
|
|
|
@Description("IGNORE")
|
|
|
|
|
|
public File owner = null;
|
2025-02-03 23:50:09 +03:00
|
|
|
|
@Description("IGNORE")
|
|
|
|
|
|
public byte[] packed_archive = null;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
public BugReport() {
|
|
|
|
|
|
}
|
2024-10-14 15:19:13 +03:00
|
|
|
|
public BugReport(BugReport src) {
|
|
|
|
|
|
this.SynchronizeFields(src);
|
|
|
|
|
|
}
|
|
|
|
|
|
public BugReport(String sender_name_in, String sender_address_in, String description_in, String version_in) {
|
|
|
|
|
|
genName();
|
|
|
|
|
|
sender_name = sender_name_in;
|
|
|
|
|
|
sender_address = sender_address_in;
|
|
|
|
|
|
project_version = version_in;
|
2025-01-29 15:20:24 +03:00
|
|
|
|
visualiser_version = Global.visualiser.version;
|
2024-10-22 20:16:57 +03:00
|
|
|
|
sapfor_version = Global.components.get(ComponentType.Sapfor_F).version;
|
2025-03-27 12:45:55 +03:00
|
|
|
|
settings = Global.mainModule.getProject().sapforProperties.toBugReportSettings();
|
2024-10-14 15:19:13 +03:00
|
|
|
|
percentage = 0;
|
|
|
|
|
|
description = description_in;
|
|
|
|
|
|
date = new Date().getTime();
|
|
|
|
|
|
change_date = new Date().getTime();
|
|
|
|
|
|
state = BugReportState.draft;
|
|
|
|
|
|
owner = Global.mainModule.getProject().Home;
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
public void SynchronizeFields(DBObject src) {
|
|
|
|
|
|
super.SynchronizeFields(src);
|
|
|
|
|
|
BugReport b = (BugReport) src;
|
|
|
|
|
|
change_date = b.change_date;
|
|
|
|
|
|
description = b.description;
|
|
|
|
|
|
comment = b.comment;
|
|
|
|
|
|
state = b.state;
|
|
|
|
|
|
percentage = b.percentage;
|
|
|
|
|
|
//-
|
|
|
|
|
|
executor = b.executor;
|
|
|
|
|
|
executor_address = b.executor_address;
|
|
|
|
|
|
project_version = b.project_version;
|
|
|
|
|
|
visualiser_version = b.visualiser_version;
|
|
|
|
|
|
sapfor_version = b.sapfor_version;
|
|
|
|
|
|
descriptionAdditionDraft = b.descriptionAdditionDraft;
|
|
|
|
|
|
commentAdditionDraft = b.commentAdditionDraft;
|
|
|
|
|
|
owner = b.owner;
|
|
|
|
|
|
}
|
2024-10-22 13:36:57 +03:00
|
|
|
|
//--
|
|
|
|
|
|
public File getArchiveFile() {
|
|
|
|
|
|
return Paths.get(System.getProperty("user.dir"), "Bugs", id + ".zip").toFile();
|
|
|
|
|
|
}
|
|
|
|
|
|
public String getDescriptionHeader() {
|
|
|
|
|
|
if (description != null) {
|
|
|
|
|
|
String[] data = description.split("\n");
|
|
|
|
|
|
return (data.length > 0) ? data[0] : "";
|
|
|
|
|
|
} else return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
public boolean CheckNotDraft(TextLog log) {
|
|
|
|
|
|
if (state.equals(BugReportState.draft)) {
|
|
|
|
|
|
log.Writeln_("Отчёт об ошибке является черновиком");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
public String getMailTitlePrefix() {
|
|
|
|
|
|
return "Ошибка " + Utils_.Brackets(id) + ", автор " + Utils_.Brackets(sender_name) + " : ";
|
|
|
|
|
|
}
|
|
|
|
|
|
public File[] getAttachements() {
|
|
|
|
|
|
File[] project_attachements = Global.mainModule.getProject().getAttachmentsDirectory().listFiles();
|
|
|
|
|
|
File[] res = new File[project_attachements.length + 1];
|
|
|
|
|
|
res[0] = getArchiveFile();
|
|
|
|
|
|
for (int i = 0; i < project_attachements.length; ++i)
|
|
|
|
|
|
res[i + 1] = project_attachements[i];
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
public boolean CheckDraft(TextLog log) {
|
|
|
|
|
|
if (!state.equals(BugReportState.draft)) {
|
|
|
|
|
|
log.Writeln("Отчёт об ошибке не является черновиком. Он уже опубликован");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
public String getNewMailText() {
|
|
|
|
|
|
String res = String.join("\n",
|
|
|
|
|
|
"Описание:", description, getPassport()
|
|
|
|
|
|
);
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
public String getSettingsSummary() {
|
2025-01-16 19:04:46 +03:00
|
|
|
|
Vector<String> res = new Vector_<String>(
|
2025-02-18 20:14:14 +03:00
|
|
|
|
(Global.mainModule.getAccount().isAdmin() ? ("Адрес отправителя: " + sender_address + "\n") : ""),
|
2025-01-16 19:04:46 +03:00
|
|
|
|
"Версия SAPFOR: " + sapfor_version,
|
|
|
|
|
|
"Версия визуализатора: " + visualiser_version,
|
|
|
|
|
|
"----------------------------------"
|
|
|
|
|
|
);
|
2025-03-27 12:45:55 +03:00
|
|
|
|
//--
|
|
|
|
|
|
Vector<BugReportSetting> settings_ = Global.componentsServer.db.getVectorByFK(this, BugReportSetting.class);
|
|
|
|
|
|
SapforProperties dummy = new SapforProperties();
|
|
|
|
|
|
for (BugReportSetting bugReportSetting : settings_)
|
|
|
|
|
|
res.add(dummy.getFieldDescription(bugReportSetting.name) + "=" + Utils_.DQuotes(bugReportSetting.value));
|
|
|
|
|
|
//--
|
2025-02-01 22:24:15 +03:00
|
|
|
|
return String.join("\n", res);
|
2024-10-22 13:36:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
public String getPassport() {
|
|
|
|
|
|
return String.join("\n",
|
2025-02-13 20:27:01 +03:00
|
|
|
|
Constants.separator,
|
2024-10-22 13:36:57 +03:00
|
|
|
|
"Отправитель: " + sender_name,
|
|
|
|
|
|
"Исполнитель: " + executor,
|
|
|
|
|
|
"Проект: " + project_version,
|
2025-02-13 20:27:01 +03:00
|
|
|
|
Constants.separator,
|
2024-10-22 13:36:57 +03:00
|
|
|
|
getSettingsSummary(),
|
2025-02-13 20:27:01 +03:00
|
|
|
|
Constants.separator);
|
2024-10-22 13:36:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
public boolean isNoneProject() {
|
|
|
|
|
|
return project_version.isEmpty();
|
|
|
|
|
|
}
|
2024-12-01 20:52:27 +03:00
|
|
|
|
//--->
|
2025-02-20 00:39:59 +03:00
|
|
|
|
public void CheckRecipients() {
|
2025-03-27 15:12:09 +03:00
|
|
|
|
Global.componentsServer.db.recipients.getUI().SelectAll(false);
|
|
|
|
|
|
Vector<BugReportRecipient> recipients_ = state.equals(BugReportState.draft) ?
|
|
|
|
|
|
recipients : Global.componentsServer.db.getVectorByFK(this, BugReportRecipient.class);
|
|
|
|
|
|
if (recipients_!=null) {
|
|
|
|
|
|
for (BugReportRecipient bugReportRecipient : recipients_) {
|
|
|
|
|
|
if (Global.componentsServer.db.recipients.containsKey(bugReportRecipient.email))
|
|
|
|
|
|
Global.componentsServer.db.recipients.get(bugReportRecipient.email).Select(true);
|
|
|
|
|
|
}
|
2024-12-01 20:52:27 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-01 22:24:15 +03:00
|
|
|
|
public VisualiserSettingsJson getSettingsJson() {
|
|
|
|
|
|
return packedSettingsJson.isEmpty() ? new VisualiserSettingsJson() : Utils_.gson.fromJson(packedSettingsJson, VisualiserSettingsJson.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
public SapforProperties getPropertiesJson() {
|
|
|
|
|
|
return packedSettingsJson.isEmpty() ? new SapforProperties() : Utils_.gson.fromJson(packedSettingsJson, SapforProperties.class);
|
|
|
|
|
|
}
|
2025-02-18 20:14:14 +03:00
|
|
|
|
public boolean canAppend(UserAccount account, TextLog log) {
|
2025-02-01 22:24:15 +03:00
|
|
|
|
if (account.CheckRegistered(log)) {
|
|
|
|
|
|
if (account.email.equals(sender_address) || account.email.equals(executor_address)) {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
switch (account.role) {
|
|
|
|
|
|
case Admin:
|
|
|
|
|
|
case Developer:
|
|
|
|
|
|
return true;
|
|
|
|
|
|
default:
|
|
|
|
|
|
if (log != null)
|
|
|
|
|
|
log.Writeln_("Вы не являетесь автором, исполнителем, разработчиком, или администратором");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2025-02-18 20:14:14 +03:00
|
|
|
|
public boolean canModify(UserAccount account, TextLog log) {
|
2025-02-01 22:24:15 +03:00
|
|
|
|
if (account.CheckRegistered(log)) {
|
|
|
|
|
|
switch (account.role) {
|
|
|
|
|
|
case Admin:
|
|
|
|
|
|
case Developer:
|
|
|
|
|
|
return true;
|
|
|
|
|
|
default:
|
|
|
|
|
|
if (account.email.equals(sender_address)) return true;
|
|
|
|
|
|
if (log != null) log.Writeln_("Вы не являетесь автором, разработчиком, или администратором");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
2025-01-16 19:04:46 +03:00
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|