no message

This commit is contained in:
2025-03-27 12:45:55 +03:00
parent 19afec4d25
commit fb296a02ee
17 changed files with 234 additions and 125 deletions

View File

@@ -17,6 +17,9 @@ public abstract class nDBObject extends DBObject {
public Object getEmptyFK() {
return "";
}
public String getFKName() {
return getClass().getSimpleName().toLowerCase() + "_id";
}
public void genName() {
id = Utils_.getDateName(getClass().getSimpleName().toLowerCase());
}

View File

@@ -29,4 +29,5 @@ public class rDBObject extends nDBObject {
date = r.date;
change_date = r.change_date;
}
}

View File

@@ -1,6 +1,7 @@
package Common;
import Common.Utils.Utils_;
import Common.Visual.Controls.StableMenuItem;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -8,6 +9,7 @@ import java.awt.event.ActionListener;
import java.io.File;
import java.lang.reflect.Field;
import java.util.LinkedHashMap;
import java.util.Vector;
public class Properties {
protected LinkedHashMap<String, JMenuItem> controls = new LinkedHashMap<>();
private File file = null; //файл где хранятся настройки.

View File

@@ -7,6 +7,7 @@ import Common.Utils.Vector_;
import _VisualDVM.ComponentsServer.BugReport.Json.RecipientJson;
import _VisualDVM.ComponentsServer.BugReport.Json.RecipientsJson;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingsJson;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.Component.ComponentType;
import _VisualDVM.ComponentsServer.Recipient.Recipient;
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
@@ -26,8 +27,9 @@ public class BugReport extends rDBObject {
public String comment = "";
@Description("DEFAULT ''")
public String packedRecipientsJson = "";
@Description("DEFAULT ''")
public String packedSettingsJson = ""; //устарело. (?)
@Description("IGNORE")
public String packedSettingsJson = ""; //todo вывести.
public Vector<BugReportSetting> settings=null;
public String executor = "";
@Description("DEFAULT ''")
public String executor_address = "";
@@ -54,7 +56,7 @@ public class BugReport extends rDBObject {
project_version = version_in;
visualiser_version = Global.visualiser.version;
sapfor_version = Global.components.get(ComponentType.Sapfor_F).version;
packedSettingsJson = Utils_.gson.toJson(Global.mainModule.getProject().sapforProperties);
settings = Global.mainModule.getProject().sapforProperties.toBugReportSettings();
percentage = 0;
description = description_in;
date = new Date().getTime();
@@ -78,7 +80,7 @@ public class BugReport extends rDBObject {
project_version = b.project_version;
visualiser_version = b.visualiser_version;
sapfor_version = b.sapfor_version;
packedSettingsJson = b.packedSettingsJson;
// packedSettingsJson = b.packedSettingsJson;
//-
descriptionAdditionDraft = b.descriptionAdditionDraft;
commentAdditionDraft = b.commentAdditionDraft;
@@ -132,13 +134,12 @@ public class BugReport extends rDBObject {
"Версия визуализатора: " + visualiser_version,
"----------------------------------"
);
if (!project_version.isEmpty()) {
if (visualiser_version < 1134) {
res.add(getSettingsJson().getSummary());
} else {
res.add(getPropertiesJson().getSummary());
}
}
//--
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));
//--
return String.join("\n", res);
}
public String getPassport() {

View File

@@ -1,9 +1,24 @@
package _VisualDVM.ComponentsServer.BugReport;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.DBTable;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Visual.DataSetControlForm;
import _VisualDVM.ComponentsServer.BugReport.UI.BugReportsForm;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.DVMParameter.DVMParameter;
import _VisualDVM.GlobalData.EnvironmentValue.EnvironmentValue;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.Module.Module;
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import _VisualDVM.GlobalData.User.User;
import javax.swing.*;
import java.util.LinkedHashMap;
import java.util.Vector;
import java.util.stream.Collectors;
public class BugReportsDBTable extends DBTable<String, BugReport> {
@@ -25,5 +40,11 @@ public class BugReportsDBTable extends DBTable<String, BugReport> {
public Vector<BugReport> getAllDrafts() throws Exception {
return Data.values().stream().filter(bugReport -> bugReport.state.equals(BugReportState.draft)).collect(Collectors.toCollection(Vector::new));
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(BugReportSetting.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
return res;
}
//-
}

View File

@@ -0,0 +1,27 @@
package _VisualDVM.ComponentsServer.BugReportSetting;
import Common.Database.Objects.DBObject;
import Common.Database.Objects.iDBObject;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
public class BugReportSetting extends iDBObject {
public String bugreport_id = "";
public String name = "";
public String value = "";
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
BugReportSetting src_ = (BugReportSetting) src;
bugreport_id = src_.bugreport_id;
name = src_.name;
value = src_.value;
}
public BugReportSetting() {
}
public BugReportSetting(BugReport bugReport, String name_in, Object value_in) {
this(name_in, value_in);
bugreport_id = bugReport.id;
}
public BugReportSetting(String name_in, Object value_in){
name = name_in;
value = (value_in instanceof Boolean) ? ((boolean) value_in ? "1" : "0"): value_in.toString();
}
}

View File

@@ -0,0 +1,8 @@
package _VisualDVM.ComponentsServer.BugReportSetting;
import Common.Database.Tables.iDBTable;
public class BugReportSettingsDBTable extends iDBTable<BugReportSetting> {
public BugReportSettingsDBTable() {
super(BugReportSetting.class);
}
}

View File

@@ -1,14 +1,21 @@
package _VisualDVM.ComponentsServer;
import Common.Database.SQLITE.SQLiteDatabase;
import Common.Utils.Vector_;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReport.BugReportsDBTable;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingJson;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingsJson;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSettingsDBTable;
import _VisualDVM.ComponentsServer.Recipient.RecipientsDataSet;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.ProjectData.SapforData.SapforProperties;
import java.nio.file.Paths;
import java.util.Vector;
public class BugReportsDatabase extends SQLiteDatabase {
public BugReportsDBTable bugReports;
public BugReportSettingsDBTable bugReportSettings;
public RecipientsDataSet recipients = new RecipientsDataSet();
public BugReportsDatabase() {
super(Paths.get(System.getProperty("user.dir"), "Data", "bug_reports.sqlite").toFile());
@@ -16,6 +23,7 @@ public class BugReportsDatabase extends SQLiteDatabase {
@Override
protected void initAllTables() throws Exception {
addTable(bugReports = new BugReportsDBTable());
addTable(bugReportSettings = new BugReportSettingsDBTable());
}
@Override
public void Init() throws Exception {
@@ -42,4 +50,34 @@ public class BugReportsDatabase extends SQLiteDatabase {
recipients.ShowUI(); //todo временно.
super.ResetUI();
}
public void Patch() throws Exception {
Vector<BugReportSetting> settings = new Vector<>();
//--
for (BugReport bugReport : bugReports.Data.values()) {
//--
if (!bugReport.project_version.isEmpty()) {
if (bugReport.visualiser_version < 1134) {
VisualiserSettingsJson visualiserSettingsJson = bugReport.getSettingsJson();
for (VisualiserSettingJson visualiserSettingJson : visualiserSettingsJson.array) {
BugReportSetting bugReportSetting = new BugReportSetting();
bugReportSetting.bugreport_id = bugReport.id;
bugReportSetting.name = visualiserSettingJson.name;
bugReportSetting.value = visualiserSettingJson.value;
settings.add(bugReportSetting);
}
} else {
SapforProperties sapforProperties = bugReport.getPropertiesJson();
Vector<BugReportSetting> settings_= sapforProperties.toBugReportSettings();
for (BugReportSetting bugReportSetting: settings_)
bugReportSetting.bugreport_id = bugReport.id;
settings.addAll(settings_);
}
}
//--
}
BeginTransaction();
for (BugReportSetting bugReportSetting : settings)
Insert(bugReportSetting);
Commit();
}
}

View File

@@ -3,6 +3,8 @@ import Common.CommonConstants;
import Common.Passes.PassException;
import Common.Utils.Utils_;
import Common.Visual.UI;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.Component.OSDComponent;
import _VisualDVM.ComponentsServer.Component.Visualizer_2;
import _VisualDVM.Constants;
@@ -12,12 +14,14 @@ import _VisualDVM.Passes.Sapfor.SapforAnalysis;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.Files.UI.Editor.SPFEditor;
import _VisualDVM.ProjectData.Project.db_project_info;
import _VisualDVM.ProjectData.SapforData.SapforProperties;
import _VisualDVM.TestingSystem.Common.Test.Test;
import _VisualDVM.Utils;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.lang.reflect.Field;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -641,4 +645,5 @@ public abstract class Sapfor extends OSDComponent {
Global.mainModule.getUI().getVersionsWindow().BlockVariants();
}
//--
}

View File

@@ -5,6 +5,7 @@ import Common.Database.RepositoryRefuseException;
import Common.Utils.Utils_;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReport.Json.BugReportAdditionJson;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.ComponentsServer.Component.ComponentType;
import _VisualDVM.ComponentsServer.Component.Json.ComponentPublicationInfoJson;
import _VisualDVM.ComponentsServer.Component.Json.ComponentVersionsInfoJson;
@@ -63,6 +64,18 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
}
}
@Override
protected void afterPublishAction(DBObject object) throws Exception {
if (object instanceof BugReport){
BugReport bugReport = (BugReport) object;
if (bugReport.settings!=null){
for (BugReportSetting setting: bugReport.settings){
setting.bugreport_id=bugReport.id;
db.Insert(setting);
}
}
}
}
@Override
protected void afterDeleteAction(DBObject object) throws Exception {
if (object instanceof BugReport) {
BugReport bugReport = (BugReport) object;
@@ -350,4 +363,9 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
}
}
@Override
public void StartAction() throws Exception {
super.StartAction();
// db.Patch();
}
}

View File

@@ -47,7 +47,7 @@ public class Constants {
public static final int MailSocketPort = 465;
//
//7998 отладочный порт. теперь.
public static final int ComponentsServerPort = 7995; //7795
public static final int ComponentsServerPort = 7998; //7795
public static final int TestingServerPort = 7996; //7996
public static final int SocketTimeout = 0;
//-

View File

@@ -31,6 +31,6 @@ public class ApplyBugReportSettings extends Pass<BugReport> {
}
@Override
protected void body() throws Exception {
Global.mainModule.getProject().sapforProperties.applyPatch(target.getSettingsJson());
Global.mainModule.getProject().sapforProperties.applyBugReportSettings(target);
}
}

View File

@@ -42,8 +42,6 @@ public class PublishBugReport extends Pass<BugReport> {
}
@Override
protected void body() throws Exception {
// 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;
@@ -67,9 +65,11 @@ public class PublishBugReport extends Pass<BugReport> {
message.addAttachement(screen);
}
}
/*
Global.mainModule.getPass(PassCode.Email).Do(
message,
Global.componentsServer.db.recipients.getSelectedMails());
*/
}
@Override
protected void showDone() throws Exception {

View File

@@ -1,8 +1,8 @@
package _VisualDVM.ProjectData.SapforData;
import Common.Properties;
import Common.Utils.Vector_;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingJson;
import _VisualDVM.ComponentsServer.BugReport.Json.VisualiserSettingsJson;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.ComponentsServer.BugReportSetting.BugReportSetting;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.SapforProfileSetting.SapforProfileSetting;
import _VisualDVM.Passes.PassCode;
@@ -177,50 +177,7 @@ public class SapforProperties extends Properties {
}
return String.join("\n", res);
}
public void applyPatch(VisualiserSettingsJson settings) {
Vector<String> changedFields = new Vector<>();
try {
for (VisualiserSettingJson setting : settings.array) {
Field field = null;
try {
field = getClass().getField(setting.name);
} catch (Exception ex) {
ex.printStackTrace();
}
if (field != null) {
if (field.getName().equals(setting.name)) {
changedFields.add(setting.name);
switch (setting.name) {
case "GCOVLimit":
GCOVLimit = Integer.parseInt(setting.value);
break;
case "MAX_SHADOW_WIDTH":
MAX_SHADOW_WIDTH = Integer.parseInt(setting.value);
break;
case "ANALYSIS_OPTIONS":
ANALYSIS_OPTIONS = setting.value;
break;
case "DVMConvertationOptions":
DVMConvertationOptions = setting.value;
break;
default:
int value_ = Integer.parseInt(setting.value);
field.set(this, value_ != 0);
break;
}
}
}
}
if (!changedFields.isEmpty()) {
this.Update();
for (String fieldName : changedFields) {
Mark(fieldName, getMenuItem(fieldName));
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
//--
public void applyProfile(Vector<SapforProfileSetting> settings) {
Vector<String> changedFields = new Vector<>();
try {
@@ -265,6 +222,52 @@ public class SapforProperties extends Properties {
ex.printStackTrace();
}
}
public void applyBugReportSettings(BugReport bugReport) {
Vector<String> changedFields = new Vector<>();
Vector<BugReportSetting> settings = Global.componentsServer.db.getVectorByFK(bugReport, BugReportSetting.class);
for (BugReportSetting setting : settings) {
try {
Field field = null;
try {
field = getClass().getField(setting.name);
} catch (Exception ex) {
ex.printStackTrace();
}
if (field != null) {
if (field.getName().equals(setting.name)) {
changedFields.add(setting.name);
switch (setting.name) {
case "GCOVLimit":
GCOVLimit = Integer.parseInt(setting.value);
break;
case "MAX_SHADOW_WIDTH":
MAX_SHADOW_WIDTH = Integer.parseInt(setting.value);
break;
case "ANALYSIS_OPTIONS":
ANALYSIS_OPTIONS = setting.value;
break;
case "DVMConvertationOptions":
DVMConvertationOptions = setting.value;
break;
default:
int value_ = Integer.parseInt(setting.value);
field.set(this, value_ != 0);
break;
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (!changedFields.isEmpty()) {
this.Update();
for (String fieldName : changedFields) {
Mark(fieldName, getMenuItem(fieldName));
}
}
}
//--
public LinkedHashMap<String, String> toMap() {
LinkedHashMap<String, String> res = new LinkedHashMap<>();
Vector<String> forbidden = new Vector_<String>(
@@ -289,4 +292,32 @@ public class SapforProperties extends Properties {
}
return res;
}
//--
public Vector<BugReportSetting> toBugReportSettings() {
Vector<BugReportSetting> res = new Vector<>();
res.addAll(new Vector_<>(
new BugReportSetting("STATIC_SHADOW_ANALYSIS", STATIC_SHADOW_ANALYSIS),
new BugReportSetting("STATIC_PRIVATE_ANALYSIS", STATIC_PRIVATE_ANALYSIS),
new BugReportSetting("FREE_FORM", FREE_FORM),
new BugReportSetting("KEEP_DVM_DIRECTIVES", KEEP_DVM_DIRECTIVES),
new BugReportSetting("KEEP_SPF_DIRECTIVES", KEEP_SPF_DIRECTIVES),
new BugReportSetting("PARALLELIZE_FREE_LOOPS", PARALLELIZE_FREE_LOOPS),
new BugReportSetting("MAX_SHADOW_WIDTH", MAX_SHADOW_WIDTH),
new BugReportSetting("OUTPUT_UPPER", OUTPUT_UPPER),
new BugReportSetting("TRANSLATE_MESSAGES", TRANSLATE_MESSAGES),
new BugReportSetting("KEEP_LOOPS_CLOSE_NESTING", KEEP_LOOPS_CLOSE_NESTING),
new BugReportSetting("KEEP_GCOV", KEEP_GCOV),
new BugReportSetting("ANALYSIS_OPTIONS", ANALYSIS_OPTIONS),
new BugReportSetting("DEBUG_PRINT_ON", DEBUG_PRINT_ON),
new BugReportSetting("MPI_PROGRAM", MPI_PROGRAM),
new BugReportSetting("IGNORE_IO_SAPFOR", IGNORE_IO_SAPFOR),
new BugReportSetting("KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS", KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS),
new BugReportSetting("PARSE_FOR_INLINE", PARSE_FOR_INLINE),
new BugReportSetting("Precompilation", Precompilation),
new BugReportSetting("SaveModifications", SaveModifications),
new BugReportSetting("GCOVLimit", GCOVLimit),
new BugReportSetting("DVMConvertationOptions", DVMConvertationOptions)
));
return res;
}
}

View File

@@ -475,7 +475,6 @@ public class CallbackForm implements FormWithSplitters, CallbackWindow {
@Override
public void ShowCurrentBugReport() {
SwitchListeners(false);
// currentBugReportTabs.setSelectedIndex(0);
BugReport target = Global.componentsServer.db.bugReports.getUI().getCurrent();
target.CheckRecipients();
Global.componentsServer.db.recipients.ShowUI();
@@ -502,9 +501,9 @@ public class CallbackForm implements FormWithSplitters, CallbackWindow {
} else ShowUser(); //недоступно ничего. и баг ему невидим. но на всякий случай.
}
break;
case Student:
case Developer:
case Admin:
//разработчик может все то же что и админ. они равны по правам владельцу любого бага.
ShowSender();
break;
}