no message
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.Json;
|
||||
import Common.CommonConstants;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.SapforSettings;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
//на самом деле уже settings. конфиграция = группы + параметры
|
||||
public class SapforConfiguration_json implements Serializable {
|
||||
@Expose
|
||||
public int id = CommonConstants.Nan;
|
||||
@Expose
|
||||
public String name = "";
|
||||
@Expose
|
||||
public String flags = "";
|
||||
@Expose
|
||||
public List<PassCode_2021> codes = new Vector<>();
|
||||
//--
|
||||
public SapforConfiguration_json() {
|
||||
}
|
||||
public SapforConfiguration_json(SapforSettings sapforSettings) {
|
||||
id = sapforSettings.id;
|
||||
name = sapforSettings.description;
|
||||
flags = sapforSettings.flags;
|
||||
codes = sapforSettings.getCheckedCodes();
|
||||
}
|
||||
}
|
||||
204
src/_VisualDVM/TestingSystem/SAPFOR/Json/SapforPackage_json.java
Normal file
204
src/_VisualDVM/TestingSystem/SAPFOR/Json/SapforPackage_json.java
Normal file
@@ -0,0 +1,204 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.Json;
|
||||
import _VisualDVM.GlobalData.Tasks.TaskState;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.ComparisonState;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI.PackageComparisonSummary;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI.PackageSummary;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class SapforPackage_json implements Serializable {
|
||||
@Expose
|
||||
public int kernels = 1;
|
||||
@Expose
|
||||
public String sapfor_drv = ""; //файл с сапфором. Имя уникально для сценария.
|
||||
//--
|
||||
@Expose
|
||||
public int max_set_id = 0;
|
||||
public int getMaxSetId() {
|
||||
return max_set_id++;
|
||||
}
|
||||
@Expose
|
||||
public int max_task_id = 0;
|
||||
public int getMaxTaskId() {
|
||||
return max_task_id++;
|
||||
}
|
||||
//--в отличие от пакета двм,где достаточно инфы о задачах, тут есть инфа о тестах и конфигурациях
|
||||
@Expose
|
||||
public List<SapforTestingSet_json> testingSets = new Vector<>(); //по факту, сет один. Наследие формирования пакетов.
|
||||
@Expose
|
||||
public List<SapforTask> tasks = new Vector<>();
|
||||
//--
|
||||
public Vector<String> getTasksKeys() {
|
||||
Vector<String> keys = new Vector<>();
|
||||
for (SapforTask task : tasks) {
|
||||
String key = task.getUniqueKey();
|
||||
if (!keys.contains(key))
|
||||
keys.add(key);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
public Vector<String> getTestsNames() {
|
||||
Vector<String> names = new Vector<>();
|
||||
for (SapforTask task : tasks) {
|
||||
if (!names.contains(task.test_description))
|
||||
names.add(task.test_description);
|
||||
}
|
||||
names.sort(new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return o1.compareTo(o2);
|
||||
}
|
||||
});
|
||||
return names;
|
||||
}
|
||||
//--
|
||||
public void sortTasks() {
|
||||
tasks.sort(new Comparator<SapforTask>() {
|
||||
@Override
|
||||
public int compare(SapforTask o1, SapforTask o2) {
|
||||
return Integer.compare(o1.state.ordinal(), o2.state.ordinal());
|
||||
}
|
||||
});
|
||||
}
|
||||
public void sortTasksForComparison() {
|
||||
tasks.sort(new Comparator<SapforTask>() {
|
||||
@Override
|
||||
public int compare(SapforTask o1, SapforTask o2) {
|
||||
return Integer.compare(o1.comparisonState.ordinal(), o2.comparisonState.ordinal());
|
||||
}
|
||||
});
|
||||
}
|
||||
public boolean containsKey(String key) {
|
||||
for (SapforTask task : tasks) {
|
||||
if (task.getUniqueKey().equals(key))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public SapforTask getTaskByKey(String key) {
|
||||
for (SapforTask task : tasks) {
|
||||
if (task.getUniqueKey().equals(key))
|
||||
return task;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//-
|
||||
public PackageSummary root = null;
|
||||
public PackageComparisonSummary comparison_root = null;
|
||||
//---------
|
||||
public void DropComparison() {
|
||||
comparison_root = null;
|
||||
for (SapforTask task : tasks) {
|
||||
task.comparisonState = ComparisonState.Unknown;
|
||||
for (SapforVersion_json version : task.versions)
|
||||
version.comparisonState = VersionComparisonState.Unknown;
|
||||
for (SapforVersion_json version : task.variants)
|
||||
version.comparisonState = VersionComparisonState.Unknown;
|
||||
}
|
||||
}
|
||||
public void buildTree(SapforPackage package_in) {
|
||||
//--
|
||||
root = new PackageSummary();
|
||||
root.count = tasks.size();
|
||||
root.errors_count = 0;
|
||||
//--
|
||||
sortTasks();
|
||||
//--
|
||||
for (SapforTask task : tasks) {
|
||||
DefaultMutableTreeNode taskNode = task.getNode(Paths.get(
|
||||
package_in.getLocalWorkspace().getAbsolutePath(),
|
||||
String.valueOf(task.set_id),
|
||||
String.valueOf(task.sapfor_configuration_id)
|
||||
).toFile());
|
||||
root.add(taskNode);
|
||||
if (task.state.equals(TaskState.DoneWithErrors))
|
||||
root.errors_count++;
|
||||
}
|
||||
}
|
||||
public void buildComparisonTree(SapforPackage package_in) {
|
||||
comparison_root = new PackageComparisonSummary();
|
||||
comparison_root.count = tasks.size();
|
||||
comparison_root.mismatches_count = 0;
|
||||
//--
|
||||
sortTasksForComparison();
|
||||
//--
|
||||
for (SapforTask task : tasks) {
|
||||
DefaultMutableTreeNode taskNode = task.getNode(Paths.get(
|
||||
package_in.getLocalWorkspace().getAbsolutePath(),
|
||||
String.valueOf(task.set_id),
|
||||
String.valueOf(task.sapfor_configuration_id)
|
||||
).toFile());
|
||||
comparison_root.add(taskNode);
|
||||
if (task.comparisonState.equals(ComparisonState.NotMatch))
|
||||
comparison_root.mismatches_count++;
|
||||
}
|
||||
}
|
||||
public void getVersionsFiles(SapforPackage package_in) {
|
||||
for (SapforTask task : tasks) {
|
||||
File configurationRoot = Paths.get(
|
||||
package_in.getLocalWorkspace().getAbsolutePath(),
|
||||
String.valueOf(task.set_id),
|
||||
String.valueOf(task.sapfor_configuration_id)
|
||||
).toFile();
|
||||
for (SapforVersion_json version_json : task.versions) {
|
||||
version_json.task = task;
|
||||
version_json.getFiles(configurationRoot);
|
||||
}
|
||||
for (SapforVersion_json version_json : task.variants) {
|
||||
version_json.task = task;
|
||||
version_json.getFiles(configurationRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
public Vector<String> getConfigurationsNames() {
|
||||
Vector<String> names = new Vector<>();
|
||||
for (SapforTestingSet_json set : testingSets) {
|
||||
for (SapforConfiguration_json configurationJson : set.configurations) {
|
||||
if (!names.contains(configurationJson.name))
|
||||
names.add(configurationJson.name);
|
||||
}
|
||||
}
|
||||
names.sort(new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return o1.compareTo(o2);
|
||||
}
|
||||
});
|
||||
return names;
|
||||
}
|
||||
//---
|
||||
public SapforPackage_json() {
|
||||
}
|
||||
public SapforPackage_json(ServerSapfor serverSapfor, LinkedHashMap<String, Test> testsByDescriptions, Vector<SapforConfiguration> configurations, int kernels_in) {
|
||||
sapfor_drv=serverSapfor.call_command;
|
||||
kernels = kernels_in;
|
||||
//рудимент от формирования пакетов. возможно, объединить с текущим классом.
|
||||
SapforTestingSet_json testingSet = new SapforTestingSet_json(testsByDescriptions, configurations);
|
||||
testingSet.id = getMaxSetId();
|
||||
testingSets.add(testingSet);
|
||||
//формирование задач
|
||||
LinkedHashMap<String, SapforTask> sortedTasks = new LinkedHashMap<>();
|
||||
for (SapforConfiguration_json sapforConfiguration_json : testingSet.configurations) {
|
||||
for (SapforTest_json test : testingSet.tests) {
|
||||
SapforTask task = new SapforTask(testingSet, test, sapforConfiguration_json);
|
||||
if (!sortedTasks.containsKey(task.getUniqueKey())) {
|
||||
task.id = getMaxTaskId();
|
||||
sortedTasks.put(task.getUniqueKey(), task);
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.addAll(sortedTasks.values());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.Json;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
public class SapforTest_json implements Serializable {
|
||||
@Expose
|
||||
public int id;
|
||||
@Expose
|
||||
public String description = "";
|
||||
@Expose
|
||||
public String group_description = "";
|
||||
public SapforTest_json(){}
|
||||
public SapforTest_json(Test test){
|
||||
id = test.id;
|
||||
description = test.description;
|
||||
group_description = Global.testingServer.db.groups.get(test.group_id).description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.Json;
|
||||
import Common.CommonConstants;
|
||||
import _VisualDVM.ServerObjectsCache.SapforConfigurationCache;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.SapforSettings;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class SapforTestingSet_json implements Serializable {
|
||||
@Expose
|
||||
public int id = CommonConstants.Nan;
|
||||
@Expose
|
||||
public List<SapforTest_json> tests = new Vector<>();
|
||||
@Expose
|
||||
public List<SapforConfiguration_json> configurations = new Vector<>();
|
||||
public SapforTestingSet_json(){}
|
||||
public SapforTestingSet_json(LinkedHashMap<String, Test> testsByDescriptions, Vector<SapforConfiguration> sapforConfigurations) {
|
||||
for (Test test : testsByDescriptions.values())
|
||||
tests.add(new SapforTest_json(test));
|
||||
for (SapforConfiguration configuration : sapforConfigurations) {
|
||||
for (SapforSettings sapforSettings : ((SapforConfigurationCache) VisualCaches.GetCache(configuration)).getSettings())
|
||||
configurations.add(new SapforConfiguration_json(sapforSettings));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.Json;
|
||||
import java.io.Serializable;
|
||||
public enum SapforVersionState implements Serializable {
|
||||
Empty, //версия оказалась пуста.
|
||||
Normal, //версия построена
|
||||
HasErrors //версия построена, но в журналах есть ошибка.
|
||||
}
|
||||
309
src/_VisualDVM/TestingSystem/SAPFOR/Json/SapforVersion_json.java
Normal file
309
src/_VisualDVM/TestingSystem/SAPFOR/Json/SapforVersion_json.java
Normal file
@@ -0,0 +1,309 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.Json;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
||||
import _VisualDVM.ProjectData.Files.FileType;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.ProjectData.Messages.Errors.MessageError;
|
||||
import _VisualDVM.ProjectData.Project.db_project_info;
|
||||
import _VisualDVM.Repository.Component.Sapfor.Sapfor;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import static java.lang.Character.isDigit;
|
||||
public class SapforVersion_json implements Serializable {
|
||||
@Expose
|
||||
public String version = "";
|
||||
@Expose
|
||||
public String description = "";
|
||||
//поля для отображения деревьев.
|
||||
public File Home = null;
|
||||
public LinkedHashMap<String, ProjectFile> files = new LinkedHashMap<>();
|
||||
//--
|
||||
public ProjectFile parse_out = null;
|
||||
public ProjectFile parse_err = null;
|
||||
public ProjectFile out = null;
|
||||
public ProjectFile err = null;
|
||||
//--
|
||||
public SapforTask task = null; //родная задача. Нужна для построения дерева версий.
|
||||
public db_project_info project = null;
|
||||
//--
|
||||
public SapforVersionState state = null;
|
||||
public VersionComparisonState comparisonState = null;
|
||||
//--
|
||||
public SapforVersion_json(String version_in, String description_in) {
|
||||
version = version_in;
|
||||
description = description_in;
|
||||
}
|
||||
public SapforVersion_json(String root_in, String version_in, String description_in) {
|
||||
version = version_in.substring(root_in.length() + 1);
|
||||
description = description_in;
|
||||
}
|
||||
public void getFiles(File configurationRoot) {
|
||||
//--
|
||||
state = SapforVersionState.Empty;
|
||||
comparisonState = VersionComparisonState.Unknown;
|
||||
//--
|
||||
String relativePath = CommonUtils.isWindows() ? CommonUtils.toW(version) : version;
|
||||
Home = Paths.get(configurationRoot.getAbsolutePath(), relativePath).toFile();
|
||||
files = new LinkedHashMap<>();
|
||||
//--
|
||||
File[] files_ = Home.listFiles();
|
||||
if (files_ != null) {
|
||||
for (File file : files_) {
|
||||
if (file.isFile()) {
|
||||
ProjectFile projectFile = new ProjectFile(file);
|
||||
if (!projectFile.fileType.equals(FileType.forbidden)
|
||||
) {
|
||||
files.put(projectFile.file.getName(), projectFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!files.isEmpty())
|
||||
state = SapforVersionState.Normal;
|
||||
}
|
||||
parse_out = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.parse_out_file).toFile());
|
||||
parse_err = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.parse_err_file).toFile());
|
||||
out = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.out_file).toFile());
|
||||
err = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.err_file).toFile());
|
||||
//--
|
||||
Vector<File> out_files = new Vector<>();
|
||||
out_files.add(parse_out.file);
|
||||
out_files.add(parse_err.file);
|
||||
out_files.add(out.file);
|
||||
out_files.add(err.file);
|
||||
for (File file : out_files) {
|
||||
try {
|
||||
if (file.exists()) {
|
||||
Vector<String> lines = new Vector<>(FileUtils.readLines(file));
|
||||
if (!Sapfor.checkLines(lines)) {
|
||||
state = SapforVersionState.HasErrors;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean isMatch(SapforVersion_json version_json) {
|
||||
if (!description.equals(version_json.description)) {
|
||||
return false;
|
||||
}
|
||||
if (files.size() != version_json.files.size()) {
|
||||
return false;
|
||||
}
|
||||
for (String name1 : files.keySet()) {
|
||||
if (!version_json.files.containsKey(name1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (String name1 : files.keySet()) {
|
||||
ProjectFile file1 = files.get(name1);
|
||||
ProjectFile file2 = version_json.files.get(name1);
|
||||
//---
|
||||
String text1 = "";
|
||||
String text2 = "";
|
||||
try {
|
||||
text1 = FileUtils.readFileToString(file1.file, Charset.defaultCharset());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try {
|
||||
text2 = FileUtils.readFileToString(file2.file, Charset.defaultCharset());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (!Utils.compareFortranTexts(text1, text2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public MessageError unpackMessage(String line_in) throws Exception {
|
||||
MessageError res = new MessageError();
|
||||
res.file = "";
|
||||
res.line = CommonConstants.Nan;
|
||||
res.value = "";
|
||||
String line = line_in.substring(9);
|
||||
int i = 0;
|
||||
int s = 0;
|
||||
String lexeme = "";
|
||||
//#1020: red43.fdv: line 988]: Active DVM directives are not supported (turn on DVM-directive support option)
|
||||
for (char c : line.toCharArray()) {
|
||||
switch (s) {
|
||||
case 0:
|
||||
//поиск groups_s
|
||||
if (c == '#') {
|
||||
s = 1;
|
||||
lexeme = "";
|
||||
} else return null;
|
||||
break;
|
||||
case 1:
|
||||
//group_s
|
||||
if (isDigit(c)) {
|
||||
res.group_s += c;
|
||||
lexeme += c;
|
||||
} else if (c == ':') {
|
||||
s = 2;
|
||||
res.group = Integer.parseInt(lexeme);
|
||||
} else return null;
|
||||
break;
|
||||
case 2:
|
||||
//поиск filename
|
||||
if (c == ' ') {
|
||||
s = 3;
|
||||
} else return null;
|
||||
break;
|
||||
case 3:
|
||||
//filename
|
||||
if (c == ':') {
|
||||
s = 4;
|
||||
} else {
|
||||
res.file += c;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
//поиск line
|
||||
if (c == ' ') {
|
||||
s = 5;
|
||||
lexeme = "";
|
||||
} else return null;
|
||||
break;
|
||||
case 5:
|
||||
//line
|
||||
if (c == ' ') {
|
||||
if (!lexeme.equals("line"))
|
||||
return null;
|
||||
else {
|
||||
s = 6;
|
||||
lexeme = "";
|
||||
}
|
||||
} else {
|
||||
lexeme += c;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
//line number
|
||||
if (isDigit(c)) {
|
||||
lexeme += c;
|
||||
} else if (c == ']') {
|
||||
res.line = Integer.parseInt(lexeme);
|
||||
s = 7;
|
||||
} else return null;
|
||||
break;
|
||||
case 7:
|
||||
//Поиск value
|
||||
if (c == ':') {
|
||||
s = 8;
|
||||
} else return null;
|
||||
break;
|
||||
case 8:
|
||||
if (c == ' ') {
|
||||
s = 9;
|
||||
} else return null;
|
||||
break;
|
||||
case 9:
|
||||
//value
|
||||
res.value += c;
|
||||
break;
|
||||
}
|
||||
;
|
||||
++i;
|
||||
}
|
||||
//--
|
||||
if (s != 9)
|
||||
return null;
|
||||
//--
|
||||
return res;
|
||||
}
|
||||
public void readMessagesFromFileDump(File file, Vector<MessageError> messages) {
|
||||
try {
|
||||
//Образец запакованного сообщения
|
||||
//ERROR - [#1020: red43.fdv: line 988]: Active DVM directives are not supported (turn on DVM-directive support option)
|
||||
Vector<String> lines = new Vector<>(FileUtils.readLines(file));
|
||||
if (!lines.isEmpty()) {
|
||||
for (int i = lines.size() - 1; i >= 0; --i) {
|
||||
String line = lines.get(i);
|
||||
if (line.startsWith("ERROR - ")) {
|
||||
MessageError message = unpackMessage(line);
|
||||
if (message != null)
|
||||
messages.add(message);
|
||||
//--
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
//--
|
||||
public void createProject(File rootHome) throws Exception {
|
||||
project = null;
|
||||
String version_ = CommonUtils.isWindows() ? CommonUtils.toW(version) : CommonUtils.toU(version);
|
||||
project = new db_project_info();
|
||||
project.Home = Paths.get(rootHome.getAbsolutePath(), version_).toFile();
|
||||
project.name = project.Home.getName();
|
||||
project.description = description;
|
||||
project.languageName = LanguageName.fortran;
|
||||
project.creationDate = CommonUtils.getDateNumber();
|
||||
//---
|
||||
FileUtils.copyDirectory(Home, project.Home);
|
||||
///--------------------------------------
|
||||
project.CreateVisualiserData();
|
||||
}
|
||||
public void ReadMessages() throws Exception {
|
||||
if (project != null) {
|
||||
Vector<MessageError> messages = new Vector<>();
|
||||
//--
|
||||
File p_out = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.parse_out_file).toFile();
|
||||
File p_err = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.parse_err_file).toFile();
|
||||
File out = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.out_file).toFile();
|
||||
File err = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.err_file).toFile();
|
||||
//--
|
||||
if (p_out.exists()) {
|
||||
project.Log += (FileUtils.readFileToString(p_out));
|
||||
readMessagesFromFileDump(p_out, messages);
|
||||
}
|
||||
if (out.exists()) {
|
||||
project.Log += "\n" + FileUtils.readFileToString(out);
|
||||
readMessagesFromFileDump(out, messages);
|
||||
}
|
||||
//в потоки ошибок идет информация от операционной системы. сообщений там быть не должно.
|
||||
if (p_err.exists())
|
||||
project.Log += (FileUtils.readFileToString(p_err));
|
||||
if (err.exists())
|
||||
project.Log += "\n" + FileUtils.readFileToString(err);
|
||||
//--
|
||||
project.Open();
|
||||
project.Update(); //Журнал
|
||||
//а так же, убрать dep и txt
|
||||
project.db.BeginTransaction();
|
||||
for (MessageError m : messages) {
|
||||
if (project.db.files.containsKey(m.file)) {
|
||||
DBProjectFile file = project.db.files.Data.get(m.file);
|
||||
file.CreateAndAddNewMessage(1, m.value, m.line, m.group);
|
||||
//update file
|
||||
project.db.Update(file);
|
||||
}
|
||||
}
|
||||
project.db.Commit();
|
||||
project.db.Disconnect();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return Home.getName() + " : " + CommonUtils.Brackets(description) + " файлы: " + files.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.Json;
|
||||
public enum VersionComparisonState {
|
||||
Unknown,
|
||||
Match, //версия совпадает
|
||||
NotMatch
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.TestingSystem.Common.TaskThread;
|
||||
import _VisualDVM.TestingSystem.Common.ThreadsPlanner.ThreadsPlanner;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforPackage_json;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
public class PackageModeSupervisor extends ThreadsPlanner {
|
||||
SapforPackage_json package_json = null;
|
||||
File sapfor_drv = null;
|
||||
public PackageModeSupervisor() throws Exception {
|
||||
super(2000);
|
||||
package_json = (SapforPackage_json) CommonUtils.jsonFromFile(new File(Constants.package_json), SapforPackage_json.class);
|
||||
//--
|
||||
File sapfor_src = new File(package_json.sapfor_drv);
|
||||
sapfor_drv = new File(CommonUtils.getHomeDirectory(), CommonUtils.getDateName("SAPFOR_F"));
|
||||
FileUtils.copyFile(sapfor_src, sapfor_drv);
|
||||
if (!sapfor_drv.setExecutable(true))
|
||||
throw new Exception("Не удалось сделать файл " + sapfor_drv.getName() + " исполняемым!");
|
||||
File PID = new File("PID");
|
||||
FileUtils.writeStringToFile(PID, sapfor_drv.getName(), Charset.defaultCharset());
|
||||
//---
|
||||
Date startDate = new Date();
|
||||
File started = new File(Constants.STARTED);
|
||||
FileUtils.writeStringToFile(started, String.valueOf(startDate));
|
||||
//формирование списка задач.
|
||||
setMaxKernels(package_json.kernels);
|
||||
for (SapforTask task: package_json.tasks)
|
||||
addThread(new TaskThread(task,sapfor_drv));
|
||||
interruptThread.start();
|
||||
}
|
||||
@Override
|
||||
public String printThread(Integer id) {
|
||||
TaskThread taskThread = (TaskThread) threads.get(id);
|
||||
return taskThread.task.getSummary();
|
||||
}
|
||||
@Override
|
||||
protected void finalize() {
|
||||
//записать результаты всех задач.
|
||||
try {
|
||||
CommonUtils.jsonToFile(package_json, new File(Constants.package_json));
|
||||
FileUtils.writeStringToFile(new File(Constants.DONE), "");
|
||||
//--
|
||||
//Очистка
|
||||
//очистка служебных файлов.
|
||||
Utils.deleteFilesByExtensions(CommonUtils.getHomeDirectory(),
|
||||
"proj", "dep", "jar"
|
||||
// ,"sh", "exe", "bat"
|
||||
);
|
||||
//удаление сапфора
|
||||
if (sapfor_drv.exists())
|
||||
FileUtils.forceDelete(sapfor_drv);
|
||||
} catch (Exception e) {
|
||||
CommonUtils.MainLog.PrintException(e);
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
129
src/_VisualDVM/TestingSystem/SAPFOR/PerformSapforTask.java
Normal file
129
src/_VisualDVM/TestingSystem/SAPFOR/PerformSapforTask.java
Normal file
@@ -0,0 +1,129 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.Tasks.TaskState;
|
||||
import _VisualDVM.Repository.Component.Sapfor.Sapfor;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforVersion_json;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
// "Запуск задачи SAPFOR"; Оставляем пустое описание чтобы не засорять журнал.
|
||||
}
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
File sapfor_drv;
|
||||
SapforVersion_json version_json;
|
||||
//-----
|
||||
File root;
|
||||
File parentTask;
|
||||
File task;
|
||||
//-----
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
//--
|
||||
target = (SapforTask) args[0];
|
||||
sapfor_drv = (File) args[1];
|
||||
//--
|
||||
version_json = null;
|
||||
//--->>
|
||||
parentTask = Paths.get(CommonUtils.getHomePath(),
|
||||
String.valueOf(target.set_id),
|
||||
String.valueOf(target.sapfor_configuration_id),
|
||||
target.test_description).toFile();
|
||||
root = Paths.get(CommonUtils.getHomePath(), String.valueOf(target.set_id), String.valueOf(target.sapfor_configuration_id)).toFile();
|
||||
task = null;
|
||||
//--->>
|
||||
return true;
|
||||
}
|
||||
protected boolean parse() throws Exception {
|
||||
if (Sapfor.parse(sapfor_drv, parentTask, target.flags)) {
|
||||
return true;
|
||||
} else {
|
||||
target.state = TaskState.DoneWithErrors;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//слегка изменить подход.
|
||||
protected boolean transformation(PassCode_2021 code) throws Exception {
|
||||
task = new File(parentTask, "v1");
|
||||
Utils.CheckAndCleanDirectory(task); //папка для преобразования.
|
||||
//если версия пустая, это тоже результат тестирования. Поэтому должна учитываться в древе.
|
||||
target.versions.add(version_json = new SapforVersion_json(
|
||||
root.getAbsolutePath(),
|
||||
task.getAbsolutePath(), code.getDescription()));
|
||||
//---
|
||||
if (Sapfor.performScript(
|
||||
"transformation",
|
||||
sapfor_drv,
|
||||
parentTask,
|
||||
code.getTestingCommand() + " -F " + CommonUtils.DQuotes(task.getAbsolutePath()),
|
||||
target.flags,
|
||||
Constants.out_file,
|
||||
Constants.err_file
|
||||
)) {
|
||||
target.state = TaskState.Done;
|
||||
parentTask = task;
|
||||
return true;
|
||||
}
|
||||
target.state = TaskState.DoneWithErrors;
|
||||
return false;
|
||||
}
|
||||
protected void variants() throws Exception {
|
||||
//папки вариантов создается самим сапфором.
|
||||
target.state = Sapfor.performScript(
|
||||
"create_variants",
|
||||
sapfor_drv,
|
||||
parentTask,
|
||||
" -t 13 -allVars",// -tinfo",
|
||||
target.flags,
|
||||
Constants.out_file,
|
||||
Constants.err_file
|
||||
) ? TaskState.Done : TaskState.DoneWithErrors;
|
||||
//найти папки с вариантами.
|
||||
File[] files_ = parentTask.listFiles((dir, name) -> dir.isDirectory() && Utils.isParallelVersionName(name));
|
||||
if ((files_ != null) && (files_.length > 0)) {
|
||||
Vector<File> files = new Vector<>(Arrays.asList(files_));
|
||||
files.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName().substring(1))));
|
||||
for (File file : files)
|
||||
target.variants.add(
|
||||
new SapforVersion_json(
|
||||
root.getAbsolutePath(),
|
||||
file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription()));
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------->>
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
target.StartDate = new Date().getTime();
|
||||
target.versions.add(version_json = new SapforVersion_json(target.test_description, "исходная"));
|
||||
String [] data = target.codes.split(" ");
|
||||
for (String code_s: data){
|
||||
PassCode_2021 code = PassCode_2021.valueOf(code_s);
|
||||
//--
|
||||
if (parse()) {
|
||||
if (code.equals(PassCode_2021.CreateParallelVariants))
|
||||
variants();
|
||||
else if (!transformation(code))
|
||||
break;
|
||||
} else
|
||||
break;
|
||||
//--
|
||||
}
|
||||
target.ChangeDate = new Date().getTime();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration;
|
||||
import _VisualDVM.ServerObjectsCache.ConfigurationCache;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
import Common.Utils.TextLog;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.SapforSettings;
|
||||
|
||||
import java.util.Vector;
|
||||
public class SapforConfiguration extends Configuration {
|
||||
public SapforConfiguration(SapforConfiguration sapforConfiguration) {
|
||||
this.SynchronizeFields(sapforConfiguration);
|
||||
}
|
||||
public SapforConfiguration() {
|
||||
}
|
||||
@Override
|
||||
public boolean validate(TextLog Log) {
|
||||
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(this);
|
||||
//--
|
||||
Vector<Group> groups = cache.getGroups();
|
||||
Vector<LanguageName> groupsLanguages = new Vector<>();
|
||||
Vector<SapforSettings> settingsArray= new Vector<>();
|
||||
//-
|
||||
//1. проверка цепочек команд на корректность
|
||||
for (SapforSettings sapforSettings: settingsArray){
|
||||
sapforSettings.validate(Log);
|
||||
}
|
||||
//2. Проверка входящих групп на единственный язык фортран
|
||||
for (Group group : groups) {
|
||||
if (!groupsLanguages.contains(group.language))
|
||||
groupsLanguages.add(group.language);
|
||||
}
|
||||
if (groupsLanguages.size()>1){
|
||||
Log.Writeln_("Запуск тестов на разных языках в рамках одного пакета запрещен!\n");
|
||||
}
|
||||
if ((!groupsLanguages.contains(LanguageName.fortran))) {
|
||||
Log.Writeln_("Поддерживается пакетный режим только для языка Fortran");
|
||||
}
|
||||
//-
|
||||
return Log.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Tables.TableEditors;
|
||||
import Common.Visual.Tables.TableRenderers;
|
||||
import _VisualDVM.ServerObjectsCache.ConfigurationCache;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import Common.Utils.Vector_;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.UI.SapforConfigurationFields;
|
||||
|
||||
import java.util.Vector;
|
||||
public class SapforConfigurationDBTable extends iDBTable<SapforConfiguration> {
|
||||
public SapforConfigurationDBTable() {
|
||||
super(SapforConfiguration.class);
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.SapforConfiguration;
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "конфигурация тестирования SAPFOR";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "конфигурации";
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
columns.get(4).setRenderer(TableRenderers.RendererAutoConfiguration);
|
||||
columns.get(4).setEditor(TableEditors.EditorAutoConfiguration);
|
||||
columns.get(4).setMinWidth(25);
|
||||
columns.get(4).setMaxWidth(25);
|
||||
columns.get(6).setMaxWidth(500);
|
||||
columns.get(7).setRenderer(TableRenderers.RendererMultiline);
|
||||
columns.get(7).setMaxWidth(500);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"имя",
|
||||
"автор",
|
||||
"",
|
||||
"ядра",
|
||||
"параметры",
|
||||
"группы",
|
||||
"тестов"
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(SapforConfiguration object, int columnIndex) {
|
||||
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(object);
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.description;
|
||||
case 3:
|
||||
return object.sender_name;
|
||||
case 4:
|
||||
return object.printAuto();
|
||||
case 5:
|
||||
return object.kernels;
|
||||
case 6:
|
||||
return cache.settingsSummary;
|
||||
case 7:
|
||||
return cache.groupsSummary;
|
||||
case 8:
|
||||
return cache.getTestsCount();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
public DBObjectDialog<SapforConfiguration, SapforConfigurationFields> getDialog() {
|
||||
return new DBObjectDialog<SapforConfiguration, SapforConfigurationFields>(SapforConfigurationFields.class) {
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return 200;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultWidth() {
|
||||
return 450;
|
||||
}
|
||||
@Override
|
||||
public void validateFields() {
|
||||
}
|
||||
@Override
|
||||
public void fillFields() {
|
||||
fields.tfName.setText(Result.description);
|
||||
fields.sKernels.setValue(Result.kernels);
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result.description = fields.tfName.getText();
|
||||
Result.kernels = (int) fields.sKernels.getValue();
|
||||
}
|
||||
@Override
|
||||
public void SetReadonly() {
|
||||
fields.tfName.setEnabled(false);
|
||||
fields.sTransformationMaxtime.setEnabled(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
public Vector<SapforConfiguration> getAutoConfigurations() {
|
||||
Vector<SapforConfiguration> res = new Vector_<>();
|
||||
for (SapforConfiguration configuration : Data.values()) {
|
||||
if (configuration.autoTesting != 0)
|
||||
res.add(configuration);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//патч.потом удалить.
|
||||
public SapforConfiguration getConfigurationByDescription(String description){
|
||||
for (SapforConfiguration sapforConfiguration: Data.values())
|
||||
if (sapforConfiguration.description.equals(description))
|
||||
return sapforConfiguration;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class SapforConfigurationsMenuBar extends DataMenuBar {
|
||||
public SapforConfigurationsMenuBar() {
|
||||
super("конфигурации",
|
||||
PassCode_2021.PublishSapforConfiguration,
|
||||
|
||||
PassCode_2021.EditSapforConfiguration,
|
||||
PassCode_2021.ShowCurrentSAPFORConfigurationTests,
|
||||
PassCode_2021.SaveCurrentSAPFORConfiguration,
|
||||
PassCode_2021.DeleteSapforConfiguration,
|
||||
|
||||
PassCode_2021.StartSelectedSAPFORConfigurations
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.UI.SapforConfigurationFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="342" height="160"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="d1d6e" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="3257b" 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">
|
||||
<preferred-size width="99" height="20"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="название"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="224d6">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="99" height="14"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="1eea4" 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">
|
||||
<preferred-size width="99" height="20"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="ядра"/>
|
||||
<toolTipText value="количество ядер, задействованное при тестировани"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ecbf1" class="javax.swing.JTextField" binding="tfName" 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">
|
||||
<minimum-size width="200" height="30"/>
|
||||
<preferred-size width="200" height="30"/>
|
||||
<maximum-size width="200" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="2a173" class="javax.swing.JSpinner" binding="sKernels">
|
||||
<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">
|
||||
<minimum-size width="100" height="30"/>
|
||||
<preferred-size width="100" height="30"/>
|
||||
<maximum-size width="100" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,27 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.UI;
|
||||
import _VisualDVM.Constants;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class SapforConfigurationFields implements DialogFields {
|
||||
private JPanel content;
|
||||
public JTextField tfName;
|
||||
public JSpinner sTransformationMaxtime;
|
||||
public JSpinner sKernels;
|
||||
//--
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
tfName = new StyledTextField();
|
||||
}
|
||||
public SapforConfigurationFields(){
|
||||
sKernels.setModel(new SpinnerNumberModel(1, 1,
|
||||
Constants.testingMaxKernels,
|
||||
1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforPackage;
|
||||
import Common.CommonConstants;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.ServerObjectsCache.ConfigurationCache;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
import Common.Utils.TextLog;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.Account.Account;
|
||||
import _VisualDVM.GlobalData.Tasks.TaskState;
|
||||
import _VisualDVM.TestingSystem.Common.TasksPackageState;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPackage.TestingPackage;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforPackage_json;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class SapforPackage extends TestingPackage<SapforPackage_json> {
|
||||
public int sapforId = CommonConstants.Nan; // так как сапфор на машине.
|
||||
//--------------
|
||||
public SapforPackage() {
|
||||
}
|
||||
public SapforPackage(SapforPackage sapforPackage) {
|
||||
SynchronizeFields(sapforPackage);
|
||||
}
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
SapforPackage p = (SapforPackage) src;
|
||||
sapforId = p.sapforId;
|
||||
}
|
||||
@Override
|
||||
public Class getJsonClass() {
|
||||
return SapforPackage_json.class;
|
||||
}
|
||||
@Override
|
||||
public File getHomeDirectory() {
|
||||
return Global.SapforPackagesDirectory;
|
||||
}
|
||||
//--
|
||||
public void init() throws Exception {
|
||||
for (SapforTask task : package_json.tasks)
|
||||
task.sapfortaskspackage_id = id;
|
||||
Utils.CheckAndCleanDirectory(getLocalWorkspace());
|
||||
saveJson();
|
||||
package_json = null; // объект больше не нужен.
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return (!SapforPackageDBTable.filterMyOnly || Current.getAccount().email.equals(sender_address)) &&
|
||||
(!SapforPackageDBTable.filterActive || state.isActive())
|
||||
;
|
||||
}
|
||||
//---------
|
||||
//конструктор. если 0 задач по итогу,значит пакет не запускаем вообще, и смотрим журнал.
|
||||
//Запрещено выполнять на нитях, так как прямой доступ к бд.
|
||||
public SapforPackage(Account account, ServerSapfor serverSapfor, Vector<SapforConfiguration> configurations,
|
||||
int neeedsEmail_in,
|
||||
TextLog Log) throws Exception {
|
||||
id = CommonConstants.Nan;
|
||||
sender_name = account.name;
|
||||
sender_address = account.email;
|
||||
//-
|
||||
sapforId = serverSapfor.id;
|
||||
//-
|
||||
drv = serverSapfor.call_command;
|
||||
version = serverSapfor.version;
|
||||
///-------------------------------
|
||||
needsEmail = neeedsEmail_in;
|
||||
//-
|
||||
state = TasksPackageState.Queued;
|
||||
//--
|
||||
boolean valid = true;
|
||||
//проверка исходных данных тестов и групп
|
||||
LinkedHashMap<String, Test> testsByDescriptions = new LinkedHashMap<>();
|
||||
//--
|
||||
kernels = 1;
|
||||
for (SapforConfiguration configuration : configurations) {
|
||||
kernels = Math.max(configuration.kernels, kernels);
|
||||
configuration.validate(Log);
|
||||
//-
|
||||
ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(configuration);
|
||||
//--
|
||||
for (Test test : cache.getTests()) {
|
||||
String l_description = test.description.toLowerCase();
|
||||
if (testsByDescriptions.containsKey(l_description)) {
|
||||
Log.Writeln_("В пакет не могут входить тесты с одинаковыми именами (без учета регистра):" + test.description.toLowerCase());
|
||||
valid = false;
|
||||
} else {
|
||||
testsByDescriptions.put(l_description, test);
|
||||
}
|
||||
}
|
||||
}
|
||||
valid = Log.isEmpty();
|
||||
//формирование задач.
|
||||
if (valid) {
|
||||
package_json = new SapforPackage_json(serverSapfor, testsByDescriptions, configurations, kernels);
|
||||
tasksCount = package_json.tasks.size();
|
||||
saveConfigurationsAsJson(configurations);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void checkFinishState() throws Exception {
|
||||
readJson();
|
||||
int good=0;
|
||||
int bad = 0;
|
||||
for (SapforTask task : package_json.tasks) {
|
||||
if (!task.state.equals(TaskState.Done))
|
||||
bad++;
|
||||
else good++;
|
||||
}
|
||||
state = (bad > 0) ? TasksPackageState.DoneWithErrors : TasksPackageState.Done;
|
||||
double percent = ( ((double)(good))/tasksCount)*100.0;
|
||||
description = "Выполнено на "+((int)percent)+"%\n"+
|
||||
"Всего задач: "+tasksCount+", из них с ошибками "+bad;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforPackage;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import _VisualDVM.ServerObjectsCache.PackageCache;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
|
||||
import static Common.Visual.Tables.TableRenderers.*;
|
||||
public class SapforPackageDBTable extends iDBTable<SapforPackage> {
|
||||
public static boolean filterMyOnly = false;
|
||||
public static boolean filterActive = false;
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.SapforPackage;
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "пакет задач SAPFOR";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "пакеты задач SAPFOR";
|
||||
}
|
||||
public SapforPackageDBTable() {
|
||||
super(SapforPackage.class);
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
columns.get(4).setRenderer(RendererMultiline);
|
||||
columns.get(7).setRenderer(RendererProgress);
|
||||
columns.get(8).setRenderer(RendererDate);
|
||||
columns.get(9).setRenderer(RendererDate);
|
||||
columns.get(10).setRenderer(RendererStatusEnum);
|
||||
}
|
||||
@Override
|
||||
public void MouseAction2() throws Exception {
|
||||
Pass_2021.passes.get(PassCode_2021.CompareSapforPackages).Do();
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"Автор",
|
||||
"SAPFOR",
|
||||
"Конфигурации",
|
||||
"Задач",
|
||||
"Ядер",
|
||||
"Прогресс",
|
||||
"Начало",
|
||||
"Изменено",
|
||||
"Статус"
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(SapforPackage object, int columnIndex) {
|
||||
PackageCache cache = (PackageCache) VisualCaches.GetCache(object);
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.sender_name;
|
||||
case 3:
|
||||
return object.version;
|
||||
case 4:
|
||||
return cache.getConfigurationsDescriptions();
|
||||
case 5:
|
||||
return object.tasksCount;
|
||||
case 6:
|
||||
return object.kernels;
|
||||
case 7:
|
||||
return object.progress;
|
||||
case 8:
|
||||
return new Date(object.StartDate);
|
||||
case 9:
|
||||
return new Date(object.ChangeDate);
|
||||
case 10:
|
||||
return object.state;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Comparator<SapforPackage> getComparator() {
|
||||
return new Comparator<SapforPackage>() {
|
||||
@Override
|
||||
public int compare(SapforPackage o1, SapforPackage o2) {
|
||||
return o2.id-o1.id;
|
||||
}
|
||||
};
|
||||
// return Comparator.comparingInt(o -> o.).reversed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforSettings;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Utils.TextLog;
|
||||
import _VisualDVM.TestingSystem.Common.Settings.Settings;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettingsCommand.SapforSettingsCommand;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class SapforSettings extends Settings {
|
||||
//настройки.
|
||||
public int FREE_FORM = 0; //"Свободный выходной стиль"; -f90
|
||||
public int STATIC_SHADOW_ANALYSIS = 0;//"Оптимизация теневых обменов"; -sh
|
||||
public int MAX_SHADOW_WIDTH = 50; // "Максимальный размер теневых граней"; (%) -shwidth значение поля
|
||||
public int KEEP_SPF_DIRECTIVES = 0; //"Сохранять SPF директивы при построении параллельных вариантов"; -keepSPF
|
||||
public int KEEP_DVM_DIRECTIVES = 0;// "Учитывать DVM директивы"; -keepDVM
|
||||
//----
|
||||
//----
|
||||
public void packFlags() {
|
||||
Vector<String> res = new Vector<>();
|
||||
//--
|
||||
if (FREE_FORM > 0)
|
||||
res.add("-f90");
|
||||
if (STATIC_SHADOW_ANALYSIS > 0)
|
||||
res.add("-sh");
|
||||
if (MAX_SHADOW_WIDTH > 0)
|
||||
res.add("-shwidth " + MAX_SHADOW_WIDTH);
|
||||
if (KEEP_DVM_DIRECTIVES > 0)
|
||||
res.add("-keepDVM");
|
||||
if (KEEP_SPF_DIRECTIVES > 0)
|
||||
res.add("-keepSPF");
|
||||
//--
|
||||
flags = String.join(" ", res);
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
SapforSettings c = (SapforSettings) src;
|
||||
FREE_FORM = c.FREE_FORM;
|
||||
STATIC_SHADOW_ANALYSIS = c.STATIC_SHADOW_ANALYSIS;
|
||||
MAX_SHADOW_WIDTH = c.MAX_SHADOW_WIDTH;
|
||||
KEEP_SPF_DIRECTIVES = c.KEEP_SPF_DIRECTIVES;
|
||||
KEEP_DVM_DIRECTIVES = c.KEEP_DVM_DIRECTIVES;
|
||||
}
|
||||
public SapforSettings(SapforSettings sapforSettings) {
|
||||
this.SynchronizeFields(sapforSettings);
|
||||
}
|
||||
public SapforSettings() {
|
||||
}
|
||||
public Vector<PassCode_2021> getCodes() {
|
||||
Vector<PassCode_2021> res = new Vector<>();
|
||||
for (SapforSettingsCommand command : Global.testingServer.db.sapforSettingsCommands.Data.values())
|
||||
if (command.sapforsettings_id == id) res.add(command.passCode);
|
||||
return res;
|
||||
}
|
||||
public List<PassCode_2021> getCheckedCodes(){
|
||||
Vector<PassCode_2021> res = getCodes();
|
||||
if (!res.firstElement().equals(PassCode_2021.SPF_InsertIncludesPass))
|
||||
res.insertElementAt(PassCode_2021.SPF_CorrectCodeStylePass,0); //всегда добавляется.
|
||||
return res;
|
||||
}
|
||||
@Override
|
||||
public boolean validate(TextLog Log) {
|
||||
boolean res = true;
|
||||
Vector<PassCode_2021> codes = getCodes();
|
||||
if (codes.size() == 0) {
|
||||
Log.Writeln_("Настройки:" + id + " не содержат ни одного прохода.");
|
||||
return false;
|
||||
}
|
||||
//-
|
||||
int first = 0;
|
||||
int last = codes.size() - 1;
|
||||
Vector<PassCode_2021> matches = new Vector<>();
|
||||
for (int i = 0; i < codes.size(); ++i) {
|
||||
PassCode_2021 code = codes.get(i);
|
||||
if (code.isSapforStart()) {
|
||||
if (i > first) {
|
||||
Log.Writeln_("Неверные настройки:" + id + ": проход" +
|
||||
CommonUtils.Brackets(code.getDescription()) +
|
||||
" может быть только первым!");
|
||||
res=false;
|
||||
}
|
||||
}
|
||||
if (code.isSapforTerminal()) {
|
||||
if (i < last) {
|
||||
Log.Writeln_("Неверные настройки:" + id + ": проход " +
|
||||
CommonUtils.Brackets(code.getDescription()) +
|
||||
" может быть только последним!");
|
||||
res= false;
|
||||
}
|
||||
}
|
||||
if (matches.contains(code)) {
|
||||
Log.Writeln_("Неверные настройки:" + id + ": проход " +
|
||||
CommonUtils.Brackets(code.getDescription()) +
|
||||
" запрещено применять более одного раза!");
|
||||
res=false;
|
||||
} else matches.add(code);
|
||||
}
|
||||
//-
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforSettings;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class SapforSettingsBar extends DataMenuBar {
|
||||
public SapforSettingsBar() {
|
||||
super("параметры тестирования",
|
||||
PassCode_2021.PublishSapforSettings,
|
||||
PassCode_2021.CloneSapforSettings,
|
||||
PassCode_2021.EditSapforSettings,
|
||||
PassCode_2021.DeleteSapforSettings
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforSettings;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Tables.FKBehaviour;
|
||||
import Common.Database.Tables.FKCurrentObjectBehaviuor;
|
||||
import Common.Database.Tables.FKDataBehaviour;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.UI.SapforSettingsFields;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettingsCommand.SapforSettingsCommand;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
public class SapforSettingsDBTable extends iDBTable<SapforSettings> {
|
||||
public SapforSettingsDBTable() {
|
||||
super(SapforSettings.class);
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.SapforSettings;
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "параметры тестирования системы SAPFOR";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "параметры тестирования системы SAPFOR";
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
/*
|
||||
columns.get(5).setRenderer(TableRenderers.RendererAutoConfiguration);
|
||||
columns.get(5).setEditor(TableEditors.EditorAutoConfiguration);
|
||||
columns.get(5).setMinWidth(25);
|
||||
columns.get(5).setMaxWidth(25);
|
||||
columns.get(6).setMaxWidth(300);
|
||||
*/
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"имя",
|
||||
"автор",
|
||||
"флаги"
|
||||
//"проходы"
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(SapforSettings object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.description;
|
||||
case 3:
|
||||
return object.sender_name;
|
||||
case 4:
|
||||
return object.flags;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//-
|
||||
@Override
|
||||
public DBObjectDialog<SapforSettings, SapforSettingsFields> getDialog() {
|
||||
return new DBObjectDialog<SapforSettings, SapforSettingsFields>(SapforSettingsFields.class) {
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return 415;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultWidth() {
|
||||
return 600;
|
||||
}
|
||||
@Override
|
||||
public void validateFields() {
|
||||
}
|
||||
@Override
|
||||
public void fillFields() {
|
||||
fields.tfName.setText(Result.description);
|
||||
fields.cbFREE_FORM.setSelected(Result.FREE_FORM != 0);
|
||||
fields.cbKEEP_DVM_DIRECTIVES.setSelected(Result.KEEP_DVM_DIRECTIVES != 0);
|
||||
fields.cbKEEP_SPF_DIRECTIVES.setSelected(Result.KEEP_SPF_DIRECTIVES != 0);
|
||||
fields.cbSTATIC_SHADOW_ANALYSIS.setSelected(Result.STATIC_SHADOW_ANALYSIS != 0);
|
||||
fields.sMAX_SHADOW_WIDTH.setValue(Result.MAX_SHADOW_WIDTH);
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result.description = fields.tfName.getText();
|
||||
Result.FREE_FORM = CommonUtils.fromBoolean(fields.cbFREE_FORM.isSelected());
|
||||
Result.KEEP_DVM_DIRECTIVES = CommonUtils.fromBoolean(fields.cbKEEP_DVM_DIRECTIVES.isSelected());
|
||||
Result.KEEP_SPF_DIRECTIVES = CommonUtils.fromBoolean(fields.cbKEEP_SPF_DIRECTIVES.isSelected());
|
||||
Result.STATIC_SHADOW_ANALYSIS = CommonUtils.fromBoolean(fields.cbSTATIC_SHADOW_ANALYSIS.isSelected());
|
||||
Result.MAX_SHADOW_WIDTH = fields.sMAX_SHADOW_WIDTH.getValue();
|
||||
Result.packFlags();
|
||||
}
|
||||
@Override
|
||||
public void SetReadonly() {
|
||||
fields.tfName.setEnabled(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
|
||||
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
|
||||
res.put(SapforSettingsCommand.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.TestingSystem.SAPFOR.SapforSettings.UI.SapforSettingsCommandFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="2" column-count="2" 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="4edf7" 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="40ef0">
|
||||
<constraints>
|
||||
<grid row="1" 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="64847" class="javax.swing.JComboBox" binding="cbPassCode" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" 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>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,33 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforSettings.UI;
|
||||
import Common.Visual.CommonUI;
|
||||
import Common.Visual.Tables.StyledCellLabel;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import _VisualDVM.Repository.Component.Sapfor.Sapfor;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class SapforSettingsCommandFields implements DialogFields {
|
||||
private JPanel content;
|
||||
public JComboBox<PassCode_2021> cbPassCode;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
cbPassCode = new JComboBox<>();
|
||||
cbPassCode.setRenderer((list, value, index, isSelected, cellHasFocus) -> {
|
||||
JLabel res = new StyledCellLabel();
|
||||
res.setText(value.getDescription());
|
||||
res.setBackground(isSelected ?
|
||||
CommonUI.getTheme().selection_background : CommonUI.getTheme().background
|
||||
);
|
||||
return res;
|
||||
});
|
||||
//-
|
||||
for (PassCode_2021 code : Sapfor.getScenariosCodes())
|
||||
cbPassCode.addItem(code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.TestingSystem.SAPFOR.SapforSettings.UI.SapforSettingsFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="528" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="3b4b2" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="2c43d" 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">
|
||||
<preferred-size width="284" height="20"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="16" style="2"/>
|
||||
<text value="название"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="2c147">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="284" height="14"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="7844f" class="javax.swing.JTextField" binding="tfName" 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">
|
||||
<minimum-size width="200" height="30"/>
|
||||
<preferred-size width="200" height="30"/>
|
||||
<maximum-size width="200" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="7788a" class="javax.swing.JCheckBox" binding="cbFREE_FORM">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="284" height="25"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="14" style="2"/>
|
||||
<icon value="icons/NotPick.png"/>
|
||||
<selectedIcon value="icons/Pick.png"/>
|
||||
<text value="Свободный выходной стиль"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="243fb" class="javax.swing.JCheckBox" binding="cbKEEP_SPF_DIRECTIVES">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="284" height="25"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="14" style="2"/>
|
||||
<icon value="icons/NotPick.png"/>
|
||||
<selectedIcon value="icons/Pick.png"/>
|
||||
<text value="Сохранять SPF директивы"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="16d89" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false">
|
||||
<preferred-size width="284" height="17"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="14" style="2"/>
|
||||
<text value="Максимальный размер теневых граней, %"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5eba5" class="javax.swing.JCheckBox" binding="cbSTATIC_SHADOW_ANALYSIS">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="284" height="25"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="14" style="2"/>
|
||||
<icon value="icons/NotPick.png"/>
|
||||
<selectedIcon value="icons/Pick.png"/>
|
||||
<text value="Оптимизация теневых обменов"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="27b84" class="javax.swing.JCheckBox" binding="cbKEEP_DVM_DIRECTIVES">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="284" height="25"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="Times New Roman" size="14" style="2"/>
|
||||
<icon value="icons/NotPick.png"/>
|
||||
<selectedIcon value="icons/Pick.png"/>
|
||||
<text value="Учитывать DVM директивы"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d47f0" class="javax.swing.JSlider" binding="sMAX_SHADOW_WIDTH">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="500" height="40"/>
|
||||
<preferred-size width="500" height="40"/>
|
||||
<maximum-size width="500" height="40"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<majorTickSpacing value="25"/>
|
||||
<minorTickSpacing value="1"/>
|
||||
<paintLabels value="true"/>
|
||||
<paintTicks value="true"/>
|
||||
<snapToTicks value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,23 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforSettings.UI;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class SapforSettingsFields implements DialogFields {
|
||||
private JPanel content;
|
||||
public JTextField tfName;
|
||||
public JCheckBox cbFREE_FORM;
|
||||
public JCheckBox cbKEEP_SPF_DIRECTIVES;
|
||||
public JCheckBox cbSTATIC_SHADOW_ANALYSIS;
|
||||
public JCheckBox cbKEEP_DVM_DIRECTIVES;
|
||||
public JSlider sMAX_SHADOW_WIDTH;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
tfName = new StyledTextField();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforSettingsCommand;
|
||||
import Common.CommonConstants;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.riDBObject;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
public class SapforSettingsCommand extends riDBObject {
|
||||
@Description("DEFAULT -1")
|
||||
public int sapforsettings_id = CommonConstants.Nan;
|
||||
public PassCode_2021 passCode = PassCode_2021.SPF_RemoveDvmDirectives;
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return Current.HasSapforSettings() && (Current.getSapforSettings().id == sapforsettings_id);
|
||||
}
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
SapforSettingsCommand c = (SapforSettingsCommand) src;
|
||||
sapforsettings_id = c.sapforsettings_id;
|
||||
passCode = c.passCode;
|
||||
}
|
||||
public SapforSettingsCommand() {
|
||||
}
|
||||
public SapforSettingsCommand(SapforSettingsCommand sapforSettingsCommand) {
|
||||
this.SynchronizeFields(sapforSettingsCommand);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforSettingsCommand;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class SapforSettingsCommandsBar extends DataMenuBar {
|
||||
public SapforSettingsCommandsBar() {
|
||||
super("команды",
|
||||
PassCode_2021.PublishSapforSettingsCommand,
|
||||
PassCode_2021.EditSapforSettingsCommand,
|
||||
PassCode_2021.DeleteSapforSettingsCommand
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforSettingsCommand;
|
||||
import Common.Visual.CommonUI;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.SapforSettings;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.UI.SapforSettingsCommandFields;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import java.util.Vector;
|
||||
public class SapforSettingsCommandsDBTable extends iDBTable<SapforSettingsCommand> {
|
||||
public SapforSettingsCommandsDBTable() {
|
||||
super(SapforSettingsCommand.class);
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "команда";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "команды";
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"Проход"
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(SapforSettingsCommand object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 2:
|
||||
return object.passCode.getDescription();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.SapforSettingsCommand;
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
public boolean hasCheckBox() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
//columns.get(0).setVisible(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public DBObjectDialog<SapforSettingsCommand, SapforSettingsCommandFields> getDialog() {
|
||||
return new DBObjectDialog<SapforSettingsCommand, SapforSettingsCommandFields>(SapforSettingsCommandFields.class) {
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return 250;
|
||||
}
|
||||
@Override
|
||||
public void fillFields() {
|
||||
CommonUI.TrySelect(fields.cbPassCode, Result.passCode);
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result.passCode = (PassCode_2021) fields.cbPassCode.getSelectedItem();
|
||||
Result.sapforsettings_id = Current.getSapforSettings().id;
|
||||
}
|
||||
};
|
||||
}
|
||||
//--
|
||||
public Vector<PassCode_2021> getCodes(SapforSettings sapforSettings) {
|
||||
Vector<PassCode_2021> res = new Vector<>();
|
||||
for (SapforSettingsCommand command : Data.values()) {
|
||||
if (command.sapforsettings_id == sapforSettings.id)
|
||||
res.add(command.passCode);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTask;
|
||||
import Common.Visual.StatusEnum;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
public enum ComparisonState implements StatusEnum {
|
||||
Unknown,
|
||||
NotMatch,
|
||||
Match;
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Unknown:
|
||||
return "неизвестно";
|
||||
case Match:
|
||||
return "совпадений";
|
||||
case NotMatch:
|
||||
return "различий";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public VisualiserFonts getFont() {
|
||||
switch (this) {
|
||||
case Unknown:
|
||||
return VisualiserFonts.UnknownState;
|
||||
case Match:
|
||||
return VisualiserFonts.GoodState;
|
||||
case NotMatch:
|
||||
return VisualiserFonts.BadState;
|
||||
default:
|
||||
return StatusEnum.super.getFont();
|
||||
}
|
||||
}
|
||||
}
|
||||
241
src/_VisualDVM/TestingSystem/SAPFOR/SapforTask/SapforTask.java
Normal file
241
src/_VisualDVM/TestingSystem/SAPFOR/SapforTask/SapforTask.java
Normal file
@@ -0,0 +1,241 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTask;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import _VisualDVM.GlobalData.Tasks.TaskState;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.*;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI.SapforPackageTreeNode;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI.SapforTaskNode;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI.VersionNode;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class SapforTask extends DBObject {
|
||||
//------------------------------------>>
|
||||
@Expose
|
||||
public long id = CommonConstants.Nan;
|
||||
@Expose
|
||||
public int set_id = 0;
|
||||
@Expose
|
||||
public int sapfor_configuration_id = CommonConstants.Nan;
|
||||
@Expose
|
||||
public long sapfortaskspackage_id = CommonConstants.Nan;
|
||||
//------------------------------------->>
|
||||
@Expose
|
||||
public String test_description = "";
|
||||
@Expose
|
||||
public String group_description = "";
|
||||
@Expose
|
||||
public String flags = "";
|
||||
@Expose
|
||||
public String codes = "";
|
||||
@Expose
|
||||
public long StartDate = 0; //дата начала выполнения
|
||||
@Expose
|
||||
public long ChangeDate = 0;//дата окончания выполнения
|
||||
//в json не выносить. это только для БД.
|
||||
@Description("DEFAULT ''")
|
||||
public String versionsDescription = "";
|
||||
//------
|
||||
@Description("IGNORE")
|
||||
@Expose
|
||||
public Vector<SapforVersion_json> versions = new Vector<>();
|
||||
//----------
|
||||
@Description("IGNORE")
|
||||
@Expose
|
||||
public Vector<SapforVersion_json> variants = new Vector<>();
|
||||
//-------------------------------------------------
|
||||
@Expose
|
||||
public TaskState state = TaskState.Inactive;
|
||||
@Description("IGNORE")
|
||||
public ComparisonState comparisonState = ComparisonState.Unknown; //для сравнения. в обычном режиме всегда Unknown!
|
||||
//--------------------------------------------------
|
||||
public String getUniqueKey() {
|
||||
return group_description + "_" + test_description + "_" + sapfor_configuration_id;
|
||||
}
|
||||
public String getSummary() {
|
||||
Vector<String> lines = new Vector<>();
|
||||
lines.add(group_description);
|
||||
lines.add(test_description);
|
||||
lines.add(codes);
|
||||
lines.add(flags);
|
||||
return String.join(" ", lines);
|
||||
}
|
||||
//-----------
|
||||
public SapforTask() {
|
||||
}
|
||||
public void Reset() {
|
||||
state = TaskState.Inactive;
|
||||
versions.clear();
|
||||
variants.clear();
|
||||
}
|
||||
public SapforTask(SapforTask src) {
|
||||
this.SynchronizeFields(src);
|
||||
}
|
||||
@Override
|
||||
public Object getPK() {
|
||||
return id;
|
||||
}
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject object) {
|
||||
super.SynchronizeFields(object);
|
||||
SapforTask t = (SapforTask) object;
|
||||
id = t.id;
|
||||
set_id = t.set_id;
|
||||
sapfor_configuration_id = t.sapfor_configuration_id;
|
||||
sapfortaskspackage_id = t.sapfortaskspackage_id;
|
||||
//-
|
||||
test_description = t.test_description;
|
||||
group_description = t.group_description;
|
||||
versionsDescription = t.versionsDescription;
|
||||
//--
|
||||
codes = t.codes;
|
||||
state = t.state;
|
||||
//--
|
||||
}
|
||||
public String getVersionsChain() {
|
||||
Vector<String> versionsLines = new Vector<>();
|
||||
for (int i = 1; i < versions.size(); ++i) {
|
||||
versionsLines.add(CommonUtils.Brackets(versions.get(i).description));
|
||||
}
|
||||
if (!variants.isEmpty()) {
|
||||
versionsLines.add(CommonUtils.Brackets(PassCode_2021.CreateParallelVariants.getDescription()));
|
||||
}
|
||||
return String.join("→", versionsLines);
|
||||
}
|
||||
public LinkedHashMap<String, SapforVersion_json> getSortedVersions() {
|
||||
LinkedHashMap<String, SapforVersion_json> res = new LinkedHashMap<>();
|
||||
for (SapforVersion_json version_json : versions)
|
||||
res.put(version_json.version, version_json);
|
||||
//--
|
||||
for (SapforVersion_json variant_json : variants)
|
||||
res.put(variant_json.version, variant_json);
|
||||
return res;
|
||||
}
|
||||
public void checkMatch(SapforTask task2) {
|
||||
if (!state.equals(task2.state)) {
|
||||
comparisonState = ComparisonState.NotMatch;
|
||||
task2.comparisonState = ComparisonState.NotMatch;
|
||||
}
|
||||
if ((versions.size() != task2.versions.size()) || (variants.size() != task2.variants.size())) {
|
||||
comparisonState = ComparisonState.NotMatch;
|
||||
task2.comparisonState = ComparisonState.NotMatch;
|
||||
}
|
||||
LinkedHashMap<String, SapforVersion_json> versions1 = getSortedVersions();
|
||||
LinkedHashMap<String, SapforVersion_json> versions2 = task2.getSortedVersions();
|
||||
//---
|
||||
for (String name1 : versions1.keySet()) {
|
||||
if (versions2.containsKey(name1)) {
|
||||
SapforVersion_json version1 = versions1.get(name1);
|
||||
SapforVersion_json version2 = versions2.get(name1);
|
||||
//---
|
||||
if (!version1.isMatch(version2)) {
|
||||
comparisonState = ComparisonState.NotMatch;
|
||||
task2.comparisonState = ComparisonState.NotMatch;
|
||||
version1.comparisonState = VersionComparisonState.NotMatch;
|
||||
version2.comparisonState = VersionComparisonState.NotMatch;
|
||||
//-
|
||||
}else {
|
||||
version1.comparisonState = VersionComparisonState.Match;
|
||||
version2.comparisonState = VersionComparisonState.Match;
|
||||
//-
|
||||
}
|
||||
} else {
|
||||
comparisonState = ComparisonState.NotMatch;
|
||||
task2.comparisonState = ComparisonState.NotMatch;
|
||||
//--
|
||||
}
|
||||
}
|
||||
//--
|
||||
if (comparisonState.equals(ComparisonState.Unknown)) {
|
||||
comparisonState = ComparisonState.Match;
|
||||
task2.comparisonState = ComparisonState.Match;
|
||||
}
|
||||
}
|
||||
public Date getStartDate() {
|
||||
return new Date(StartDate);
|
||||
}
|
||||
public Date getChangeDate() {
|
||||
return new Date(ChangeDate);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return
|
||||
"#" + id + " группа " + CommonUtils.Brackets(group_description) + " тест " + CommonUtils.Brackets(test_description) + " параметры " + CommonUtils.Brackets(sapfor_configuration_id);
|
||||
// getUniqueKey();
|
||||
}
|
||||
public String getPassesInfo() {
|
||||
String res = "";
|
||||
String[] data = codes.split(" ");
|
||||
Vector<String> strings = new Vector<>();
|
||||
for (String code_s : data) {
|
||||
PassCode_2021 code = PassCode_2021.valueOf(code_s);
|
||||
strings.add(CommonUtils.Brackets(code.getDescription()));
|
||||
}
|
||||
return String.join("→", strings);
|
||||
}
|
||||
//---
|
||||
public DefaultMutableTreeNode getVersionsTree() {
|
||||
VersionNode root = null;
|
||||
VersionNode child = null;
|
||||
VersionNode parent = null;
|
||||
//--
|
||||
for (SapforVersion_json version_json : versions) {
|
||||
version_json.task = this;
|
||||
child = new VersionNode(version_json);
|
||||
if (parent == null) {
|
||||
root = child;
|
||||
parent = child;
|
||||
} else {
|
||||
parent.add(child);
|
||||
parent = child;
|
||||
}
|
||||
//-
|
||||
}
|
||||
if (parent != null) {
|
||||
for (SapforVersion_json version_json : variants) {
|
||||
version_json.task = this;
|
||||
parent.add(new VersionNode(version_json));
|
||||
}
|
||||
}
|
||||
//--
|
||||
return root;
|
||||
}
|
||||
//---
|
||||
public DefaultMutableTreeNode getNode(File configurationRoot) {
|
||||
SapforPackageTreeNode res = new SapforTaskNode(this);
|
||||
//-
|
||||
DefaultMutableTreeNode flags_info = new DefaultMutableTreeNode("флаги: " + this.flags);
|
||||
DefaultMutableTreeNode passes_info = new DefaultMutableTreeNode("проходы: " + getPassesInfo());
|
||||
//-
|
||||
int total_versions_count = versions.size() + variants.size();
|
||||
DefaultMutableTreeNode versions_info = new DefaultMutableTreeNode("версии: " + total_versions_count);
|
||||
versions_info.add(getVersionsTree());
|
||||
res.add(flags_info);
|
||||
res.add(passes_info);
|
||||
res.add(versions_info);
|
||||
return res;
|
||||
}
|
||||
//-
|
||||
public SapforTask(SapforTestingSet_json testingSet, SapforTest_json test, SapforConfiguration_json sapforConfiguration_json) {
|
||||
id = CommonConstants.Nan;
|
||||
set_id = testingSet.id;
|
||||
sapfortaskspackage_id = CommonConstants.Nan;
|
||||
//-- unique key--
|
||||
group_description = test.group_description;
|
||||
test_description = test.description;
|
||||
sapfor_configuration_id = sapforConfiguration_json.id;
|
||||
//---------------
|
||||
flags = sapforConfiguration_json.flags;
|
||||
Vector<String> codes_s = new Vector<>();
|
||||
for (PassCode_2021 code : sapforConfiguration_json.codes)
|
||||
codes_s.add(code.toString());
|
||||
codes = String.join(" ", codes_s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import _VisualDVM.Visual.Menus.VisualiserMenu;
|
||||
public class AddSapforPackageMenu extends VisualiserMenu {
|
||||
public AddSapforPackageMenu() {
|
||||
super("", "/icons/RedAdd.png");
|
||||
// addPasses(PassCode_2021.AddSapforPackage,PassCode_2021.CloneSapforPackage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
public class PackageComparisonSummary extends SapforPackageTreeNode {
|
||||
public int count = 0;
|
||||
public int mismatches_count = 0;
|
||||
@Override
|
||||
public String getImageKey() {
|
||||
return "Package";
|
||||
}
|
||||
public PackageComparisonSummary() {
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "всего задач : " + count + ", различий : " + mismatches_count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
public class PackageSummary extends SapforPackageTreeNode {
|
||||
public int count = 0;
|
||||
public int errors_count=0;
|
||||
@Override
|
||||
public String getImageKey() {
|
||||
return "Package";
|
||||
}
|
||||
public PackageSummary() {
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "всего задач : " + count+", с ошибками : "+errors_count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import Common.Utils.CommonUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
public abstract class SapforPackageTreeNode extends DefaultMutableTreeNode {
|
||||
public ImageIcon getIcon() {
|
||||
ImageIcon res = new ImageIcon((getClass().getResource("/icons/versions/" + getImageKey() + ".png")));
|
||||
if (res==null) {
|
||||
CommonUtils.MainLog.Print("/icons/versions/" + getImageKey() + ".png=NULL");
|
||||
// res= new ImageIcon((getClass().getResource("/icons/versions/Version.png")));
|
||||
}
|
||||
return (getImageKey() != null) ? res : null;
|
||||
}
|
||||
public abstract String getImageKey();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Common.Visual.Controls.MenuBarButton;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackageDBTable;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
public class SapforPackagesBar extends DataMenuBar {
|
||||
public SapforPackagesBar() {
|
||||
super("пакеты задач SAPFOR");
|
||||
addPasses(PassCode_2021.SynchronizeTests);
|
||||
addSeparator();
|
||||
addPasses(PassCode_2021.AbortSapforPackage);
|
||||
addSeparator();
|
||||
addPasses(PassCode_2021.CompareSapforPackages);
|
||||
addSeparator();
|
||||
addPasses(PassCode_2021.DeleteSapforPackage);
|
||||
add(new JSeparator());
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setText("Свои");
|
||||
setToolTipText("Отображать только пакеты тестов авторства пользователя");
|
||||
Mark();
|
||||
addActionListener(e -> {
|
||||
SapforPackageDBTable.filterMyOnly = !SapforPackageDBTable.filterMyOnly;
|
||||
Mark();
|
||||
Global.testingServer.db.sapforPackages.ShowUI();
|
||||
});
|
||||
}
|
||||
public void Mark() {
|
||||
setIcon(CommonUtils.getIcon(SapforPackageDBTable.filterMyOnly ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
}
|
||||
});
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setText("Активные");
|
||||
setToolTipText("Отображать только активные пакеты тестов");
|
||||
Mark();
|
||||
addActionListener(e -> {
|
||||
SapforPackageDBTable.filterActive = !SapforPackageDBTable.filterActive;
|
||||
Mark();
|
||||
Global.testingServer.db.sapforPackages.ShowUI();
|
||||
});
|
||||
}
|
||||
public void Mark() {
|
||||
setIcon(CommonUtils.getIcon(SapforPackageDBTable.filterActive ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.ComparisonState;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
public class SapforTaskNode extends SapforPackageTreeNode {
|
||||
public SapforTaskNode(SapforTask task_in) {
|
||||
setUserObject(task_in);
|
||||
}
|
||||
@Override
|
||||
public String getImageKey() {
|
||||
SapforTask task = (SapforTask) getUserObject();
|
||||
//обычный режим
|
||||
if (task.comparisonState == ComparisonState.Unknown) {
|
||||
return task.state.toString();
|
||||
}
|
||||
//режим сравнения.
|
||||
else {
|
||||
return task.comparisonState.toString()+task.state.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import Common.CurrentAnchestor;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Visual.Trees.DataTree;
|
||||
import Common.Visual.Trees.TreeRenderers;
|
||||
import _VisualDVM.Visual.UI;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforVersion_json;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.util.Vector;
|
||||
public class SapforTasksPackageTree extends DataTree {
|
||||
Current current;
|
||||
SapforTasksPackageTree slave_tree = null;
|
||||
public void setSlaveTree(SapforTasksPackageTree slave_tree_in) {
|
||||
slave_tree = slave_tree_in;
|
||||
}
|
||||
public SapforTasksPackageTree(DefaultMutableTreeNode root_in, Current current_in) {
|
||||
super(root_in);
|
||||
current = current_in;
|
||||
}
|
||||
@Override
|
||||
protected int getStartLine() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public TreeRenderers getRenderer() {
|
||||
return TreeRenderers.RendererSapforVersion;
|
||||
}
|
||||
@Override
|
||||
public Current getCurrent() {
|
||||
return current;
|
||||
}
|
||||
public void selectSamePath_r(TreePath example, int index, DefaultMutableTreeNode node, Vector<DefaultMutableTreeNode> res) {
|
||||
if (index < example.getPathCount()) {
|
||||
DefaultMutableTreeNode exampleNode = (DefaultMutableTreeNode) example.getPathComponent(index);
|
||||
if (exampleNode.toString().equals(node.toString())) {
|
||||
res.add(node);
|
||||
for (int i = 0; i < node.getChildCount(); ++i)
|
||||
selectSamePath_r(example, index + 1, (DefaultMutableTreeNode) node.getChildAt(i), res);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void selectSamePath(TreePath path_in) {
|
||||
Vector<DefaultMutableTreeNode> pathNodes = new Vector<>();
|
||||
selectSamePath_r(path_in, 0, root, pathNodes);
|
||||
if (!pathNodes.isEmpty()) {
|
||||
TreePath path = new TreePath(pathNodes.toArray());
|
||||
setSelectionPath(path);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void SelectionAction(TreePath e) {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastPathComponent();
|
||||
Object o = node.getUserObject();
|
||||
//---
|
||||
if (slave_tree != null) {
|
||||
slave_tree.selectSamePath(e);
|
||||
}
|
||||
//---
|
||||
if (o instanceof SapforVersion_json) {
|
||||
SapforVersion_json version = (SapforVersion_json) o;
|
||||
CurrentAnchestor.set(current, version);
|
||||
if (current.equals(Current.SapforEtalonVersion))
|
||||
UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersionEtalon();
|
||||
else
|
||||
UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersion();
|
||||
//--
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import Common.Visual.Trees.StyledTreeCellRenderer;
|
||||
|
||||
import javax.swing.*;
|
||||
public class SapforVersionsTreeCellRenderer extends StyledTreeCellRenderer {
|
||||
public java.awt.Component getTreeCellRendererComponent(
|
||||
JTree tree, Object value,
|
||||
boolean selected, boolean expanded,
|
||||
boolean leaf, int row, boolean hasFocus) {
|
||||
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
|
||||
if (value instanceof SapforPackageTreeNode) {
|
||||
SapforPackageTreeNode node = (SapforPackageTreeNode) value;
|
||||
setForeground(tree.getForeground());
|
||||
setFont(getFont().deriveFont((float) 14.0));
|
||||
if (node.getIcon() != null)
|
||||
setIcon(node.getIcon());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import javax.swing.*;
|
||||
import java.util.Objects;
|
||||
public abstract class TreeSummary {
|
||||
public String text = "";
|
||||
public abstract void refreshText();
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
public ImageIcon getIcon() {
|
||||
return new ImageIcon(Objects.requireNonNull(getClass().getResource("/icons/versions/" + getImageKey() + ".png")));
|
||||
}
|
||||
public abstract String getImageKey();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforVersionState;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforVersion_json;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.VersionComparisonState;
|
||||
public class VersionNode extends SapforPackageTreeNode {
|
||||
public VersionNode(SapforVersion_json version_json) {
|
||||
setUserObject(version_json);
|
||||
}
|
||||
@Override
|
||||
public String getImageKey() {
|
||||
SapforVersion_json version = (SapforVersion_json) getUserObject();
|
||||
String res = "";
|
||||
if (version.comparisonState.equals(VersionComparisonState.Unknown)||version.state.equals(SapforVersionState.Empty)){
|
||||
res = version.state.toString();
|
||||
}else {
|
||||
res = version.comparisonState.toString()+version.state.toString();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
286
src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.java
Normal file
286
src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.java
Normal file
@@ -0,0 +1,286 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR;
|
||||
import Common.CommonConstants;
|
||||
import Common.Mode;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.GlobalProperties;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.Repository.Component.Sapfor.Sapfor;
|
||||
import _VisualDVM.Repository.EmailMessage;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import _VisualDVM.TestingSystem.Common.TasksPackageState;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPlanner;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforConfiguration_json;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforTest_json;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforTestingSet_json;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
|
||||
import _VisualDVM.Global;
|
||||
import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
|
||||
File workspace;
|
||||
ServerSapfor sapfor;
|
||||
//--
|
||||
File repo;
|
||||
File repoSapforHome;
|
||||
int max_version;
|
||||
int current_version;
|
||||
//--
|
||||
File repo_bin;
|
||||
File repo_out;
|
||||
File repo_err;
|
||||
//--
|
||||
public SapforTestingPlanner() {
|
||||
repo = new File(CommonUtils.getHomeDirectory(), "Repo");
|
||||
repoSapforHome = Paths.get(CommonUtils.getHomePath(), "Repo", Constants.SAPFOR_REPOSITORY_BIN).toFile();
|
||||
repo_bin = new File(repoSapforHome, "Sapfor_F");
|
||||
repo_out = new File(repoSapforHome, Constants.out_file);
|
||||
repo_err = new File(repoSapforHome, Constants.err_file);
|
||||
}
|
||||
@Override
|
||||
public String packageDescription() {
|
||||
return "SAPFOR";
|
||||
}
|
||||
@Override
|
||||
protected ServerCode getActivePackagesCode() {
|
||||
return ServerCode.GetFirstActiveSapforPackages;
|
||||
}
|
||||
@Override
|
||||
protected ServerCode getCheckIfNeedsKillCode() {
|
||||
return ServerCode.SapforPackageNeedsKill;
|
||||
}
|
||||
@Override
|
||||
protected TasksPackageState getStateAfterStart() {
|
||||
return TasksPackageState.RunningExecution;
|
||||
}
|
||||
@Override
|
||||
protected void InitSessionCredentials() {
|
||||
workspace = testingPackage.getLocalWorkspace();
|
||||
}
|
||||
@Override
|
||||
protected void TestsSynchronize() throws Exception {
|
||||
testingPackage.readJson();
|
||||
//--
|
||||
for (SapforTestingSet_json set_json : testingPackage.package_json.testingSets) {
|
||||
File setWorkspace = new File(workspace, String.valueOf(set_json.id));
|
||||
FileUtils.forceMkdir(setWorkspace);
|
||||
//копирование тестов по конфигурациям.
|
||||
for (SapforConfiguration_json configuration_json : set_json.configurations) {
|
||||
//--
|
||||
File configurationWorkspace = new File(setWorkspace, String.valueOf(configuration_json.id));
|
||||
FileUtils.forceMkdir(configurationWorkspace);
|
||||
//--->>>
|
||||
for (SapforTest_json test_json : set_json.tests) {
|
||||
File test_root = new File(configurationWorkspace, test_json.description);
|
||||
Utils.CheckAndCleanDirectory(test_root);
|
||||
FileUtils.copyDirectory(new File(Global.TestsDirectory, String.valueOf(test_json.id)), test_root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void PackageWorkspaceCreation() throws Exception {
|
||||
//копирование визуализатора
|
||||
File visualiser = new File(workspace, "VisualSapfor.jar");
|
||||
FileUtils.copyFile(new File(CommonUtils.getHomeDirectory(), "_VisualDVM.TestingSystem.jar"), visualiser);
|
||||
//создание настроек
|
||||
GlobalProperties properties = new GlobalProperties(Global.properties);
|
||||
properties.Mode = Mode.Package;
|
||||
CommonUtils.jsonToFile(properties, new File(workspace, "properties"));
|
||||
//подготовка пакетного режима. Запустит его уже очередь.
|
||||
Utils.createScript(workspace, workspace, "start", "java -jar VisualSapfor.jar");
|
||||
}
|
||||
@Override
|
||||
protected void PackageStart() throws Exception {
|
||||
File script = new File(workspace, "start");
|
||||
ProcessBuilder procBuilder = new ProcessBuilder(script.getAbsolutePath());
|
||||
procBuilder.directory(workspace);
|
||||
procBuilder.start();
|
||||
//--->>
|
||||
File started = new File(workspace, Constants.STARTED);
|
||||
while (!started.exists()) {
|
||||
Print("waiting for package start...");
|
||||
CommonUtils.sleep(1000);
|
||||
}
|
||||
File pid = new File(workspace, "PID");
|
||||
testingPackage.PID = FileUtils.readFileToString(pid, Charset.defaultCharset());
|
||||
}
|
||||
@Override
|
||||
protected boolean CheckNextState() throws Exception {
|
||||
boolean progress_changed = false;
|
||||
boolean state_changed = false;
|
||||
//--
|
||||
File workspace = testingPackage.getLocalWorkspace();
|
||||
//--
|
||||
File progress = new File(workspace, "progress");
|
||||
if (progress.exists()) {
|
||||
String s = FileUtils.readFileToString(progress);
|
||||
int current_progress = Integer.parseInt(s);
|
||||
if (current_progress != testingPackage.progress) {
|
||||
Print("progress changed: " + current_progress);
|
||||
testingPackage.progress = current_progress;
|
||||
progress_changed = true;
|
||||
}
|
||||
}
|
||||
//--
|
||||
File done = new File(workspace, Constants.DONE);
|
||||
File aborted = new File(workspace, Constants.ABORTED);
|
||||
if (done.exists()) {
|
||||
testingPackage.state = TasksPackageState.Analysis;
|
||||
state_changed = true;
|
||||
} else if (aborted.exists()) {
|
||||
testingPackage.state = TasksPackageState.Aborted;
|
||||
state_changed = true;
|
||||
}
|
||||
return progress_changed || state_changed;
|
||||
}
|
||||
@Override
|
||||
protected void DownloadResults() throws Exception {
|
||||
//не требуется.
|
||||
}
|
||||
@Override
|
||||
protected void AnalyseResults() throws Exception {
|
||||
//не требуется.
|
||||
testingPackage.progress = 100;
|
||||
testingPackage.checkFinishState();
|
||||
UpdatePackageState();
|
||||
}
|
||||
@Override
|
||||
protected void Kill() throws Exception {
|
||||
File workspace = testingPackage.getLocalWorkspace();
|
||||
//----
|
||||
File interrupt_file = new File(workspace, Constants.INTERRUPT);
|
||||
//----
|
||||
FileUtils.writeStringToFile(interrupt_file, new Date().toString());
|
||||
File aborted_file = new File(workspace, Constants.ABORTED);
|
||||
do {
|
||||
Print("waiting for interrupt...");
|
||||
Thread.sleep(1000);
|
||||
} while (!aborted_file.exists());
|
||||
Print("coup de grace..");
|
||||
String kill_command = "killall -SIGKILL " + testingPackage.PID;
|
||||
Print(kill_command);
|
||||
Process killer = Runtime.getRuntime().exec(kill_command);
|
||||
killer.waitFor();
|
||||
Print("done!");
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
public void perform() throws Exception {
|
||||
checkServerSapforsForCompilation();
|
||||
super.perform();
|
||||
}
|
||||
//--------------------
|
||||
public void getServerSapforForCompilation() throws Exception {
|
||||
sapfor = (ServerSapfor) ServerCommand(ServerCode.GetSapforForCompilation);
|
||||
}
|
||||
void UpdateSapforState(ServerSapforState state_in) throws Exception {
|
||||
sapfor.state = state_in;
|
||||
ServerCommand(ServerCode.EditObject, sapfor);
|
||||
}
|
||||
void SyncronizeRepository() throws Exception {
|
||||
UpdateSapforState(ServerSapforState.DVMRepositorySynchronization);
|
||||
Utils.startScript(repo, repo, "dvm_checkout",
|
||||
"svn checkout " +
|
||||
Constants.REPOSITORY_AUTHENTICATION +
|
||||
" " + Constants.DVM_REPOSITORY + " 1>dvm_out.txt 2>dvm_err.txt\n").waitFor();
|
||||
UpdateSapforState(ServerSapforState.SAPFORRepositorySynchronization);
|
||||
Utils.startScript(repo, repo, "spf_checkout",
|
||||
"svn checkout " +
|
||||
Constants.REPOSITORY_AUTHENTICATION +
|
||||
" " + Constants.SAPFOR_REPOSITORY + " 1>spf_out.txt 2>spf_err.txt\n").waitFor();
|
||||
}
|
||||
void CompileSapfor() throws Exception {
|
||||
UpdateSapforState(ServerSapforState.Compilation);
|
||||
//-
|
||||
if (repo_bin.exists())
|
||||
FileUtils.forceDelete(repo_bin);
|
||||
if (repo_out.exists())
|
||||
FileUtils.forceDelete(repo_out);
|
||||
if (repo_err.exists())
|
||||
FileUtils.forceDelete(repo_err);
|
||||
//--
|
||||
Utils.startScript(repoSapforHome, repoSapforHome, "build_sapfor",
|
||||
"cmake ../ 1>" +
|
||||
Constants.out_file +
|
||||
" 2>" +
|
||||
Constants.err_file +
|
||||
"\nmake -j 14 1>>" +
|
||||
Constants.out_file +
|
||||
" 2>>" +
|
||||
Constants.err_file +
|
||||
"\n").waitFor();
|
||||
}
|
||||
//--------------------
|
||||
public void checkServerSapforsForCompilation() throws Exception {
|
||||
sapfor = null;
|
||||
getServerSapforForCompilation();
|
||||
if (sapfor != null) {
|
||||
//---
|
||||
max_version = CommonConstants.Nan;
|
||||
current_version = CommonConstants.Nan;
|
||||
//--
|
||||
SyncronizeRepository();
|
||||
max_version = (int) ServerCommand(ServerCode.GetMaxSapforVersion);
|
||||
current_version = Sapfor.readVersionFromCode(Paths.get(repo.getAbsolutePath(), "/sapfor/experts/Sapfor_2017/_src/Utils/version.h").toFile());
|
||||
if (current_version==max_version){
|
||||
ServerCommand(ServerCode.DeleteObjectByPK, new Pair(ServerSapfor.class,sapfor.id));
|
||||
return;
|
||||
}
|
||||
//-
|
||||
File sapforHome = new File(Global.SapforsDirectory, CommonUtils.getDateName("sapfor"));
|
||||
//--
|
||||
sapfor.home_path = sapforHome.getAbsolutePath();
|
||||
sapfor.languageName = LanguageName.fortran;
|
||||
//--
|
||||
File sapforBin = new File(sapforHome, "Sapfor_F");
|
||||
File sapforOut = new File(sapforHome, Constants.out_file);
|
||||
File sapforErr = new File(sapforHome, Constants.err_file);
|
||||
//-
|
||||
CompileSapfor();
|
||||
sapforHome.mkdir();
|
||||
//--
|
||||
if (repo_out.exists())
|
||||
FileUtils.copyFile(repo_out, sapforOut);
|
||||
if (repo_err.exists())
|
||||
FileUtils.copyFile(repo_err, sapforErr);
|
||||
if (repo_bin.exists()) {
|
||||
FileUtils.copyFile(repo_bin, sapforBin);
|
||||
sapforBin.setExecutable(true, false);
|
||||
//--
|
||||
sapfor.version= String.valueOf(current_version);
|
||||
sapfor.call_command = sapforBin.getAbsolutePath();
|
||||
sapfor.buildDate = new Date().getTime();
|
||||
//--
|
||||
UpdateSapforState(ServerSapforState.Done);
|
||||
EmailSapforAssembly(current_version, true, sapforOut, sapforErr);
|
||||
//запуск автоматического тестирования.
|
||||
ServerCommand(ServerCode.PerformAutoSapforTesting, String.valueOf(sapfor.id), null);
|
||||
} else {
|
||||
UpdateSapforState(ServerSapforState.DoneWithErrors);
|
||||
EmailSapforAssembly(current_version, false, sapforOut, sapforErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
void EmailSapforAssembly(int version, boolean done, File out, File err) throws Exception {
|
||||
String version_s = (version == CommonConstants.Nan) ? "?" : String.valueOf(version);
|
||||
String status = done ? "Успешно" : "С ошибками";
|
||||
//-
|
||||
EmailMessage message = new EmailMessage(
|
||||
"Выполнена сборка системы SAPFOR",
|
||||
"Версия: " + version_s + "\n" + "Статус: " + status,
|
||||
new Vector<>()
|
||||
);
|
||||
//-
|
||||
ServerCommand(ServerCode.Email, "", message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.ServerSapfor;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.riDBObject;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import java.util.Date;
|
||||
public class ServerSapfor extends riDBObject {
|
||||
//--------------------------------------------------------------------->>>
|
||||
@Description("IGNORE")
|
||||
public static String version_command = "-ver";//команда запроса версии компилятора.
|
||||
@Description("IGNORE")
|
||||
public static String help_command = "-help";// команда запроса help
|
||||
//--------------------------------------------------------------------->>>
|
||||
public LanguageName languageName = LanguageName.fortran;
|
||||
public String home_path = ""; //домашняя папка.
|
||||
public String call_command = ""; //полная команда вызова.
|
||||
public String version = "?";
|
||||
public long buildDate = 0;
|
||||
@Description("DEFAULT 'Done'")
|
||||
public ServerSapforState state = ServerSapforState.Done;
|
||||
public Date getBuildDate() {
|
||||
return new Date(buildDate);
|
||||
}
|
||||
//--
|
||||
public ServerSapfor() {
|
||||
}
|
||||
public ServerSapfor(ServerSapfor s) {
|
||||
SynchronizeFields(s);
|
||||
}
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
ServerSapfor s = (ServerSapfor) src;
|
||||
languageName = s.languageName;
|
||||
home_path = s.home_path;
|
||||
call_command = s.call_command;
|
||||
version = s.version;
|
||||
buildDate = s.buildDate;
|
||||
state = s.state;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return call_command;
|
||||
}
|
||||
public String getVersionCommand() {
|
||||
return CommonUtils.DQuotes(call_command) + " " + version_command;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.ServerSapfor;
|
||||
import Common.Visual.StatusEnum;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
public enum ServerSapforState implements StatusEnum {
|
||||
Queued,
|
||||
DVMRepositorySynchronization,
|
||||
SAPFORRepositorySynchronization,
|
||||
Compilation,
|
||||
Done,
|
||||
DoneWithErrors;
|
||||
@Override
|
||||
public VisualiserFonts getFont() {
|
||||
switch (this){
|
||||
case Queued:
|
||||
return VisualiserFonts.UnknownState;
|
||||
case Done:
|
||||
return VisualiserFonts.GoodState;
|
||||
case DoneWithErrors:
|
||||
return VisualiserFonts.BadState;
|
||||
case Compilation:
|
||||
case DVMRepositorySynchronization:
|
||||
case SAPFORRepositorySynchronization:
|
||||
return VisualiserFonts.ProgressState;
|
||||
default:
|
||||
return VisualiserFonts.UnknownState;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Queued:
|
||||
return "в очереди";
|
||||
case DVMRepositorySynchronization:
|
||||
return "синхронизация репозитория DVM";
|
||||
case SAPFORRepositorySynchronization:
|
||||
return "синхронизация репозитория SAPFOR";
|
||||
case Compilation:
|
||||
return "сборка";
|
||||
case Done:
|
||||
return "успешно";
|
||||
case DoneWithErrors:
|
||||
return "с ошибками";
|
||||
default:
|
||||
return StatusEnum.super.getDescription();
|
||||
}
|
||||
}
|
||||
public boolean isActive(){
|
||||
switch (this){
|
||||
case Done:
|
||||
case DoneWithErrors:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.ServerSapfor;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class ServerSapforsBar extends DataMenuBar {
|
||||
public ServerSapforsBar() {
|
||||
super("версии SAPFOR",
|
||||
PassCode_2021.CompileServerSapfor,
|
||||
PassCode_2021.ShowSapforCompilationOut,
|
||||
PassCode_2021.ShowSapforCompilationErr,
|
||||
PassCode_2021.DeleteServerSapfor
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package _VisualDVM.TestingSystem.SAPFOR.ServerSapfor;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Tables.TableRenderers;
|
||||
import _VisualDVM.Visual.UI;
|
||||
|
||||
import java.util.Comparator;
|
||||
public class ServerSapforsDBTable extends iDBTable<ServerSapfor> {
|
||||
public ServerSapforsDBTable() {
|
||||
super(ServerSapfor.class);
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "SAPFOR";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "SAPFOR";
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.ServerSapfor;
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{"версия","автор", "дата сборки", "сборка"};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(ServerSapfor object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 1:
|
||||
return object.version;
|
||||
case 2:
|
||||
return object.sender_name;
|
||||
case 3:
|
||||
return object.getBuildDate();
|
||||
case 4:
|
||||
return object.state;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
// columns.get(0).setVisible(false);
|
||||
columns.get(3).setRenderer(TableRenderers.RendererDate);
|
||||
columns.get(4).setRenderer(TableRenderers.RendererStatusEnum);
|
||||
}
|
||||
@Override
|
||||
public void ShowCurrentObject() throws Exception {
|
||||
super.ShowCurrentObject();
|
||||
UI.getMainWindow().getTestingWindow().ShowCurrentServerSapfor();
|
||||
}
|
||||
@Override
|
||||
public void ShowNoCurrentObject() throws Exception {
|
||||
super.ShowNoCurrentObject();
|
||||
UI.getMainWindow().getTestingWindow().ShowNoServerSapfor();
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Comparator<ServerSapfor> getComparator() {
|
||||
return new Comparator<ServerSapfor>() {
|
||||
@Override
|
||||
public int compare(ServerSapfor o1, ServerSapfor o2) {
|
||||
return o2.id-o1.id;
|
||||
}
|
||||
};
|
||||
// return Comparator.comparingInt(o -> o.).reversed();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user