промежуточный. частичный рефакторинг смены глобальный настроек. автоотключение проверки бд тестов если активных пакетов нет.

This commit is contained in:
2023-11-13 21:07:44 +03:00
parent 56f54581b6
commit a76e9d0310
21 changed files with 218 additions and 188 deletions

24
.idea/workspace.xml generated
View File

@@ -6,7 +6,29 @@
</artifacts-to-build> </artifacts-to-build>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="" /> <list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/UpdateProperty.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/GlobalProperties.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/GlobalProperties.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Properties.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Properties.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestingBar/TestingBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestingBar/TestingBar.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/GlobalData/Settings/SettingName.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GlobalData/Settings/SettingName.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TasksDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TasksDatabase.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TasksPackage/TasksPackageState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TasksPackage/TasksPackageState.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ActualizePackages.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ConvertCorrectnessTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/ConvertCorrectnessTests.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestsGroupFromSelectedVersions.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestsGroupFromSelectedVersions.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartSapforTests.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/StartTests.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/SynchronizeTestsTasks.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/SynchronizeTestsTasks.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/UpdateSetting.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/UpdateSetting.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/Pass_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/Pass_2021.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Interface/TestingWindow.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Interface/TestingWindow.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/TestingForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/TestingForm.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />

View File

@@ -24,5 +24,9 @@
"Visualizer_2Path": "C:\\Users\\misha\\Documents", "Visualizer_2Path": "C:\\Users\\misha\\Documents",
"InstructionPath": "", "InstructionPath": "",
"PerformanceAnalyzerPath": "", "PerformanceAnalyzerPath": "",
"ComponentsBackUpsCount": 10 "ComponentsBackUpsCount": 10,
"TestingKernels": 4,
"AutoCheckTesting": false,
"CheckTestingIntervalSeconds": 10,
"EmailOnTestingProgress": false
} }

View File

