начал перестройку под бд пользователя.
This commit is contained in:
194
src/Visual_DVM_2021/Passes/All/StartSapforTests.java
Normal file
194
src/Visual_DVM_2021/Passes/All/StartSapforTests.java
Normal file
@@ -0,0 +1,194 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import ProjectData.LanguageName;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import SapforTestingSystem.SapforTasksPackage_info;
|
||||
import SapforTestingSystem.SapforConfiguration.SapforConfiguration;
|
||||
import SapforTestingSystem.SapforConfigurationCommand.SapforConfigurationCommand;
|
||||
import TestingSystem.Group.Group;
|
||||
import TestingSystem.Test.Test;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.TestingSystemPass;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class StartSapforTests extends TestingSystemPass<SapforTasksPackage_info> {
|
||||
protected int allTasksCount = 0;
|
||||
//--
|
||||
protected LinkedHashMap<String, Vector<String>> groupsTests = null;
|
||||
//--
|
||||
protected LinkedHashMap<String, Test> allTests = null;
|
||||
protected Vector<String> testsNames_lower = null; //все тесты что участвуют здесь
|
||||
protected Vector<LanguageName> groupsLanguages = null;
|
||||
protected File sapfor = null;
|
||||
//---
|
||||
//---
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Start.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
}
|
||||
//--
|
||||
protected boolean checkTestName(Test test) {
|
||||
String name = test.description.toLowerCase();
|
||||
if (testsNames_lower.contains(name)) {
|
||||
Log.Writeln_("В пакет не могут входить тесты с одинаковыми именами (без учета регистра):" + test.description.toLowerCase());
|
||||
return false;
|
||||
}
|
||||
testsNames_lower.add(name);
|
||||
return true;
|
||||
}
|
||||
protected boolean getGroupTests(String groupId) {
|
||||
Vector<String> groupTests = new Vector<>();
|
||||
Vector<String> selectedGroupTests = new Vector<>();
|
||||
//---
|
||||
for (Test test : Global.testingServer.db.tests.Data.values()) {
|
||||
if (test.group_id.equals(groupId)) {
|
||||
groupTests.add(test.id);
|
||||
if (test.isSelected())
|
||||
selectedGroupTests.add(test.id);
|
||||
}
|
||||
}
|
||||
if (!groupTests.isEmpty() && !selectedGroupTests.isEmpty())
|
||||
groupTests = selectedGroupTests;
|
||||
//---
|
||||
if (groupTests.isEmpty()) {
|
||||
Log.Writeln_("Пустая группа тестов: " + groupId);
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
for (String testId : groupTests) {
|
||||
Test test = Global.testingServer.db.tests.get(testId);
|
||||
if (!checkTestName(test))
|
||||
return false;
|
||||
else
|
||||
allTests.put(test.description, test);
|
||||
}
|
||||
//--
|
||||
groupsTests.put(groupId, groupTests);
|
||||
//--
|
||||
return true;
|
||||
}
|
||||
public boolean getConfigurationCommands(SapforConfiguration sapforConfiguration) {
|
||||
//1. получить список всех команд.
|
||||
Vector<PassCode_2021> codes = new Vector<>();
|
||||
int v = 0;
|
||||
for (SapforConfigurationCommand command : Global.testingServer.db.sapforConfigurationCommands.Data.values()) {
|
||||
if (command.sapforconfiguration_id.equals(sapforConfiguration.id)) {
|
||||
codes.add(command.passCode);
|
||||
if (command.passCode.equals(PassCode_2021.CreateParallelVariants))
|
||||
v++;
|
||||
}
|
||||
}
|
||||
//--
|
||||
if (codes.size() == 0) {
|
||||
Log.Writeln_("Пустая конфигурация:" + sapforConfiguration.id);
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
if (v > 2) {
|
||||
Log.Writeln_("Неверная конфигурация:" + sapforConfiguration.id + ": построение параллельных вариантов возможно единожды.");
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
if ((v == 1) && codes.size() > 1) {
|
||||
if (!codes.lastElement().equals(PassCode_2021.CreateParallelVariants)) {
|
||||
Log.Writeln_("Неверная конфигурация:" + sapforConfiguration.id + ": построение параллельных вариантов может быть только завершающей командой!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
//--
|
||||
allTasksCount = 0;
|
||||
target = null;
|
||||
//--
|
||||
groupsTests = new LinkedHashMap<>();
|
||||
//--->>
|
||||
testsNames_lower = new Vector<>();
|
||||
allTests = new LinkedHashMap<>();
|
||||
groupsLanguages = new Vector<>();
|
||||
//-->>
|
||||
if (!Current.getAccount().CheckRegistered(Log)) {
|
||||
return false;
|
||||
}
|
||||
//проверка стартовых условий.
|
||||
if (!Current.Check(Log, Current.ServerSapfor))
|
||||
return false;
|
||||
//--->>
|
||||
if (Global.testingServer.db.sapforConfigurations.getCheckedCount() == 0) {
|
||||
Log.Writeln_("Не отмечено ни одной конфигурации SAPFOR.");
|
||||
return false;
|
||||
}
|
||||
//-
|
||||
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems()) {
|
||||
if (!getConfigurationCommands(configuration))
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
if (Global.testingServer.db.groups.getCheckedCount() == 0) {
|
||||
Log.Writeln_("Не отмечено ни одной группы тестов");
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
for (Group group : Global.testingServer.db.groups.getCheckedItems()) {
|
||||
//---
|
||||
if (!groupsLanguages.contains(group.language))
|
||||
groupsLanguages.add(group.language);
|
||||
//-
|
||||
if (groupsLanguages.get(0) != LanguageName.fortran) {
|
||||
Log.Writeln_("Поддерживается пакетный режим только для языка Fortran!");
|
||||
return false;
|
||||
}
|
||||
if (groupsLanguages.size() > 1) {
|
||||
Log.Writeln_("Запуск тестов на разных языках в рамках одного пакета запрещен!");
|
||||
return false;
|
||||
}
|
||||
//---
|
||||
if (!getGroupTests(group.id))
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
for (int i = 0; i < Global.testingServer.db.sapforConfigurations.getCheckedCount(); ++i) {
|
||||
for (Vector<String> tests : groupsTests.values())
|
||||
allTasksCount += tests.size();
|
||||
}
|
||||
//--
|
||||
return (UI.Question("Будет запущено:\n"
|
||||
+ allTasksCount + " задач\n" +
|
||||
"Продолжить"));
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
target = new SapforTasksPackage_info();
|
||||
target.email = Current.getAccount().email;
|
||||
target.sapforId = Current.getServerSapfor().id;
|
||||
for (Test test : allTests.values())
|
||||
target.testsIds.add(test.id);
|
||||
//--
|
||||
ShowMessage1("Создание рабочих пространств...");
|
||||
for (SapforConfiguration configuration : Global.testingServer.db.sapforConfigurations.getCheckedItems())
|
||||
target.configurationsIds.add(configuration.id);
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.StartSapforTests, "", target));
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
super.performFinish();
|
||||
//passes.get(PassCode_2021.SynchronizeTests).Do();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user