v++
This commit is contained in:
2023-12-31 17:36:20 +03:00
parent b4184d9361
commit 5baf2154e2
9 changed files with 296 additions and 74 deletions

10
.idea/workspace.xml generated
View File

@@ -7,8 +7,16 @@
</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/CloneSapforPackage.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PublishSapforConfigurationCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PublishSapforConfigurationCommand.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Component/Visualiser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Component/Visualiser.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/Group/GroupsDBTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/Group/GroupsDBTable.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/Test/TestDBTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/Test/TestDBTable.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforPackage/SapforPackagesBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/SAPFOR/SapforPackage/SapforPackagesBar.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CloneDVMPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CloneDVMPackage.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" />
</list> </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" />

View File

@@ -62,7 +62,7 @@ public class Visualiser extends Component {
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html //http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
@Override @Override
public void GetVersionInfo() { public void GetVersionInfo() {
version = 1061; version = 1062;
String pattern = "MMM dd yyyy HH:mm:ss"; String pattern = "MMM dd yyyy HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH); DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
date_text = df.format(getClassBuildTime()); date_text = df.format(getClassBuildTime());

View File

@@ -125,4 +125,18 @@ public class GroupsDBTable extends iDBTable<Group> {
} }
}; };
} }
public boolean containsGroupWithDescription(String description_in) {
for (Group group : Data.values()) {
if (group.description.equalsIgnoreCase(description_in))
return true;
}
return false;
}
public Group getGroupByDescription(String description_in) {
for (Group group : Data.values()) {
if (group.description.equalsIgnoreCase(description_in))
return group;
}
return null;
}
} }

View File

@@ -93,4 +93,18 @@ public class TestDBTable extends iDBTable<Test> {
} }
}; };
} }
public boolean containsTestWithDescription(String description_in) {
for (Test test : Data.values()) {
if (test.description.equalsIgnoreCase(description_in))
return true;
}
return false;
}
public Test getTestByDescription(String description_in) {
for (Test test : Data.values()) {
if (test.description.equalsIgnoreCase(description_in))
return test;
}
return null;
}
} }

View File

