no message

This commit is contained in:
2024-10-22 13:36:57 +03:00
parent fc6282cd22
commit 54a52a1e6e
15 changed files with 170 additions and 174 deletions

View File

@@ -1,13 +1,20 @@
package _VisualDVM.Repository.BugReport;
import Common.Database.Objects.DBObject;
import Common.Database.Objects.rDBObject;
import Common.Utils.TextLog;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.Repository.Component.ComponentType;
import _VisualDVM.Repository.RepositoryServer;
import _VisualDVM.Repository.Subscribes.Subscriber;
import com.sun.org.glassfish.gmbal.Description;
import java.io.File;
import java.nio.file.Paths;
import java.util.Date;
import java.util.Vector;
public class BugReport extends rDBObject {
//todo все запакованные поля переделать в json.
public String project_version = "";
public long visualiser_version = -1;
public long sapfor_version = -1;
@@ -46,6 +53,12 @@ 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,4 +81,80 @@ public class BugReport extends rDBObject {
commentAdditionDraft = b.commentAdditionDraft;
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);
if (!res.contains(Global.mainModule.getAccount().email))
res.add(Global.mainModule.getAccount().email);
return res;
}
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 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_("Отчёт об ошибке является черновиком");
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() {
return
(Global.mainModule.HasAccount() ? (Global.mainModule.getAccount().isAdmin() ? ("Адрес отправителя: " + sender_address + "\n") : "") : "") +
"Версия SAPFOR: " + sapfor_version + "\n" +
"Версия визуализатора: " + visualiser_version + "\n" +
"----------------------------------\n" +
sapfor_settings;
}
public String getPassport() {
return String.join("\n",
RepositoryServer.separator,
"Отправитель: " + sender_name,
"Исполнитель: " + executor,
"Проект: " + project_version,
RepositoryServer.separator,
getSettingsSummary(),
RepositoryServer.separator);
}
public boolean isNoneProject() {
return project_version.isEmpty();
}
}

View File

@@ -1,121 +0,0 @@
package _VisualDVM.Repository.BugReport.UI;
import Common.Utils.TextLog;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.Repository.BugReport.BugReport;
import _VisualDVM.Repository.BugReport.BugReportState;
import _VisualDVM.Repository.RepositoryServer;
import _VisualDVM.Repository.Subscribes.Subscriber;
import java.io.File;
import java.nio.file.Paths;
import java.util.Vector;
//todo слить с формой.
public class BugReportInterface {
public static String filterKey = "";
public static String filterSenderName = "";
public static String filterDescription = "";
public static String filterComment = "";
public static String filterExecutor = "";
public static String filterVersion = "";
public static boolean filterOpenedOnly = false;
public static boolean filterMyOnly = false;
public static boolean isVisible(BugReport object) {
return
object.state.equals(BugReportState.draft) ||
object.id.toUpperCase().contains(filterKey.toUpperCase())
&& object.sender_name.toUpperCase().contains(filterSenderName.toUpperCase())
&& object.description.toUpperCase().contains(filterDescription.toUpperCase())
&& object.comment.toUpperCase().contains(filterComment.toUpperCase())
&& object.executor.toUpperCase().contains(filterExecutor.toUpperCase())
&& object.project_version.toUpperCase().contains(filterVersion.toUpperCase())
&& (!filterOpenedOnly || object.state.equals(BugReportState.active))
&& (!filterMyOnly ||
(object.sender_address.equalsIgnoreCase(Global.mainModule.getAccount().email) ||
object.executor_address.equalsIgnoreCase(Global.mainModule.getAccount().email)
)
);
}
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);
}
public static File getArchiveFile(BugReport object) {
return Paths.get(System.getProperty("user.dir"), "Bugs", object.id + ".zip").toFile();
}
public static String getDescriptionHeader(BugReport object) {
if (object.description != null) {
String[] data = object.description.split("\n");
return (data.length > 0) ? data[0] : "";
} else return "";
}
public static void CheckSubscribers(BugReport object) {
for (Subscriber subscriber : Global.componentsServer.db.subscribers.Data.values())
subscriber.Select(object.targets.contains(subscriber.address));
}
public static boolean CheckNotDraft(BugReport object, TextLog log) {
if (object.state.equals(BugReportState.draft)) {
log.Writeln_("Отчёт об ошибке является черновиком");
return false;
}
return true;
}
public static String getMailTitlePrefix(BugReport object) {
return "Ошибка " + Utils_.Brackets(object.id) + ", автор " + Utils_.Brackets(object.sender_name) + " : ";
}
public static Vector<String> getRecipients(BugReport object) {
Vector<String> res = new Vector<>();
String[] data = object.targets.split("\n");
for (String a : data)
if (a.length() > 0)
res.add(a);
if (!res.contains(Global.mainModule.getAccount().email))
res.add(Global.mainModule.getAccount().email);
return res;
}
public static File[] getAttachements(BugReport object) {
File[] project_attachements = Global.mainModule.getProject().getAttachmentsDirectory().listFiles();
File[] res = new File[project_attachements.length + 1];
res[0] = getArchiveFile(object);
for (int i = 0; i < project_attachements.length; ++i)
res[i + 1] = project_attachements[i];
return res;
}
public static boolean CheckDraft(BugReport object, TextLog log) {
if (!object.state.equals(BugReportState.draft)) {
log.Writeln("Отчёт об ошибке не является черновиком. Он уже опубликован");
return false;
}
return true;
}
public static String getNewMailText(BugReport object) {
String res = String.join("\n",
"Описание:", object.description,
getPassport(object)
);
return res;
}
public static String getSettingsSummary(BugReport object) {
return
(Global.mainModule.HasAccount() ? (Global.mainModule.getAccount().isAdmin() ? ("Адрес отправителя: " + object.sender_address + "\n") : "") : "") +
"Версия SAPFOR: " + object.sapfor_version + "\n" +
"Версия визуализатора: " + object.visualiser_version + "\n" +
"----------------------------------\n" +
object.sapfor_settings;
}
public static String getPassport(BugReport object) {
return String.join("\n",
RepositoryServer.separator,
"Отправитель: " + object.sender_name,
"Исполнитель: " + object.executor,
"Проект: " + object.project_version,
RepositoryServer.separator,
getSettingsSummary(object),
RepositoryServer.separator);
}
public static boolean isNoneProject(BugReport object) {
return object.project_version.isEmpty();
}
}

