рефакторинг. неудачные наименования классов, и остатки старых вариантов

This commit is contained in:
2023-10-08 01:06:55 +03:00
parent 49805f1293
commit eedddcd7d3
42 changed files with 295 additions and 1415 deletions

View File

@@ -1,10 +1,8 @@
package GlobalData;
import Common.Current;
import Common.Database.DBObject;
import Common.Database.DataSet;
import Common.Database.SQLITE.SQLiteDatabase;
import Common.Global;
import Common.UI.DataSetControlForm;
import GlobalData.Account.Account;
import GlobalData.Account.AccountsDBTable;
import GlobalData.Compiler.CompilersDBTable;
@@ -19,7 +17,6 @@ import GlobalData.Grid.GridsDBTable;
import GlobalData.Machine.MachinesDBTable;
import GlobalData.Makefile.MakefilesDBTable;
import GlobalData.Module.ModulesDBTable;
import GlobalData.RemoteSapfor.RemoteSapforsDBTable;
import GlobalData.RunConfiguration.RunConfigurationsDBTable;
import GlobalData.SapforProfile.SapforProfile;
import GlobalData.SapforProfile.SapforProfilesDBTable;
@@ -33,24 +30,17 @@ import GlobalData.Tasks.CompilationTask.CompilationTasksDBTable;
import GlobalData.Tasks.RunTask.RunTasksDBTable;
import GlobalData.User.UsersDBTable;
import Repository.Component.ComponentType;
import SapforTestingSystem.SapforTask.SapforTaskResult;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.TaskKey.TaskKeysDBTable;
import Visual_DVM_2021.PassStats.PassStatsDBTable;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import java.nio.file.Paths;
import java.util.Date;
import java.util.LinkedHashMap;
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
public class GlobalDatabase extends SQLiteDatabase {
//---------СЕАНС----------------------------------------------
public MachinesDBTable machines;
public UsersDBTable users;
public CompilersDBTable compilers;
public RemoteSapforsDBTable remoteSapfors;
public MakefilesDBTable makefiles;
public ModulesDBTable modules;
public CompilationTasksDBTable compilationTasks;
@@ -70,10 +60,6 @@ public class GlobalDatabase extends SQLiteDatabase {
public GridsDBTable grids;
//-
public TaskKeysDBTable tasksKeys;
//---------
// public SapforScenariosDBTable sapforScenarios;
// public SapforTasksPackagesDBTable sapforTasksPackages;
// public SapforTasksDBTable sapforTasks = null;
public SapforProfilesDBTable sapforProfiles = null;
//---------
public SapforProfileSettingsDBTable sapforProfilesSettings = null;
@@ -86,7 +72,6 @@ public class GlobalDatabase extends SQLiteDatabase {
addTable(machines = new MachinesDBTable());
addTable(users = new UsersDBTable());
addTable(compilers = new CompilersDBTable());
addTable(remoteSapfors = new RemoteSapforsDBTable());
addTable(makefiles = new MakefilesDBTable());
addTable(modules = new ModulesDBTable());
addTable(compilationTasks = new CompilationTasksDBTable());
@@ -104,11 +89,6 @@ public class GlobalDatabase extends SQLiteDatabase {
addTable(dvmParameters = new DVMParameterDBTable());
addTable(grids = new GridsDBTable());
addTable(tasksKeys = new TaskKeysDBTable());
//--
// addTable(sapforScenarios = new SapforScenariosDBTable());
// addTable(sapforTasksPackages = new SapforTasksPackagesDBTable());
// addTable(sapforTasks = new SapforTasksDBTable());
//--
addTable(sapforProfiles = new SapforProfilesDBTable());
addTable(sapforProfilesSettings = new SapforProfileSettingsDBTable());
}
@@ -138,8 +118,6 @@ public class GlobalDatabase extends SQLiteDatabase {
credentials.makefile_id = Current.getMakefile().id;
if (Current.HasRunConfiguration())
credentials.runconfiguration_id = Current.getRunConfiguration().id;
if (Current.HasRemoteSapfor())
credentials.remotesapfor_id = Current.getRemoteSapfor().id;
Update(credentials);
}
public void UpdateCredentials() {
@@ -156,17 +134,7 @@ public class GlobalDatabase extends SQLiteDatabase {
return res;
}
/*
public LinkedHashMap<Long, SapforTask> getSapforPackageTasks(int package_id) throws Exception {
LinkedHashMap<Long, SapforTask> res = new LinkedHashMap<>();
for (SapforTask task : sapforTasks.Data.values()) {
if (task.sapfor_configuration_id == package_id) {
res.put(task.id, task);
}
}
return res;
}
*/
public DataSet<String, SapforTaskResult> getSapforPackagesMasterDataSet(SapforTasksPackage package_in) throws Exception {
public DataSet<String, SapforTaskResult> getSapforPackagesMasterDataSet(SapforConfigurationTasksSet package_in) throws Exception {
DataSet<String, SapforTaskResult> res = new DataSet<String, SapforTaskResult>(String.class, SapforTaskResult.class) {
@Override
protected DataSetControlForm createUI() {
@@ -209,11 +177,9 @@ public class GlobalDatabase extends SQLiteDatabase {
for (SapforTask task : sapforTasks.Data.values())
if (task.sapfor_configuration_id == package_in.id)
res.put(task.test_description, new SapforTaskResult(package_in, task));
*/
return res;
}
//--
public DataSet<String, SapforTaskResult> getSapforPackagesSlaveDataSet(SapforTasksPackage package_in) throws Exception {
public DataSet<String, SapforTaskResult> getSapforPackagesSlaveDataSet(SapforConfigurationTasksSet package_in) throws Exception {
DataSet<String, SapforTaskResult> res = new DataSet<String, SapforTaskResult>(String.class, SapforTaskResult.class) {
@Override
protected DataSetControlForm createUI() {
@@ -256,13 +222,13 @@ public class GlobalDatabase extends SQLiteDatabase {
return Current.SapforTaskResult;
}
};
/*
for (SapforTask task : sapforTasks.Data.values())
if (task.sapfor_configuration_id == package_in.id)
res.put(task.test_description, new SapforTaskResult(package_in, task));
*/
return res;
}
*/
//--
public LinkedHashMap<SettingName, String> getSapforSettingsForProfile() {
LinkedHashMap<SettingName, String> res = new LinkedHashMap<>();

View File

@@ -10,7 +10,6 @@ import GlobalData.EnvironmentValue.EnvironmentValue;
import GlobalData.Machine.UI.MachineFields;
import GlobalData.Makefile.Makefile;
import GlobalData.Module.Module;
import GlobalData.RemoteSapfor.RemoteSapfor;
import GlobalData.RunConfiguration.RunConfiguration;
import GlobalData.Tasks.CompilationTask.CompilationTask;
import GlobalData.Tasks.RunTask.RunTask;
@@ -67,7 +66,6 @@ public class MachinesDBTable extends iDBTable<Machine> {
//-
res.put(User.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(Compiler.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(RemoteSapfor.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(Makefile.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
res.put(RunConfiguration.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
//-

View File

@@ -1,47 +0,0 @@
package GlobalData.RemoteSapfor;
import Common.Current;
import Common.Database.iDBObject;
import Common.Utils.Utils;
import GlobalData.Machine.Machine;
import ProjectData.LanguageName;
import com.sun.org.glassfish.gmbal.Description;
public class RemoteSapfor extends iDBObject {
//---------------------------------------------------------------------
@Description("IGNORE")
public static String version_command = "-ver";//команда запроса версии компилятора.
@Description("IGNORE")
public static String help_command = "-help";// команда запроса help
//----------------------------------------------------------------------
public int machine_id = -1;
public String description = "";
public LanguageName languageName = LanguageName.fortran;
public String home_path = ""; //домашняя папка.
public String call_command = ""; //полная команда вызова.
public String version = "?";
public RemoteSapfor() {
}
public RemoteSapfor(Machine machine,
String description_in,
LanguageName languageName_in,
String call_command_in
) {
machine_id = machine.id;
description = description_in;
languageName = languageName_in;
call_command = call_command_in;
}
@Override
public boolean isVisible() {
return Current.HasMachine() && Current.getMachine().id == machine_id;
}
@Override
public String toString() {
return call_command;
}
public String getDescription() {
return description;
}
public String getVersionCommand() {
return Utils.DQuotes(call_command) + " " + version_command;
}
}

View File

@@ -1,126 +0,0 @@
package GlobalData.RemoteSapfor;
import Common.Current;
import Common.Database.iDBTable;
import Common.UI.DataSetControlForm;
import Common.UI.UI;
import Common.UI.Windows.Dialog.DBObjectDialog;
import Common.Utils.Utils;
import Common.Utils.Validators.PathValidator;
import GlobalData.RemoteSapfor.UI.RemoteSapforFields;
import ProjectData.LanguageName;
public class RemoteSapforsDBTable extends iDBTable<RemoteSapfor> {
public RemoteSapforsDBTable() {
super(RemoteSapfor.class);
}
@Override
public String getSingleDescription() {
return "SAPFOR";
}
@Override
public String getPluralDescription() {
return "SAPFOR";
}
@Override
public Current CurrentName() {
return Current.RemoteSapfor;
}
@Override
public String[] getUIColumnNames() {
return new String[]{"описание", "команда вызова", "версия"};
}
@Override
public Object getFieldAt(RemoteSapfor object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.description;
case 2:
return object.call_command;
case 3:
return object.version;
}
return null;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
}
};
}
//---
@Override
public DBObjectDialog<RemoteSapfor, RemoteSapforFields> getDialog() {
return new DBObjectDialog<RemoteSapfor, RemoteSapforFields>(RemoteSapforFields.class) {
@Override
public void validateFields() {
//<editor-fold desc="расположение">
String home = fields.tfHome.getText();
if (!home.isEmpty()) {
if (home.startsWith("/")) {
if (Utils.ContainsCyrillic(home))
Log.Writeln("Расположение системы SAPFOR не может содержать кириллицу");
else {
new PathValidator(home, "Расположение системы SAPFOR", Log).Validate();
}
} else
Log.Writeln("Расположение системы SAPFOR может быть либо пустой строкой, либо путём к файлу");
}
//</editor-fold>
//<editor-fold desc="команда вызова">
String call_command = fields.tfCallCommand.getText();
if (call_command.isEmpty()) Log.Writeln("Команда вызова системы SAPFOR не может быть пустой");
else if (Utils.ContainsCyrillic(call_command))
Log.Writeln("Команда вызова системы SAPFOR не может содержать кириллицу");
else {
switch (call_command.charAt(0)) {
case ' ':
Log.Writeln("Команда вызова системы SAPFOR не может начинаться с пробела.");
break;
case '/':
if (call_command.endsWith("/"))
Log.Writeln("Каталог не может быть указан в качестве команды.");
else new PathValidator(call_command, "Команда вызова системы SAPFOR", Log).Validate();
break;
default:
//это команда.
//самое опасное место. теоретически тут можно ввести любую команду ОС, в том числе rm -rf
if (call_command.contains(" "))
Log.Writeln("Прямая команда вызова системы SAPFOR не может содержать пробелы");
if (!call_command.contains("+") && Utils.ContainsForbiddenName(call_command))
Log.Writeln("Прямая команда вызова системы SAPFOR содержит запрещённые символы");
else {
if (Utils.isLinuxSystemCommand(call_command))
Log.Writeln(Utils.DQuotes(call_command) + " является системной командой Linux");
}
break;
}
}
//</editor-fold>
}
@Override
public void fillFields() {
fields.tfDescription.setText(Result.description);
fields.tfCallCommand.setText(Result.call_command);
fields.tfHome.setText(Result.home_path);
UI.TrySelect(fields.cbLanguageName, Result.languageName);
fields.tfVersion.setText(Result.version);
fields.events_on = true;
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Result.description = fields.tfDescription.getText();
Result.call_command = fields.tfCallCommand.getText();
Result.home_path = fields.tfHome.getText();
Result.languageName = (LanguageName) fields.cbLanguageName.getSelectedItem();
Result.version = fields.tfVersion.getText();
}
@Override
public int getDefaultHeight() {
return 300;
}
};
}
}

View File

@@ -1,113 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="GlobalData.RemoteSapfor.UI.RemoteSapforFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="a4409" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="описание"/>
</properties>
</component>
<vspacer id="ff938">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="d8b80" class="javax.swing.JTextField" binding="tfDescription" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="38f55" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="расположение"/>
</properties>
</component>
<component id="4599c" class="javax.swing.JTextField" binding="tfHome" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="92f09" class="javax.swing.JButton" binding="bBrowse">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<icon value="icons/LastOpened.png"/>
<text value=""/>
</properties>
</component>
<component id="66fe1" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="команда вызова"/>
</properties>
</component>
<component id="bb2d7" class="javax.swing.JTextField" binding="tfCallCommand" custom-create="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="99516" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="язык"/>
</properties>
</component>
<component id="113b3" class="javax.swing.JComboBox" binding="cbLanguageName" custom-create="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<toolTipText value="выберите тип компилятора"/>
</properties>
</component>
<component id="3f186" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="версия"/>
</properties>
</component>
<component id="acebb" class="javax.swing.JTextField" binding="tfVersion" custom-create="true">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>

View File

@@ -1,65 +0,0 @@
package GlobalData.RemoteSapfor.UI;
import Common.Current;
import Common.UI.TextField.StyledTextField;
import Common.UI.Windows.Dialog.DialogFields;
import ProjectData.LanguageName;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
public class RemoteSapforFields implements DialogFields {
private JPanel content;
public JTextField tfDescription;
public JTextField tfHome;
private JButton bBrowse;
public JTextField tfCallCommand;
public JComboBox<LanguageName> cbLanguageName;
public JTextField tfVersion;
public boolean events_on = false;
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfDescription = new StyledTextField();
tfHome = new StyledTextField();
tfCallCommand = new StyledTextField();
cbLanguageName = new JComboBox<>();
cbLanguageName.addItem(LanguageName.fortran);
tfVersion = new StyledTextField();
}
public RemoteSapforFields() {
bBrowse.addActionListener(e -> {
// LanguageName languageName = (LanguageName) cbLanguageName.getSelectedItem();
String dst = null;
if (Pass_2021.passes.get(PassCode_2021.SelectRemoteFile).Do(true))
dst = Current.getRemoteFile().full_name;
if (dst != null)
tfHome.setText(dst);
});
tfHome.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
TryRestoreCallCommand();
}
@Override
public void removeUpdate(DocumentEvent e) {
TryRestoreCallCommand();
}
@Override
public void changedUpdate(DocumentEvent e) {
}
}
);
}
public void TryRestoreCallCommand() {
if (events_on && (cbLanguageName.getSelectedItem() != null))
tfCallCommand.setText(tfHome.getText() +
(tfHome.getText().endsWith("/") ? "" : "/") +
"Sapfor_F");
}
}