@@ -4,6 +4,19 @@ import com.google.gson.annotations.Expose;
import java.io.File; import java.io.File;
import java.nio.file.Paths; import java.nio.file.Paths;
public class GlobalProperties extends Properties { public class GlobalProperties extends Properties {
@Override
public String getFieldDescription(String fieldName) {
switch (fieldName) {
case "ShowPassesDone":
return "Сообщать об успешном выполнении проходов";
case "ConfirmPassesStart":
return "Запрашивать подтверждения начала выполнения проходов";
case "FocusPassesResult":
return "Переходить на результирующую вкладку проходов по их завершении";
default:
return "?";
}
}
@Expose @Expose
public Current.Mode Mode = Current.Mode.Normal; public Current.Mode Mode = Current.Mode.Normal;
//--- //---
@@ -37,7 +50,6 @@ public class GlobalProperties extends Properties {
public boolean ShowPassesDone = true; public boolean ShowPassesDone = true;
@Expose @Expose
public boolean FocusPassesResult = true; public boolean FocusPassesResult = true;
//-
@Expose @Expose
public String GlobalDBName = "db7.sqlite"; public String GlobalDBName = "db7.sqlite";
@Expose @Expose
@@ -64,21 +76,17 @@ public class GlobalProperties extends Properties {
public String PerformanceAnalyzerPath = ""; public String PerformanceAnalyzerPath = "";
@Expose @Expose
public int ComponentsBackUpsCount=10; public int ComponentsBackUpsCount=10;
//- тестирование.
@Expose
public int TestingKernels = 4; //число ядер для тестирования
@Expose
public boolean AutoCheckTesting = false; // проверять ли задачи тестирования при включенном визуализаторе.
@Expose
public int CheckTestingIntervalSeconds = 10; //интервал автопроверки тестирования
@Expose
public boolean EmailOnTestingProgress = false; //включено ли оповещение по email о результатах тестирования.
//- //-
@Override @Override
public String getFieldDescription(String fieldName) {
switch (fieldName) {
case "ShowPassesDone":
return "Сообщать об успешном выполнении проходов";
case "ConfirmPassesStart":
return "Запрашивать подтверждения начала выполнения проходов";
case "FocusPassesResult":
return "Переходить на результирующую вкладку проходов по их завершении";
default:
return "?";
}
}
@Override
public File getFile() { public File getFile() {
return Paths.get(System.getProperty("user.dir"),"properties").toFile(); return Paths.get(System.getProperty("user.dir"),"properties").toFile();
} }

View File

@@ -4,6 +4,7 @@ import Common.Utils.Utils;
import javax.swing.*; import javax.swing.*;
import java.io.File; import java.io.File;
import java.lang.reflect.Field;
public abstract class Properties { public abstract class Properties {
public void addFlagMenuItem(JMenu menu, String fieldName) { public void addFlagMenuItem(JMenu menu, String fieldName) {
JMenuItem menu_item = new StableMenuItem(getFieldDescription(fieldName), JMenuItem menu_item = new StableMenuItem(getFieldDescription(fieldName),
@@ -46,4 +47,32 @@ public abstract class Properties {
//-- //--
public abstract String getFieldDescription(String fieldName); public abstract String getFieldDescription(String fieldName);
public abstract File getFile(); public abstract File getFile();
public boolean updateField(String name, Object newValue) {
try {
Field field = getClass().getField(name);
Object oldValue = field.get(Global.properties);
//---
if (newValue.equals(oldValue))
return false;
//--
field.set(this, newValue);
return true;
//--
} catch (Exception exception) {
exception.printStackTrace();
}
return false;
}
public void switchAndUpdateFlag(String name){
try {
Field field = getClass().getField(name);
boolean oldValue = (boolean) field.get(Global.properties);
boolean newValue = !oldValue;
//---
field.set(this, newValue);
//--
} catch (Exception exception) {
exception.printStackTrace();
}
}
} }

View File

@@ -1,5 +1,6 @@
package Common.UI.Menus_2023.TestingBar; package Common.UI.Menus_2023.TestingBar;
import Common.Current; import Common.Current;
import Common.Global;
import Common.UI.Menus_2023.MenuBarButton; import Common.UI.Menus_2023.MenuBarButton;
import Common.UI.Menus_2023.VisualiserMenuBar; import Common.UI.Menus_2023.VisualiserMenuBar;
import Common.UI.Themes.VisualiserFonts; import Common.UI.Themes.VisualiserFonts;
@@ -25,9 +26,10 @@ public class TestingBar extends VisualiserMenuBar {
add(sKernels = new JSpinner()); add(sKernels = new JSpinner());
sKernels.setPreferredSize(new Dimension(60, 26)); sKernels.setPreferredSize(new Dimension(60, 26));
sKernels.setMaximumSize(new Dimension(60, 26)); sKernels.setMaximumSize(new Dimension(60, 26));
sKernels.setModel(new SpinnerNumberModel(TestingServer.kernels, 1, 64, 1)); sKernels.setModel(new SpinnerNumberModel(Global.properties.TestingKernels, 1, 64, 1));
sKernels.setValue(Global.properties.TestingKernels);
UI.MakeSpinnerRapid(sKernels, e -> { UI.MakeSpinnerRapid(sKernels, e -> {
TestingServer.kernels = (int) sKernels.getValue(); Global.properties.updateField("TestingKernels", sKernels.getValue());
}); });
//-- //--
add(new MenuBarButton() { add(new MenuBarButton() {
@@ -36,14 +38,13 @@ public class TestingBar extends VisualiserMenuBar {
setToolTipText("Оповещение о прогрессе выполнения пакета тестов"); setToolTipText("Оповещение о прогрессе выполнения пакета тестов");
Mark(); Mark();
addActionListener(e -> { addActionListener(e -> {
TestingServer.email = !TestingServer.email; Global.properties.switchAndUpdateFlag("EmailOnTestingProgress");
Mark(); Mark();
}); });
} }
public void Mark() { public void Mark() {
setIcon(Utils.getIcon(TestingServer.email ? "/icons/Pick.png" : "/icons/NotPick.png")); setIcon(Utils.getIcon(Global.properties.EmailOnTestingProgress ? "/icons/Pick.png" : "/icons/NotPick.png"));
} }
}); });
//-- //--
add(autorefreshButton = new MenuBarButton() { add(autorefreshButton = new MenuBarButton() {
@@ -52,23 +53,29 @@ public class TestingBar extends VisualiserMenuBar {
setToolTipText("автоматическое обновление состояния пакета задач"); setToolTipText("автоматическое обновление состояния пакета задач");
Mark(); Mark();
addActionListener(e -> { addActionListener(e -> {
TestingServer.checkTasks = !TestingServer.checkTasks; Global.properties.switchAndUpdateFlag("AutoCheckTesting");
TestingServer.switchTimer(TestingServer.checkTasks); //-
if (Global.properties.AutoCheckTesting)
TestingServer.TimerOn();
else
TestingServer.TimerOff();
//-
Mark(); Mark();
}); });
} }
public void Mark() { public void Mark() {
setIcon(Utils.getIcon(TestingServer.checkTasks ? "/icons/Pick.png" : "/icons/NotPick.png")); setIcon(Utils.getIcon(Global.properties.AutoCheckTesting ? "/icons/Pick.png" : "/icons/NotPick.png"));
} }
}); });
//-- //--
add(sCheckTime = new JSpinner()); add(sCheckTime = new JSpinner());
sCheckTime.setPreferredSize(new Dimension(60, 26)); sCheckTime.setPreferredSize(new Dimension(60, 26));
sCheckTime.setMaximumSize(new Dimension(60, 26)); sCheckTime.setMaximumSize(new Dimension(60, 26));
sCheckTime.setModel(new SpinnerNumberModel(TestingServer.checkIntervalSecond, 10, 3600, 1)); sCheckTime.setModel(new SpinnerNumberModel(Global.properties.CheckTestingIntervalSeconds, 10, 3600, 1));
sCheckTime.setValue(Global.properties.CheckTestingIntervalSeconds);
UI.MakeSpinnerRapid(sCheckTime, e -> { UI.MakeSpinnerRapid(sCheckTime, e -> {
TestingServer.checkIntervalSecond = (int) sCheckTime.getValue(); Global.properties.updateField("CheckTestingIntervalSeconds", sCheckTime.getValue());
if (TestingServer.checkTasks) TestingServer.ResetTimer(); if (Global.properties.AutoCheckTesting) TestingServer.ResetTimer();
}); });
add(new JLabel(" сек ") { add(new JLabel(" сек ") {
{ {
@@ -76,7 +83,7 @@ public class TestingBar extends VisualiserMenuBar {
} }
}); });
} }
public void ShowAutorefresh() { public void ShowAutoCheckTesting() {
autorefreshButton.setIcon(Utils.getIcon(TestingServer.checkTasks ? "/icons/Pick.png" : "/icons/NotPick.png")); autorefreshButton.setIcon(Utils.getIcon(Global.properties.AutoCheckTesting ? "/icons/Pick.png" : "/icons/NotPick.png"));
} }
} }

View File

@@ -1,6 +1,7 @@
package GlobalData.Settings; package GlobalData.Settings;
public enum SettingName { public enum SettingName {
Undefined, Undefined,
//
//совместимость //совместимость
ConfirmPassesStart, ConfirmPassesStart,
ShowPassesDone, ShowPassesDone,
@@ -72,10 +73,6 @@ public enum SettingName {
} }
public String getDescription() { public String getDescription() {
switch (this) { switch (this) {
// case VersionsMultiSelection:
// return "Режим выбора версий";
// case FilesMultiSelection:
// return "Режим выбора файлов";
case SaveModifications: case SaveModifications:
return "Сохранять копию исходной версии при преобразованиях"; return "Сохранять копию исходной версии при преобразованиях";
case ComparsionDiffMergeOn: case ComparsionDiffMergeOn:

View File

@@ -145,6 +145,7 @@ public class TasksDatabase extends SQLiteDatabase {
return sum; return sum;
} }
//-- //--
/*
public Vector<TasksPackage> getActivePackages() { public Vector<TasksPackage> getActivePackages() {
Vector<TasksPackage> res = new Vector<>(); Vector<TasksPackage> res = new Vector<>();
for (TasksPackage p : packages.Data.values()) for (TasksPackage p : packages.Data.values())
@@ -159,6 +160,7 @@ public class TasksDatabase extends SQLiteDatabase {
res.add(p); res.add(p);
return res; return res;
} }
*/
public SapforTasksPackage getFirstActiveSapforPackage() { public SapforTasksPackage getFirstActiveSapforPackage() {
SapforTasksPackage first_active = null; SapforTasksPackage first_active = null;
SapforTasksPackage first_queued = null; SapforTasksPackage first_queued = null;
@@ -189,4 +191,15 @@ public class TasksDatabase extends SQLiteDatabase {
} }
return null; return null;
} }
public boolean hasActivePackages() {
for (TasksPackage tasksPackage : packages.Data.values()) {
if (tasksPackage.state.isActive())
return true;
}
for (SapforTasksPackage sapforTasksPackage : sapforTasksPackages.Data.values()) {
if (sapforTasksPackage.state.isActive())
return true;
}
return false;
}
} }

View File

@@ -23,8 +23,16 @@ public enum TasksPackageState implements StatusEnum {
//--------------------------------------- //---------------------------------------
Analysis, Analysis,
Done, Done,
Aborted Aborted;
; public boolean isActive() {
switch (this) {
case Done:
case Aborted:
return false;
default:
return true;
}
}
@Override @Override
public Font getFont() { public Font getFont() {
switch (this) { switch (this) {

View File

@@ -46,10 +46,6 @@ import java.util.stream.Collectors;
import static TestingSystem.TasksDatabase.tests_db_name; import static TestingSystem.TasksDatabase.tests_db_name;
public class TestingServer extends RepositoryServer<TestsDatabase> { public class TestingServer extends RepositoryServer<TestsDatabase> {
public static boolean email = false;
public static boolean checkTasks = false;
public static int checkIntervalSecond = 10;
public static int kernels = 4;
LinkedHashMap<String, TasksDatabase> accountsBases = new LinkedHashMap<>(); LinkedHashMap<String, TasksDatabase> accountsBases = new LinkedHashMap<>();
//--------------------------------->>> //--------------------------------->>>
public TestingServer() { public TestingServer() {
@@ -233,17 +229,10 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
protected TestingPlanner testingPlanner = new TestingPlanner(); protected TestingPlanner testingPlanner = new TestingPlanner();
protected Thread testingThread = new Thread(() -> testingPlanner.Perform()); protected Thread testingThread = new Thread(() -> testingPlanner.Perform());
//------>>> //------>>>
public static void switchTimer(boolean on) {
if (on)
TimerOn();
else
TimerOff();
}
public static Timer checkTimer = null; public static Timer checkTimer = null;
public static void TimerOn() { public static void TimerOn() {
checkTasks = true; System.out.println("timer on");
checkTimer = new Timer(checkIntervalSecond * 1000, e -> { checkTimer = new Timer(Global.properties.CheckTestingIntervalSeconds * 1000, e -> {
// Pass_2021.passes.get(PassCode_2021.ActualizePackages).Do();
Pass_2021.passes.get(PassCode_2021.SynchronizeTestsTasks).Do(); Pass_2021.passes.get(PassCode_2021.SynchronizeTestsTasks).Do();
}); });
checkTimer.start(); checkTimer.start();
@@ -252,7 +241,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
System.out.println("timer off"); System.out.println("timer off");
if (checkTimer != null) if (checkTimer != null)
checkTimer.stop(); checkTimer.stop();
checkTasks = false;
} }
public static void ResetTimer() { public static void ResetTimer() {
TimerOff(); TimerOff();

View File

@@ -1,85 +0,0 @@
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.UI.UI;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.TasksPackage.TasksPackage;
import TestingSystem.TasksPackage.TasksPackageState;
import TestingSystem.TestingServer;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.TestingSystemPass;
import javafx.util.Pair;
import java.util.Vector;
public class ActualizePackages extends TestingSystemPass<Object> {
boolean needsSynchronize;
Vector<TasksPackage> dvmPackages;
Vector<SapforTasksPackage> spfPackages;
@Override
protected void ServerAction() throws Exception {
for (TasksPackage p : dvmPackages) {
TasksPackageState oldState = p.state;
Command(new ServerExchangeUnit_2021(ServerCode.GetAccountObjectCopyByPK, Current.getAccount().email, new Pair<>(TasksPackage.class, p.id)));
TasksPackage actual_package = (TasksPackage) response.object;
//-
p.SynchronizeFields(actual_package);
if (!oldState.equals(p.state) && p.state.equals(TasksPackageState.Done))
needsSynchronize = true; //состояние изменилось, и на Done значит нужно скачивать задачи.
server.account_db.Update(p);
}
//---
for (SapforTasksPackage p : spfPackages) {
TasksPackageState oldState = p.state;
Command(new ServerExchangeUnit_2021(ServerCode.GetAccountObjectCopyByPK, Current.getAccount().email, new Pair<>(SapforTasksPackage.class, p.id)));
SapforTasksPackage actual_package = (SapforTasksPackage) response.object;
//-
p.SynchronizeFields(actual_package);
if (!oldState.equals(p.state) && p.state.equals(TasksPackageState.Done))
needsSynchronize = true; //состояние изменилось, и на Done значит нужно скачивать задачи.
server.account_db.Update(p);
}
}
@Override
protected boolean needsAnimation() {
return false;
}
@Override
protected boolean canStart(Object... args) throws Exception {
needsSynchronize = false;
dvmPackages = server.account_db.getActivePackages();
spfPackages = server.account_db.getActiveSapforPackages();
return !dvmPackages.isEmpty() || !spfPackages.isEmpty();
}
@Override
protected void performCanNotStart() throws Exception {
TestingServer.TimerOff();
}
@Override
protected void showCanNotStart() throws Exception {
UI.getMainWindow().getTestingWindow().ShowAutoActualizeTestsState();
}
@Override
protected void performPreparation() throws Exception {
server.account_db.SaveLastSelections();
}
@Override
protected void showPreparation() throws Exception {
server.account_db.packages.ClearUI();
server.account_db.sapforTasksPackages.ClearUI();
}
@Override
protected void showDone() throws Exception {
server.account_db.packages.ShowUI();
server.account_db.sapforTasksPackages.ShowUI();
//--->>
if (!TestingServer.checkTasks) UI.getMainWindow().getTestingWindow().ShowAutoActualizeTestsState();
server.account_db.RestoreLastSelections();
}
@Override
protected void performDone() throws Exception {
super.performDone();
if (needsSynchronize)
passes.get(PassCode_2021.SynchronizeTestsTasks).Do();
}
}

View File

@@ -10,7 +10,6 @@ import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.Group.Group; import TestingSystem.Group.Group;
import TestingSystem.Test.ProjectFiles_json; import TestingSystem.Test.ProjectFiles_json;
import TestingSystem.Test.Test; import TestingSystem.Test.Test;
import TestingSystem.TestingServer;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.PassException; import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.TestingSystemPass; import Visual_DVM_2021.Passes.TestingSystemPass;
@@ -45,12 +44,10 @@ public class ConvertCorrectnessTests extends TestingSystemPass<File> {
passes.get(PassCode_2021.CloseCurrentProject); passes.get(PassCode_2021.CloseCurrentProject);
Current.set(Current.Root, null); Current.set(Current.Root, null);
Current.set(Current.Version, null); Current.set(Current.Version, null);
if (TestingServer.checkTasks)
TestingServer.TimerOff();
} }
@Override @Override
protected void showPreparation() throws Exception { protected void showPreparation() throws Exception {
UI.getMainWindow().getTestingWindow().ShowAutoActualizeTestsState(); UI.testingBar.ShowAutoCheckTesting();
} }
@Override @Override
protected void ServerAction() throws Exception { protected void ServerAction() throws Exception {

View File

@@ -7,7 +7,6 @@ import ProjectData.Project.db_project_info;
import TestingSystem.Group.Group; import TestingSystem.Group.Group;
import TestingSystem.Test.Test; import TestingSystem.Test.Test;
import TestingSystem.Test.TestType; import TestingSystem.Test.TestType;
import TestingSystem.TestingServer;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021; import Visual_DVM_2021.Passes.Pass_2021;
@@ -61,13 +60,11 @@ public class CreateTestsGroupFromSelectedVersions extends Pass_2021<Vector<db_pr
} }
@Override @Override
protected void performPreparation() throws Exception { protected void performPreparation() throws Exception {
if (TestingServer.checkTasks)
TestingServer.TimerOff();
passes.get(PassCode_2021.CloseCurrentProject).Do(); passes.get(PassCode_2021.CloseCurrentProject).Do();
} }
@Override @Override
protected void showPreparation() throws Exception { protected void showPreparation() throws Exception {
UI.getMainWindow().getTestingWindow().ShowAutoActualizeTestsState(); UI.testingBar.ShowAutoCheckTesting();
} }
@Override @Override
protected void body() throws Exception { protected void body() throws Exception {

View File

@@ -13,7 +13,6 @@ import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.Group.Group; import TestingSystem.Group.Group;
import TestingSystem.TasksPackage.TasksPackageState; import TestingSystem.TasksPackage.TasksPackageState;
import TestingSystem.Test.Test; import TestingSystem.Test.Test;
import TestingSystem.TestingServer;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.TestingSystemPass; import Visual_DVM_2021.Passes.TestingSystemPass;
@@ -223,9 +222,9 @@ public class StartSapforTests extends TestingSystemPass<SapforTasksPackage> {
//-- //--
target.testsNames = String.join(";", testsNames_lower); target.testsNames = String.join(";", testsNames_lower);
target.StartDate = new Date().getTime(); target.StartDate = new Date().getTime();
target.kernels = TestingServer.kernels; target.kernels = Global.properties.TestingKernels;
target.state = TasksPackageState.Queued; target.state = TasksPackageState.Queued;
target.needsEmail = TestingServer.email ? 1 : 0; target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
//--- //---
Vector<SapforTasksPackage> packages = new Vector<>(); Vector<SapforTasksPackage> packages = new Vector<>();
packages.add(target); packages.add(target);

View File

@@ -1,5 +1,6 @@
package Visual_DVM_2021.Passes.All; package Visual_DVM_2021.Passes.All;
import Common.Current; import Common.Current;
import Common.Global;
import Common.UI.UI; import Common.UI.UI;
import GlobalData.Compiler.CompilerType; import GlobalData.Compiler.CompilerType;
import GlobalData.Machine.MachineType; import GlobalData.Machine.MachineType;
@@ -13,7 +14,6 @@ import TestingSystem.Tasks.TestCompilationTask;
import TestingSystem.Tasks.TestRunTask; import TestingSystem.Tasks.TestRunTask;
import TestingSystem.TasksPackage.TasksPackage; import TestingSystem.TasksPackage.TasksPackage;
import TestingSystem.Test.Test; import TestingSystem.Test.Test;
import TestingSystem.TestingServer;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.TestingSystemPass; import Visual_DVM_2021.Passes.TestingSystemPass;
@@ -135,7 +135,7 @@ public class StartTests extends TestingSystemPass<TasksPackage> {
target.user_workspace = Current.getUser().workspace; target.user_workspace = Current.getUser().workspace;
target.dvm_drv = Current.getCompiler().call_command; target.dvm_drv = Current.getCompiler().call_command;
target.dvm_version = Current.getCompiler().getVersionInfo(); target.dvm_version = Current.getCompiler().getVersionInfo();
target.kernels = TestingServer.kernels; target.kernels = Global.properties.TestingKernels;
Vector<TestCompilationTask> tasks = new Vector<>(); Vector<TestCompilationTask> tasks = new Vector<>();
//1, Проверяем выбраны ли конфиги. //1, Проверяем выбраны ли конфиги.
if (server.db.configurations.getCheckedCount() == 0) { if (server.db.configurations.getCheckedCount() == 0) {
@@ -200,7 +200,7 @@ public class StartTests extends TestingSystemPass<TasksPackage> {
"Задач на компиляцию: " + target.compilationTasksCount + "\n" + "Задач на компиляцию: " + target.compilationTasksCount + "\n" +
"Задач на запуск: " + target.runTasksCount + "\n" + "Задач на запуск: " + target.runTasksCount + "\n" +
String.join("\n", summary_lines); String.join("\n", summary_lines);
target.needsEmail = TestingServer.email ? 1 : 0; target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
return !tasks.isEmpty(); return !tasks.isEmpty();
} }
@Override @Override

View File

@@ -1,20 +1,42 @@
package Visual_DVM_2021.Passes.All; package Visual_DVM_2021.Passes.All;
import Common.Current; import Common.Current;
import Common.Global;
import Common.UI.UI; import Common.UI.UI;
import Common.Utils.Utils; import Common.Utils.Utils;
import Repository.Server.ServerCode; import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021; import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.TestingServer; import TestingSystem.TestingServer;
import Visual_DVM_2021.Passes.Pass_2021;
import Visual_DVM_2021.Passes.TestingSystemPass; import Visual_DVM_2021.Passes.TestingSystemPass;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.util.Vector; public class SynchronizeTestsTasks extends Pass_2021 {
public class SynchronizeTestsTasks extends TestingSystemPass<Vector<Integer>> { byte[] db_file_bytes;
File new_db_file; File new_db_file;
@Override @Override
protected boolean canStart(Object... args) throws Exception { protected boolean canStart(Object... args) throws Exception {
return Current.getAccount().CheckRegistered(Log); db_file_bytes = null;
new_db_file = null;
if (Current.getAccount().CheckRegistered(Log)) {
TestingSystemPass download = new TestingSystemPass() {
@Override
protected boolean needsAnimation() {
return false;
}
@Override
public String getDescription() {
return "Загрузка базы тестовых задач";
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.ReceiveTestsTasksDatabase, Current.getAccount().email));
db_file_bytes = (byte[]) response.object;
}
};
return download.Do();
}
return false;
} }
@Override @Override
protected boolean needsAnimation() { protected boolean needsAnimation() {
@@ -30,37 +52,42 @@ public class SynchronizeTestsTasks extends TestingSystemPass<Vector<Integer>> {
} }
@Override @Override
protected void performPreparation() throws Exception { protected void performPreparation() throws Exception {
server.account_db.Disconnect(); Global.testingServer.account_db.Disconnect();
} }
@Override @Override
protected void showPreparation() throws Exception { protected void showPreparation() throws Exception {
server.account_db.packages.ClearUI(); Global.testingServer.account_db.packages.ClearUI();
server.account_db.sapforTasksPackages.ClearUI(); Global.testingServer.account_db.sapforTasksPackages.ClearUI();
} }
@Override @Override
protected void ServerAction() throws Exception { protected void body() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.ReceiveTestsTasksDatabase, Current.getAccount().email)); Utils.unpackFile(db_file_bytes, new_db_file = Utils.getTempFileName("tdb"));
response.Unpack(new_db_file = Utils.getTempFileName("tdb"));
if (new_db_file.exists()) { if (new_db_file.exists()) {
Utils.forceDeleteWithCheck(server.account_db.getFile()); Utils.forceDeleteWithCheck(Global.testingServer.account_db.getFile());
FileUtils.moveFile(new_db_file, server.account_db.getFile()); FileUtils.moveFile(new_db_file, Global.testingServer.account_db.getFile());
server.account_db.setFile(Current.getAccount().email); Global.testingServer.account_db.setFile(Current.getAccount().email);
} }
server.account_db.Connect(); //--
server.account_db.CreateAllTables(); Global.testingServer.account_db.Connect();
server.account_db.prepareTablesStatements(); Global.testingServer.account_db.CreateAllTables();
server.account_db.Synchronize(); Global.testingServer.account_db.prepareTablesStatements();
Global.testingServer.account_db.Synchronize();
UI.getMainWindow().getTestingWindow().RemountTestTable(); UI.getMainWindow().getTestingWindow().RemountTestTable();
//--
} }
@Override @Override
protected boolean validate() { protected boolean validate() {
return (response.object != null); return (db_file_bytes != null);
} }
@Override @Override
protected void showDone() throws Exception { protected void showFinish() throws Exception {
server.account_db.packages.ShowUI(); Global.testingServer.account_db.packages.ShowUI();
server.account_db.sapforTasksPackages.ShowUI(); Global.testingServer.account_db.sapforTasksPackages.ShowUI();
if (!TestingServer.checkTasks) UI.getMainWindow().getTestingWindow().ShowAutoActualizeTestsState(); if (!Global.testingServer.account_db.hasActivePackages()) {
Global.properties.updateField("AutoCheckTesting", false);
TestingServer.TimerOff();
UI.testingBar.ShowAutoCheckTesting();
}
} }
} }

View File

@@ -0,0 +1,28 @@
package Visual_DVM_2021.Passes.All;
import Common.Global;
import Common.GlobalProperties;
import Visual_DVM_2021.Passes.Pass_2021;
import java.lang.reflect.Field;
public class UpdateProperty extends Pass_2021<Object> {
//todo в дальнейшем, все настройки перевести в properties, и перенести сюда функционал UpdateSetting (?)
String name = "";
Field field = null;
Object oldValue = null;
Object newValue = null;
@Override
protected boolean canStart(Object... args) throws Exception {
name = (String) args[0];
newValue = args[1];
//--
field = GlobalProperties.class.getField(name);
oldValue = field.get(Global.properties);
//---
return !newValue.equals(oldValue);
}
@Override
protected void body() throws Exception {
field.set(Global.properties, newValue);
Global.properties.Update();
}
}

View File

@@ -16,16 +16,13 @@ import Visual_DVM_2021.Passes.Pass_2021;
import javax.swing.*; import javax.swing.*;
import java.io.File; import java.io.File;
public class UpdateSetting extends Pass_2021<DBSetting> { public class UpdateSetting extends Pass_2021<DBSetting> {
String NewValue; String NewValue;
VDirectoryChooser directoryChooser = new VDirectoryChooser(""); VDirectoryChooser directoryChooser = new VDirectoryChooser("");
VFileChooser fileChooser = new VFileChooser("", "exe"); VFileChooser fileChooser = new VFileChooser("", "exe");
boolean silent;
@Override @Override
protected boolean canStart(Object... args) throws Exception { protected boolean canStart(Object... args) throws Exception {
target = Global.db.settings.get(args[0]); target = Global.db.settings.get(args[0]);
NewValue = target.Value; NewValue = target.Value;
silent = false;
if (args.length == 1) { if (args.length == 1) {
//интерфейсный режим. получение по клику на пункт меню. //интерфейсный режим. получение по клику на пункт меню.
switch (target.settingType) { switch (target.settingType) {
@@ -101,11 +98,8 @@ public class UpdateSetting extends Pass_2021<DBSetting> {
} }
} else { } else {
NewValue = args[1].toString(); NewValue = args[1].toString();
silent = true;
} }
//программный, тихий режим.} //программный, тихий режим.}
//--
System.out.println(target.Value + "/" + NewValue);
return !NewValue.equals(target.Value); return !NewValue.equals(target.Value);
} }
@Override @Override

View File

@@ -2,6 +2,7 @@ package Visual_DVM_2021.Passes;
public enum PassCode_2021 { public enum PassCode_2021 {
Undefined, Undefined,
//- //-
UpdateProperty,
ShowAllParallelVariants, ShowAllParallelVariants,
ShowParallelVariantsCoverage, ShowParallelVariantsCoverage,
AbortSapforTaskPackage, AbortSapforTaskPackage,
@@ -269,7 +270,6 @@ public enum PassCode_2021 {
DownloadTaskTest, DownloadTaskTest,
//- //-
GetTestsQueueSize, GetTestsQueueSize,
ActualizePackages,
AbortSelectedPackages, AbortSelectedPackages,
ApplyCurrentFunction, ApplyCurrentFunction,
//-> //->
@@ -314,6 +314,8 @@ public enum PassCode_2021 {
switch (this) { switch (this) {
case Undefined: case Undefined:
return "?"; return "?";
case UpdateProperty:
return "Обновить параметр";
case OpenSapforEtalonVersion: case OpenSapforEtalonVersion:
return "Открыть текущую эталонную версию SAPFOR как проект"; return "Открыть текущую эталонную версию SAPFOR как проект";
case OpenSapforVersion: case OpenSapforVersion:
@@ -438,8 +440,6 @@ public enum PassCode_2021 {
return "Прерывать отмеченные пакеты задач"; return "Прерывать отмеченные пакеты задач";
case GetTestsQueueSize: case GetTestsQueueSize:
return "Очередь перед текущим пакетом"; return "Очередь перед текущим пакетом";
case ActualizePackages:
return "Обновить текущий пакет задач";
case DownloadTaskTest: case DownloadTaskTest:
return "Загрузить тест текущей задачи"; return "Загрузить тест текущей задачи";
case CopyGroups: case CopyGroups:

View File

@@ -244,7 +244,7 @@ public class Pass_2021<T> {
Vector<String> ToPrint = new Vector<>(); Vector<String> ToPrint = new Vector<>();
createStack_r(ToDo, ToPrint); createStack_r(ToDo, ToPrint);
if (Global.properties.ConfirmPassesStart && !ToPrint.isEmpty() && if (Global.properties.ConfirmPassesStart && !ToPrint.isEmpty() &&
!UI.Question("Выполнить проход(ы):\n" + String.join("\n", ToPrint))//, SettingName.ConfirmPassesStart) !UI.Question("Выполнить проход(ы):\n" + String.join("\n", ToPrint))
) return false; ) return false;
while (ToDo.size() > 1) { while (ToDo.size() > 1) {
if (!ToDo.pop().start()) return false; if (!ToDo.pop().start()) return false;

View File

@@ -10,7 +10,7 @@ public interface TestingWindow extends VisualizerForm {
//- //-
void RefreshTabsNames(); void RefreshTabsNames();
void FocusTestingSystem(); void FocusTestingSystem();
void ShowAutoActualizeTestsState();
void RemountTestTable(); void RemountTestTable();
//- //-
void FocusTestingTasks(); void FocusTestingTasks();

View File

@@ -103,6 +103,7 @@ public class TestingForm implements FormWithSplitters, TestingWindow {
Global.testingServer.db.serverSapfors.ShowUI(); Global.testingServer.db.serverSapfors.ShowUI();
Global.testingServer.db.sapforConfigurations.ShowUI(); Global.testingServer.db.sapforConfigurations.ShowUI();
Global.testingServer.account_db.sapforTasksPackages.ShowUI(); Global.testingServer.account_db.sapforTasksPackages.ShowUI();
//---
} }
//- //-
@Override @Override
@@ -143,10 +144,6 @@ public class TestingForm implements FormWithSplitters, TestingWindow {
testingTabs.setSelectedIndex(2); testingTabs.setSelectedIndex(2);
} }
@Override @Override
public void ShowAutoActualizeTestsState() {
UI.testingBar.ShowAutorefresh();
}
@Override
public void FocusTestingTasks() { public void FocusTestingTasks() {
} }
@Override @Override