View File

@@ -8,12 +8,23 @@ import Common.Visual.Tables.RendererStatusEnum;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Repository.BugReport.BugReport;
import _VisualDVM.Repository.BugReport.BugReportState;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.Comparator;
public class BugReportsForm extends DataSetControlForm<BugReport> {
//todo упразднить и раскидать по стандартным фильтрам. галки и столбцы
public static String filterKey = "";
public static String filterSenderName = "";
public static String filterDescription = "";
public static String filterComment = "";
public static String filterExecutor = "";
public static String filterVersion = "";
public static boolean filterOpenedOnly = false;
public static boolean filterMyOnly = false;
//--
public BugReportsForm(DataSet<?, BugReport> dataSource_in, JPanel mountPanel_in) {
super(dataSource_in, mountPanel_in);
}
@@ -84,14 +95,27 @@ public class BugReportsForm extends DataSetControlForm<BugReport> {
}
@Override
public boolean isObjectVisible(BugReport object) {
return super.isObjectVisible(object) && BugReportInterface.isVisible(object);
return super.isObjectVisible(object) && (
object.state.equals(BugReportState.draft) ||
object.id.toUpperCase().contains(filterKey.toUpperCase())
&& object.sender_name.toUpperCase().contains(filterSenderName.toUpperCase())
&& object.description.toUpperCase().contains(filterDescription.toUpperCase())
&& object.comment.toUpperCase().contains(filterComment.toUpperCase())
&& object.executor.toUpperCase().contains(filterExecutor.toUpperCase())
&& object.project_version.toUpperCase().contains(filterVersion.toUpperCase())
&& (!filterOpenedOnly || object.state.equals(BugReportState.active))
&& (!filterMyOnly ||
(object.sender_address.equalsIgnoreCase(Global.mainModule.getAccount().email) ||
object.executor_address.equalsIgnoreCase(Global.mainModule.getAccount().email)
)
)
);
}
@Override
public Object getFieldAt(BugReport object, int columnIndex) {
switch (columnIndex) {
case 1:
//todo выкинуть этот интерфейс. бессмысленный
return BugReportInterface.getDescriptionHeader(object);
return object.getDescriptionHeader();
case 2:
return object.sender_name;
case 3:

View File

@@ -13,7 +13,6 @@ import _VisualDVM.Passes.All.UnzipFolderPass;
import _VisualDVM.Passes.All.ZipFolderPass;
import _VisualDVM.ProjectData.LanguageName;
import _VisualDVM.Repository.BugReport.BugReport;
import _VisualDVM.Repository.BugReport.UI.BugReportInterface;
import _VisualDVM.Repository.BugReportsDatabase;
import _VisualDVM.Repository.Component.ComponentType;
import _VisualDVM.Repository.EmailMessage;
@@ -125,7 +124,7 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
if (object instanceof BugReport) {
BugReport bugReport = (BugReport) object;
if (!bugReport.project_version.isEmpty())
Utils_.forceDeleteWithCheck(BugReportInterface.getArchiveFile(bugReport));
Utils_.forceDeleteWithCheck(bugReport.getArchiveFile());
}
}
@Override