@@ -37,6 +37,22 @@ import java.util.Comparator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Vector; import java.util.Vector;
public class TestingServer extends RepositoryServer<TestsDatabase> { public class TestingServer extends RepositoryServer<TestsDatabase> {
/*
@Override
protected void beforePublishAction(DBObject object) throws Exception {
if (object instanceof Group) {
Group group = (Group) object;
if (db.groups.containsGroupWithDescription(group.description))
throw new RepositoryRefuseException("Уже существует группа с описанием " +
Utils.Brackets(group.description.toLowerCase()));
} else if (object instanceof Test) {
Test test = (Test) object;
if (db.tests.containsTestWithDescription(test.description))
throw new RepositoryRefuseException("Уже существует тест с описанием " +
Utils.Brackets(test.description.toLowerCase()));
}
}
*/
@Override @Override
public void afterPublishAction(DBObject object) throws Exception { public void afterPublishAction(DBObject object) throws Exception {
if (object instanceof Test) { if (object instanceof Test) {

View File

@@ -7,6 +7,7 @@ public class SapforPackagesBar extends DataMenuBar {
PassCode_2021.SynchronizeTests, PassCode_2021.SynchronizeTests,
PassCode_2021.AddSapforPackage, PassCode_2021.AddSapforPackage,
PassCode_2021.AddTasksToSapforPackage, PassCode_2021.AddTasksToSapforPackage,
PassCode_2021.CloneSapforPackage,
PassCode_2021.StartSapforPackage, PassCode_2021.StartSapforPackage,
PassCode_2021.AbortSapforPackage, PassCode_2021.AbortSapforPackage,
PassCode_2021.DeleteSapforPackage PassCode_2021.DeleteSapforPackage

View File

@@ -3,6 +3,7 @@ import Common.Constants;
import Common.Current; import Common.Current;
import Common.Database.Database; import Common.Database.Database;
import Common.Global; import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils; import Common.Utils.Utils;
import GlobalData.Compiler.CompilerType; import GlobalData.Compiler.CompilerType;
import GlobalData.Machine.MachineType; import GlobalData.Machine.MachineType;
@@ -18,6 +19,8 @@ import TestingSystem.DVM.DVMTasks.DVMCompilationTask;
import TestingSystem.DVM.DVMTasks.DVMRunTask; import TestingSystem.DVM.DVMTasks.DVMRunTask;
import Visual_DVM_2021.Passes.AddObjectPass; import Visual_DVM_2021.Passes.AddObjectPass;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import java.util.Vector;
public class CloneDVMPackage extends AddObjectPass<DVMPackage> { public class CloneDVMPackage extends AddObjectPass<DVMPackage> {
DVMPackage src; DVMPackage src;
public CloneDVMPackage() { public CloneDVMPackage() {
@@ -92,83 +95,89 @@ public class CloneDVMPackage extends AddObjectPass<DVMPackage> {
//-- //--
target.tasksCount = 0; target.tasksCount = 0;
//-- //--
return true; src.readJson();
target.package_json = new DVMPackage_json();
//--
Vector<String> inexistingTests = new Vector<>();
//--
for (DVMCompilationTask src_compilationTask : src.package_json.compilationTasks) {
if (Global.testingServer.db.tests.containsKey(src_compilationTask.test_id)
) {
Group group = Global.testingServer.db.groups.get(src_compilationTask.group_id);
Test test = Global.testingServer.db.tests.get(src_compilationTask.test_id);
//--
DVMCompilationTask compilationTask = new DVMCompilationTask();
//--
compilationTask.group_id = group.id;
compilationTask.group_description = group.description;
compilationTask.language = src_compilationTask.language;
//--
compilationTask.test_id = test.id;
compilationTask.test_description = test.description;
compilationTask.test_type = group.type;
//--
compilationTask.maxtime = src_compilationTask.maxtime;
//--
compilationTask.flags = src_compilationTask.flags;
compilationTask.kernels = 1;
//---
for (DVMRunTask src_runTask : src_compilationTask.runTasks) {
DVMRunTask runTask = new DVMRunTask();
//--
runTask.group_id = group.id;
runTask.group_description = group.description;
runTask.language = src_runTask.language;
//--
runTask.test_id = test.id;
runTask.test_description = test.description;
runTask.test_type = group.type;
//--
runTask.compilation_maxtime = src_runTask.compilation_maxtime;
runTask.compilation_state = TaskState.Waiting;
runTask.maxtime = src_runTask.maxtime;
//--
runTask.cube = src_runTask.cube;
runTask.min_dim = src_runTask.min_dim;
runTask.max_dim = src_runTask.max_dim;
runTask.matrix = src_runTask.matrix;
runTask.environments = src_runTask.environments;
runTask.usr_par = src_runTask.usr_par;
runTask.args = test.args;
//--
runTask.flags = src_runTask.flags;
runTask.kernels = (group.type == TestType.Performance) ? target.kernels :
Math.min(Utils.getMatrixProcessors(src_runTask.matrix), target.kernels);
compilationTask.runTasks.add(runTask);
}
//--
target.package_json.compilationTasks.add(compilationTask);
//-
} else {
inexistingTests.add(String.valueOf(src_compilationTask.test_id));
}
}
///-
//инициализируем идентификаторы задач.
for (DVMCompilationTask compilationTask : target.package_json.compilationTasks) {
//--
compilationTask.id = target.package_json.getMaxTaskId();
//-
for (DVMRunTask runTask : compilationTask.runTasks) {
runTask.id = target.package_json.getMaxTaskId();
runTask.dvmcompilationtask_id = compilationTask.id;
target.tasksCount++;
}
}
//--
for (String test_id: inexistingTests){
System.out.println("Тест "+test_id+" не найден!");
}
return inexistingTests.isEmpty()|| UI.Question(inexistingTests.size()+ " тестов отсутствует. Продолжить");
} }
return false; return false;
} }
@Override @Override
protected void body() throws Exception { protected void body() throws Exception {
// надо скопировать все задачи.
src.readJson();
target.package_json = new DVMPackage_json();
//--
for (DVMCompilationTask src_compilationTask : src.package_json.compilationTasks) {
if (Global.testingServer.db.groups.containsKey(src_compilationTask.group_id) &&
Global.testingServer.db.tests.containsKey(src_compilationTask.test_id)
) {
Group group = Global.testingServer.db.groups.get(src_compilationTask.group_id);
Test test = Global.testingServer.db.tests.get(src_compilationTask.test_id);
//--
DVMCompilationTask compilationTask = new DVMCompilationTask();
//--
compilationTask.group_id = group.id;
compilationTask.group_description = group.description;
compilationTask.language = src_compilationTask.language;
//--
compilationTask.test_id = test.id;
compilationTask.test_description = test.description;
compilationTask.test_type = group.type;
//--
compilationTask.maxtime = src_compilationTask.maxtime;
//--
compilationTask.flags = src_compilationTask.flags;
compilationTask.kernels = 1;
//---
for (DVMRunTask src_runTask : src_compilationTask.runTasks) {
DVMRunTask runTask = new DVMRunTask();
//--
runTask.group_id = group.id;
runTask.group_description = group.description;
runTask.language = src_runTask.language;
//--
runTask.test_id = test.id;
runTask.test_description = test.description;
runTask.test_type = group.type;
//--
runTask.compilation_maxtime = src_runTask.compilation_maxtime;
runTask.compilation_state = TaskState.Waiting;
runTask.maxtime = src_runTask.maxtime;
//--
runTask.cube = src_runTask.cube;
runTask.min_dim = src_runTask.min_dim;
runTask.max_dim = src_runTask.max_dim;
runTask.matrix = src_runTask.matrix;
runTask.environments = src_runTask.environments;
runTask.usr_par = src_runTask.usr_par;
runTask.args = test.args;
//--
runTask.flags = src_runTask.flags;
runTask.kernels = (group.type == TestType.Performance) ? target.kernels :
Math.min(Utils.getMatrixProcessors(src_runTask.matrix), target.kernels);
compilationTask.runTasks.add(runTask);
}
//--
target.package_json.compilationTasks.add(compilationTask);
//-
}
}
///-
//инициализируем идентификаторы задач.
for (DVMCompilationTask compilationTask : target.package_json.compilationTasks) {
//--
compilationTask.id = target.package_json.getMaxTaskId();
//-
for (DVMRunTask runTask : compilationTask.runTasks) {
runTask.id = target.package_json.getMaxTaskId();
runTask.dvmcompilationtask_id = compilationTask.id;
target.tasksCount++;
}
}
//черновик не вставляется в бд. идет только как элемент списка. //черновик не вставляется в бд. идет только как элемент списка.
Global.testingServer.db.dvmPackages.Data.put(target.id, target); Global.testingServer.db.dvmPackages.Data.put(target.id, target);
} }

View File

@@ -0,0 +1,157 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants;
import Common.Current;
import Common.Database.Database;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.TasksPackageState;
import TestingSystem.Common.Test.Test;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.Json.SapforPackage_json;
import TestingSystem.SAPFOR.Json.SapforTest_json;
import TestingSystem.SAPFOR.Json.SapforTestingSet_json;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
import Visual_DVM_2021.Passes.AddObjectPass;
import Visual_DVM_2021.Passes.PassCode_2021;
import java.util.Vector;
public class CloneSapforPackage extends AddObjectPass<SapforPackage> {
SapforPackage src;
public CloneSapforPackage() {
super(SapforPackage.class);
}
@Override
public String getIconPath() {
return "/icons/MultiFiles.png";
}
@Override
protected Database getDb() {
return Global.testingServer.db;
}
@Override
protected boolean canStart(Object... args) throws Exception {
src = null;
if (!Current.getAccount().CheckRegistered(Log)) {
return false;
}
if (Current.Check(Log, Current.ServerSapfor, Current.SapforPackage)) {
//-
for (SapforPackage sapforPackage : Global.testingServer.db.sapforPackages.Data.values()) {
if (sapforPackage.state.equals(TasksPackageState.Draft)) {
Log.Writeln_("Может существовать только один пакет, готовящийся к публикации.");
return false;
}
}
//--
src = Current.getSapforPackage();
if (!src.state.equals(TasksPackageState.Done)) {
Log.Writeln_("Возможно повторить только завершенный пакет!");
return false;
}
if (!src.isLoaded())
passes.get(PassCode_2021.DownloadSapforPackage).Do(src);
//-
if (!src.isLoaded())
return false;
//----
Vector<String> inexistingTests = new Vector<>();
Vector<String> inexistingConfigurations = new Vector<>();
//---->>
target = new SapforPackage();
target.id = Constants.Nan;
//-
target.sender_name = Current.getAccount().name;
target.sender_address = Current.getAccount().email;
//-
target.drv = Current.getServerSapfor().call_command;
target.version = Current.getServerSapfor().version;
target.kernels = Global.properties.TestingKernels;
target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
//--
target.sapforId = Current.getServerSapfor().id;
//--
target.kernels = Global.properties.TestingKernels;
target.needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
//--
target.tasksCount = 0;
//--
src.readJson();
target.package_json = new SapforPackage_json();
///-------------------------------
target.package_json.kernels = target.kernels;
target.package_json.sapfor_drv = target.drv;
//--
Vector<String> testsNames = new Vector<>();
//--
for (SapforTestingSet_json src_testingSet : src.package_json.testingSets) {
int tests_count = 0;
int configurations_count = 0;
//--
SapforTestingSet_json testingSet = new SapforTestingSet_json();
testingSet.id = target.package_json.getMaxSetId();
//--
for (SapforTest_json src_TestJson : src_testingSet.tests) {
if (Global.testingServer.db.tests.containsKey(src_TestJson.id)) {
System.out.println("test=" + src_TestJson.id);
Test test = Global.testingServer.db.tests.get(src_TestJson.id);
SapforTest_json testJson = new SapforTest_json();
//--
testJson.id = test.id;
testJson.description = test.description;
testJson.group_description = src_TestJson.group_description;
//--
testingSet.tests.add(testJson);
//--
testsNames.add(test.description);
tests_count++;
}else {
inexistingTests.add(String.valueOf(src_TestJson.id));
}
}
//--
for (SapforConfiguration_json src_configuration : src_testingSet.configurations) {
if (Global.testingServer.db.sapforConfigurations.containsKey(src_configuration.id)) {
System.out.println("configuration=" + src_configuration.id);
SapforConfiguration configuration = Global.testingServer.db.sapforConfigurations.get(src_configuration.id);
SapforConfiguration_json configurationJson = new SapforConfiguration_json();
//--
configurationJson.id = configuration.id;
configurationJson.flags = src_configuration.flags;
configurationJson.codes.addAll(src_configuration.codes);
//--
testingSet.configurations.add(configurationJson);
configurations_count++;
}else {
inexistingConfigurations.add(String.valueOf(src_configuration.id));
}
}
//--
target.package_json.testingSets.add(testingSet);
target.tasksCount += tests_count * configurations_count;
target.testsNames += String.join(";", testsNames) + ";";
}
//--
for (String test_id: inexistingTests){
System.out.println("Тест "+test_id+" не найден!");
}
for (String configiration_id: inexistingConfigurations){
System.out.println("Конфигурация "+configiration_id+" не найдена!");
}
return inexistingTests.isEmpty()&&inexistingConfigurations.isEmpty()||
UI.Question(
(inexistingTests.isEmpty()? "" :(inexistingTests.size()+ " тестов отсутствует;"))+
(inexistingConfigurations.isEmpty()? "" : (inexistingConfigurations.size()+ " конфигураций отсутствует;"))
+"\родолжить");
}
return false;
}
@Override
protected void body() throws Exception {
// Utils.CheckAndCleanDirectory(target.getLocalWorkspace());
// target.saveJson();
Global.testingServer.db.sapforPackages.Data.put(target.id, target);
}
}

View File

@@ -315,11 +315,14 @@ public enum PassCode_2021 {
TestPass, TestPass,
SPF_InsertPrivateFromGUI, SPF_InsertPrivateFromGUI,
CloneDVMPackage, CloneDVMPackage,
CloneSapforPackage,
; ;
public String getDescription() { public String getDescription() {
switch (this) { switch (this) {
case Undefined: case Undefined:
return "?"; return "?";
case CloneSapforPackage:
return "Клонировать пакет SAPFOR с текущей версией";
case CloneDVMPackage: case CloneDVMPackage:
return "Клонировать пакет DVM c текущим компилятором"; return "Клонировать пакет DVM c текущим компилятором";
case AddTasksToSapforPackage: case AddTasksToSapforPackage: