запись результатов тестирования в бд
This commit is contained in:
5553
.idea/workspace.xml
generated
5553
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
@@ -25,8 +25,8 @@ public enum ServerCode {
|
||||
GetTestProject,
|
||||
StartTests,
|
||||
//-
|
||||
CompareSapforPackages,
|
||||
RefreshDVMTests, //- для админа. получение тестов из репозитория.
|
||||
PublishSapforPackageTasks,
|
||||
//-
|
||||
PublishObject,
|
||||
CopyObjects, //использовать с осторожностью. проверять CopyAction на тему первичного ключа.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package SapforTestingSystem.Json;
|
||||
import com.google.gson.annotations.Expose;
|
||||
public class SapforVersion_json {
|
||||
|
||||
import java.io.Serializable;
|
||||
public class SapforVersion_json implements Serializable {
|
||||
@Expose
|
||||
public String version = "";
|
||||
@Expose
|
||||
|
||||
@@ -66,7 +66,7 @@ public class PackageModeSupervisor extends ThreadsPlanner {
|
||||
//--
|
||||
for (SapforTask task : results_json.tasks) {
|
||||
//--
|
||||
task.files = new Vector<>();
|
||||
task.filesList = new Vector<>();
|
||||
//--
|
||||
if (task.versions.size() > 1) {
|
||||
SapforVersion_json correctness = task.versions.get(1); //0 - исходная, 1 коррекция стиля кода.
|
||||
@@ -80,7 +80,7 @@ public class PackageModeSupervisor extends ThreadsPlanner {
|
||||
pf.file = file;
|
||||
pf.AutoDetectProperties();
|
||||
if (pf.fileType != FileType.forbidden)
|
||||
task.files.add(pf.file.getName());
|
||||
task.filesList.add(pf.file.getName());
|
||||
}
|
||||
}
|
||||
//--
|
||||
|
||||
@@ -55,7 +55,6 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
parentTask = Paths.get(Global.Home, sapforConfiguration_json.id, target.test_description).toFile();
|
||||
task = null;
|
||||
//--->>
|
||||
target.root = parentTask.getAbsolutePath();
|
||||
return true;
|
||||
}
|
||||
protected static boolean checkLines(Vector<String> lines) {
|
||||
@@ -342,7 +341,10 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
//-------------------------------------------------->>
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
target.versions.add(new SapforVersion_json(target.root, "исходная"));
|
||||
target.versions.add(new SapforVersion_json(
|
||||
Paths.get(Global.Home,
|
||||
sapforConfiguration_json.id,
|
||||
target.test_description).toFile().getAbsolutePath(), "исходная"));
|
||||
for (PassCode_2021 code : sapforConfiguration_json.codes) {
|
||||
if (parse()) {
|
||||
if (code.equals(PassCode_2021.CreateParallelVariants))
|
||||
|
||||
@@ -4,6 +4,7 @@ import Common.Database.DBObject;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Tasks.TaskState;
|
||||
import SapforTestingSystem.Json.SapforVersion_json;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -20,6 +21,8 @@ public class SapforTask extends DBObject {
|
||||
@Description("DEFAULT '-1'")
|
||||
@Expose
|
||||
public String sapfor_configuration_id = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String sapfortaskspackage_id = "";
|
||||
//------------------------------------->>
|
||||
@Description("DEFAULT ''")
|
||||
@Expose
|
||||
@@ -33,16 +36,18 @@ public class SapforTask extends DBObject {
|
||||
@Description("DEFAULT ''")
|
||||
@Expose
|
||||
public String codes = "";
|
||||
@Description("DEFAULT ''")
|
||||
@Expose
|
||||
public String root = "";
|
||||
@Description("DEFAULT 'Inactive'")
|
||||
@Expose
|
||||
public TaskState state = TaskState.Inactive;
|
||||
//в json не выносить. это только для БД.
|
||||
@Description("DEFAULT ''")
|
||||
public String files = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String versionsDescription = "";
|
||||
//------
|
||||
//-----------
|
||||
@Description("IGNORE")
|
||||
@Expose
|
||||
public List<String> files = new Vector<>(); //файлы проекта.Брать из коррекции стиля кода. есть первой версия
|
||||
public List<String> filesList = new Vector<>(); //файлы проекта.Брать из коррекции стиля кода. есть первой версия
|
||||
//-------------------------------------->>
|
||||
@Description("IGNORE")
|
||||
@Expose
|
||||
@@ -55,9 +60,8 @@ public class SapforTask extends DBObject {
|
||||
public SapforTask() {
|
||||
}
|
||||
public void Reset() {
|
||||
root = "";
|
||||
state = TaskState.Inactive;
|
||||
files.clear();
|
||||
filesList.clear();
|
||||
versions.clear();
|
||||
variants.clear();
|
||||
}
|
||||
@@ -74,14 +78,25 @@ public class SapforTask extends DBObject {
|
||||
SapforTask t = (SapforTask) object;
|
||||
id = t.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;
|
||||
//--
|
||||
files = t.files;
|
||||
codes = t.codes;
|
||||
state = t.state;
|
||||
//--
|
||||
}
|
||||
public String getVersionsChain() {
|
||||
Vector<String> versionsLines = new Vector<>();
|
||||
for (int i = 1; i < versions.size(); ++i) {
|
||||
versionsLines.add(Utils.Brackets(versions.get(i).description));
|
||||
}
|
||||
if (!variants.isEmpty()) {
|
||||
versionsLines.add(Utils.Brackets(PassCode_2021.CreateParallelVariants.getDescription()));
|
||||
}
|
||||
return String.join("→", versionsLines);
|
||||
}
|
||||
public static boolean compareVersionsFiles(SapforVersion_json version1, SapforVersion_json version2, List<String> files) throws Exception {
|
||||
@@ -105,10 +120,10 @@ public class SapforTask extends DBObject {
|
||||
}
|
||||
public boolean Compare(SapforTask task, Vector<String> comparisonLog) throws Exception {
|
||||
//1. сравнить списки файлов. без учета порядка.
|
||||
if (files.size() != task.files.size())
|
||||
if (filesList.size() != task.filesList.size())
|
||||
return false;
|
||||
for (String file1 : files) {
|
||||
if (!task.files.contains(file1)) {
|
||||
for (String file1 : filesList) {
|
||||
if (!task.filesList.contains(file1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -124,7 +139,7 @@ public class SapforTask extends DBObject {
|
||||
SapforVersion_json version1 = versions.get(i);
|
||||
SapforVersion_json version2 = task.versions.get(i);
|
||||
//--
|
||||
if (!compareVersionsFiles(version1, version2, files)) return false;
|
||||
if (!compareVersionsFiles(version1, version2, filesList)) return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ public class SapforTasksPackage extends nDBObject {
|
||||
public String testsIds = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String configurationsIds = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String summary = "";
|
||||
// допустимые состояния
|
||||
//Queued
|
||||
//PackageStart
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package SapforTestingSystem.SapforTasksPackage;
|
||||
import Common.Global;
|
||||
|
||||
import java.io.File;
|
||||
public class SapforTasksPackageInterface {
|
||||
public static File getPackageArchive(SapforTasksPackage package_in){
|
||||
return new File(Global.SapforPackagesDirectory, package_in.workspace+".zip");
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package SapforTestingSystem.SapforTasksPackage;
|
||||
import Common.Current;
|
||||
import Common.Database.DBTable;
|
||||
import Common.Database.*;
|
||||
import Common.UI.DataSetControlForm;
|
||||
import SapforTestingSystem.SapforTask.SapforTask;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import static Common.UI.Tables.TableRenderers.RendererDate;
|
||||
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
|
||||
@@ -77,12 +79,11 @@ public class SapforTasksPackagesDBTable extends DBTable<String, SapforTasksPacka
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
@Override
|
||||
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
|
||||
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
|
||||
res.put(SapforTasksPackage.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
||||
res.put(SapforTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
||||
return res;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@ import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.GlobalProperties;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Tasks.TaskState;
|
||||
import Repository.Server.ServerCode;
|
||||
import SapforTestingSystem.Json.SapforConfiguration_json;
|
||||
import SapforTestingSystem.Json.SapforTasksPackage_json;
|
||||
import SapforTestingSystem.Json.SapforTasksResults_json;
|
||||
import SapforTestingSystem.Json.SapforTest_json;
|
||||
import SapforTestingSystem.SapforConfiguration.SapforConfiguration;
|
||||
import SapforTestingSystem.SapforConfiguration.SapforConfigurationInterface;
|
||||
import SapforTestingSystem.SapforTask.SapforTask;
|
||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||
import TestingSystem.Group.Group;
|
||||
import TestingSystem.TasksPackage.TasksPackageState;
|
||||
@@ -139,9 +142,9 @@ public class SapforTasksPackageSupervisor {
|
||||
File done = new File(sapforTasksPackage.workspace, Constants.DONE);
|
||||
File aborted = new File(sapforTasksPackage.workspace, Constants.ABORTED);
|
||||
if (done.exists()) {
|
||||
sapforTasksPackage.state = TasksPackageState.Done;
|
||||
sapforTasksPackage.state = TasksPackageState.Analysis;
|
||||
planner.UpdateSapforPackage();
|
||||
System.out.println("package done");
|
||||
System.out.println("package done, start Analysis");
|
||||
} else if (aborted.exists()) {
|
||||
sapforTasksPackage.state = TasksPackageState.Aborted;
|
||||
planner.UpdateSapforPackage();
|
||||
@@ -171,6 +174,95 @@ public class SapforTasksPackageSupervisor {
|
||||
killer.waitFor();
|
||||
System.out.println("done!");
|
||||
}
|
||||
public void AnalysePackage() throws Exception {
|
||||
Vector<String> summary_lines = new Vector<>();
|
||||
File results_json_file = new File(sapforTasksPackage.workspace, Constants.results_json);
|
||||
if (results_json_file.exists()) {
|
||||
SapforTasksResults_json results_json = (SapforTasksResults_json) Utils.jsonFromFile(results_json_file, SapforTasksResults_json.class);
|
||||
summary_lines.add("Всего задач: " + results_json.tasks.size());
|
||||
LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> sortedTasks = new LinkedHashMap<>();
|
||||
//рассортировать задачи по конфигурациям.
|
||||
for (TaskState state : TaskState.values()) {
|
||||
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByFlags = new LinkedHashMap<>();
|
||||
sortedTasks.put(state, tasksByFlags);
|
||||
//--
|
||||
for (SapforTask task : results_json.tasks) {
|
||||
task.sapfortaskspackage_id = sapforTasksPackage.id;
|
||||
if (task.state.equals(state)) {
|
||||
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = null;
|
||||
if (tasksByFlags.containsKey(task.flags)) {
|
||||
groups_tasks = tasksByFlags.get(task.flags);
|
||||
} else {
|
||||
groups_tasks = new LinkedHashMap<>();
|
||||
tasksByFlags.put(task.flags, groups_tasks);
|
||||
}
|
||||
Vector<SapforTask> tasks = null;
|
||||
if (groups_tasks.containsKey(task.group_description)) {
|
||||
tasks = groups_tasks.get(task.group_description);
|
||||
} else {
|
||||
tasks = new Vector<>();
|
||||
groups_tasks.put(task.group_description, tasks);
|
||||
}
|
||||
tasks.add(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
//--
|
||||
for (TaskState state : sortedTasks.keySet()) {
|
||||
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByFlags = sortedTasks.get(state);
|
||||
if (!tasksByFlags.isEmpty()) {
|
||||
int count = 0;
|
||||
if (!state.equals(TaskState.Done)) {
|
||||
Vector<String> flagsLines = new Vector<>();
|
||||
for (String flags : tasksByFlags.keySet()) {
|
||||
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByFlags.get(flags);
|
||||
for (String group : tasksByGroups.keySet()) {
|
||||
Vector<SapforTask> tasks = tasksByGroups.get(group);
|
||||
flagsLines.add("Группа " + group + ": " + tasks.size());
|
||||
count += tasks.size();
|
||||
for (SapforTask task : tasks) {
|
||||
task.versionsDescription = task.getVersionsChain();
|
||||
flagsLines.add(
|
||||
"тест: " +
|
||||
Utils.Brackets(task.test_description) + " " +
|
||||
"флаги: "
|
||||
+ Utils.Brackets(flags) + " " +
|
||||
"версии: " +
|
||||
task.versionsDescription
|
||||
// + " " + "конфигурация " + task.sapfor_configuration_id
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
summary_lines.add(state.getDescription() + " :" + count);
|
||||
summary_lines.addAll(flagsLines);
|
||||
} else {
|
||||
for (String flags : tasksByFlags.keySet()) {
|
||||
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByFlags.get(flags);
|
||||
for (String group : tasksByGroups.keySet()) {
|
||||
Vector<SapforTask> tasks = tasksByGroups.get(group);
|
||||
for (SapforTask task: tasks)
|
||||
task.versionsDescription = task.getVersionsChain();
|
||||
count += tasks.size();
|
||||
}
|
||||
}
|
||||
summary_lines.add(state.getDescription() + " :" + count);
|
||||
}
|
||||
}
|
||||
}
|
||||
sapforTasksPackage.summary = String.join("\n", summary_lines);
|
||||
for (SapforTask task : results_json.tasks) {
|
||||
//--
|
||||
if (!task.filesList.isEmpty())
|
||||
task.files = String.join("\n", task.filesList);
|
||||
//---
|
||||
task.filesList = null;
|
||||
task.versions = null;
|
||||
task.variants = null;
|
||||
}
|
||||
planner.ServerCommand(ServerCode.PublishSapforPackageTasks, planner.email, new Vector<>(results_json.tasks));
|
||||
}
|
||||
}
|
||||
public void Perform() throws Exception {
|
||||
if (packageNeedsKill()) {
|
||||
System.out.println("PACKAGE " + sapforTasksPackage.id + " NEEDS TO KILL");
|
||||
@@ -190,6 +282,11 @@ public class SapforTasksPackageSupervisor {
|
||||
case RunningExecution:
|
||||
CheckPackageState();
|
||||
break;
|
||||
case Analysis:
|
||||
AnalysePackage();
|
||||
sapforTasksPackage.state = TasksPackageState.Done;
|
||||
planner.UpdateSapforPackage();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package TestingSystem;
|
||||
import Common.Database.SQLITE.SQLiteDatabase;
|
||||
import Common.Global;
|
||||
import GlobalData.Settings.SettingName;
|
||||
import SapforTestingSystem.SapforTask.SapforTasksDBTable;
|
||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackagesDBTable;
|
||||
import TestingSystem.TSetting.TSetting;
|
||||
@@ -31,6 +32,7 @@ public class TasksDatabase extends SQLiteDatabase {
|
||||
PreparedStatement selectPackageRunTasks = null;
|
||||
//----------
|
||||
public SapforTasksPackagesDBTable sapforTasksPackages;
|
||||
public SapforTasksDBTable sapforTasks;
|
||||
//---------
|
||||
public TasksDatabase(String email) {
|
||||
super(Paths.get(Global.DataDirectory.getAbsolutePath(), email + "_" + tests_db_name + ".sqlite").toFile());
|
||||
@@ -50,6 +52,7 @@ public class TasksDatabase extends SQLiteDatabase {
|
||||
addTable(packagesToKill = new TasksPackageToKillDBTable());
|
||||
//-----------
|
||||
addTable(sapforTasksPackages = new SapforTasksPackagesDBTable());
|
||||
addTable(sapforTasks = new SapforTasksDBTable());
|
||||
}
|
||||
@Override
|
||||
public void Init() throws Exception {
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package TestingSystem;
|
||||
import Common.Constants;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Machine.Machine;
|
||||
import GlobalData.Tasks.TaskState;
|
||||
import GlobalData.User.User;
|
||||
import Repository.EmailMessage;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import SapforTestingSystem.Json.SapforTasksResults_json;
|
||||
import SapforTestingSystem.SapforTask.SapforTask;
|
||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||
import SapforTestingSystem.SapforTasksPackageSupervisor.SapforTasksPackageSupervisor;
|
||||
import TestingSystem.Tasks.TestCompilationTask;
|
||||
@@ -31,7 +27,7 @@ import java.util.Vector;
|
||||
|
||||
import static TestingSystem.TasksDatabase.tests_db_name;
|
||||
public class TestingPlanner {
|
||||
protected String email;
|
||||
public String email;
|
||||
TasksPackage tasksPackage;
|
||||
TestsSupervisor_2022 supervisor;
|
||||
LinkedHashMap<String, Machine> machines = new LinkedHashMap<>();
|
||||
@@ -227,7 +223,7 @@ public class TestingPlanner {
|
||||
//результаты.
|
||||
message = new EmailMessage();
|
||||
message.subject = "Состояние пакета задач SAPFOR" + Utils.Brackets(sapforTasksPackage.id) + " изменилось на " + Utils.Brackets(sapforTasksPackage.state.getDescription());
|
||||
message.text = PrintSapforPackageResults();
|
||||
message.text = sapforTasksPackage.summary;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -238,81 +234,4 @@ public class TestingPlanner {
|
||||
ServerCommand(ServerCode.Email, message);
|
||||
}
|
||||
}
|
||||
//--
|
||||
public String PrintSapforPackageResults() throws Exception {
|
||||
String result = "";
|
||||
Vector<String> result_lines = new Vector<>();
|
||||
File results_json_file = new File(sapforTasksPackage.workspace, Constants.results_json);
|
||||
if (results_json_file.exists()) {
|
||||
SapforTasksResults_json results_json = (SapforTasksResults_json) Utils.jsonFromFile(results_json_file, SapforTasksResults_json.class);
|
||||
result_lines.add("Всего задач: " + results_json.tasks.size());
|
||||
LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> sortedTasks = new LinkedHashMap<>();
|
||||
//рассортировать задачи по конфигурациям.
|
||||
for (TaskState state : TaskState.values()) {
|
||||
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByFlags = new LinkedHashMap<>();
|
||||
sortedTasks.put(state, tasksByFlags);
|
||||
//--
|
||||
for (SapforTask task : results_json.tasks) {
|
||||
if (task.state.equals(state)) {
|
||||
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = null;
|
||||
if (tasksByFlags.containsKey(task.flags)) {
|
||||
groups_tasks = tasksByFlags.get(task.flags);
|
||||
} else {
|
||||
groups_tasks = new LinkedHashMap<>();
|
||||
tasksByFlags.put(task.flags, groups_tasks);
|
||||
}
|
||||
Vector<SapforTask> tasks = null;
|
||||
if (groups_tasks.containsKey(task.group_description)) {
|
||||
tasks = groups_tasks.get(task.group_description);
|
||||
} else {
|
||||
tasks = new Vector<>();
|
||||
groups_tasks.put(task.group_description, tasks);
|
||||
}
|
||||
tasks.add(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
//--
|
||||
for (TaskState state : sortedTasks.keySet()) {
|
||||
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByFlags = sortedTasks.get(state);
|
||||
if (!tasksByFlags.isEmpty()) {
|
||||
int count = 0;
|
||||
if (!state.equals(TaskState.Done)) {
|
||||
Vector<String> flagsLines = new Vector<>();
|
||||
for (String flags : tasksByFlags.keySet()) {
|
||||
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByFlags.get(flags);
|
||||
for (String group : tasksByGroups.keySet()) {
|
||||
Vector<SapforTask> tasks = tasksByGroups.get(group);
|
||||
flagsLines.add("Группа " + group + ": " + tasks.size());
|
||||
count += tasks.size();
|
||||
for (SapforTask task : tasks)
|
||||
flagsLines.add(
|
||||
"тест: " +
|
||||
Utils.Brackets(task.test_description) + " " +
|
||||
"флаги: "
|
||||
+ Utils.Brackets(flags) + " " +
|
||||
"версии: " +
|
||||
task.getVersionsChain() + " " +
|
||||
"конфигурация " + task.sapfor_configuration_id
|
||||
);
|
||||
}
|
||||
}
|
||||
result_lines.add(state.getDescription() + " :" + count);
|
||||
result_lines.addAll(flagsLines);
|
||||
} else {
|
||||
for (String flags : tasksByFlags.keySet()) {
|
||||
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByFlags.get(flags);
|
||||
for (String group : tasksByGroups.keySet()) {
|
||||
Vector<SapforTask> tasks = tasksByGroups.get(group);
|
||||
count += tasks.size();
|
||||
}
|
||||
}
|
||||
result_lines.add(state.getDescription() + " :" + count);
|
||||
}
|
||||
}
|
||||
}
|
||||
result = String.join("\n", result_lines);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import Repository.Server.ServerExchangeUnit_2021;
|
||||
import SapforTestingSystem.Json.SapforTasksResults_json;
|
||||
import SapforTestingSystem.SapforTask.SapforTask;
|
||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackageInterface;
|
||||
import SapforTestingSystem.ServerSapfor.ServerSapfor;
|
||||
import TestingSystem.Group.Group;
|
||||
import TestingSystem.Group.GroupInterface;
|
||||
@@ -185,11 +186,22 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
)
|
||||
);
|
||||
} else if (object instanceof SapforTasksPackage) {
|
||||
SapforTasksPackage sapforTasksPackage = (SapforTasksPackage) object;
|
||||
File workspace = new File(
|
||||
((SapforTasksPackage) object).workspace
|
||||
sapforTasksPackage.workspace
|
||||
);
|
||||
System.out.println(Utils.Brackets(workspace.getAbsolutePath()));
|
||||
Utils.forceDeleteWithCheck(workspace);
|
||||
Utils.forceDeleteWithCheck(SapforTasksPackageInterface.getPackageArchive(sapforTasksPackage));
|
||||
//внешние ключи не работают
|
||||
Vector<SapforTask> tasks = new Vector<>();
|
||||
for (SapforTask task : account_db.sapforTasks.Data.values()) {
|
||||
if (task.sapfortaskspackage_id.equals(sapforTasksPackage.id)) // todo group_name -> group_id
|
||||
tasks.add(task);
|
||||
}
|
||||
for (SapforTask task : tasks) {
|
||||
account_db.Delete(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@@ -357,18 +369,32 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
DBObject dbObject = null;
|
||||
Test test = null;
|
||||
switch (code) {
|
||||
case PublishSapforPackageTasks:
|
||||
Print("Опубликовать задачи SAPFOR для пользователя " + request.arg);
|
||||
SetCurrentAccountDB(request.arg);
|
||||
Vector<Object> tasks = (Vector<Object>) request.object;
|
||||
account_db.BeginTransaction();
|
||||
for (Object object : tasks) {
|
||||
SapforTask task = (SapforTask) object;
|
||||
task.id = db.IncMaxTaskId();
|
||||
if (account_db.InsertWithCheck_(task) != null)
|
||||
PublishAction(task);
|
||||
}
|
||||
account_db.Commit();
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
break;
|
||||
case DownloadSapforTasksPackage:
|
||||
Print("Загрузить пакет тестов SAPFOR " + request.object + " для пользователя " + request.arg);
|
||||
SetCurrentAccountDB(request.arg);
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
//---
|
||||
if (!account_db.sapforTasksPackages.containsKey(request.object))
|
||||
throw new RepositoryRefuseException("Не существует пакета с ключом "+Utils.Brackets(request.object));
|
||||
throw new RepositoryRefuseException("Не существует пакета с ключом " + Utils.Brackets(request.object));
|
||||
//--
|
||||
SapforTasksPackage sapforTasksPackage = account_db.sapforTasksPackages.get(request.object);
|
||||
//---
|
||||
//1 - архивировать пакет.
|
||||
File packageArchive = new File(Global.SapforPackagesDirectory, sapforTasksPackage.id+".zip");
|
||||
File packageArchive = SapforTasksPackageInterface.getPackageArchive(sapforTasksPackage);
|
||||
Utils.forceDeleteWithCheck(packageArchive);
|
||||
//---
|
||||
ZipFolderPass zip = new ZipFolderPass();
|
||||
@@ -377,7 +403,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
Print("Архив успешно запакован");
|
||||
} else throw new RepositoryRefuseException("Не удалось запаковать архив пакета");
|
||||
//---
|
||||
|
||||
break;
|
||||
case SynchronizeTests:
|
||||
//временный проход. синхронизирует тесты на заданной машине, с сервера.
|
||||
@@ -432,9 +457,9 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
case PublishAccountObjects:
|
||||
Print("Опубликовать объекты для пользователя " + request.arg);
|
||||
SetCurrentAccountDB(request.arg);
|
||||
Vector<Object> objects_ = (Vector<Object>) request.object;
|
||||
Vector<Object> objects__ = (Vector<Object>) request.object;
|
||||
account_db.BeginTransaction();
|
||||
for (Object object : objects_)
|
||||
for (Object object : objects__)
|
||||
if (account_db.InsertWithCheck_((DBObject) object) != null)
|
||||
PublishAction((DBObject) object);
|
||||
account_db.Commit();
|
||||
|
||||
@@ -19,7 +19,7 @@ public class DownloadSapforTasksPackage extends TestingSystemPass<SapforTasksPac
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
File packageArchive = null;
|
||||
File tmpArchive = null;
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
if (Current.Check(Log, Current.SapforTasksPackage)) {
|
||||
@@ -32,11 +32,11 @@ public class DownloadSapforTasksPackage extends TestingSystemPass<SapforTasksPac
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.DownloadSapforTasksPackage, Current.getAccount().email, target.id));
|
||||
response.Unpack(packageArchive = Utils.getTempFileName(target.id));
|
||||
response.Unpack(tmpArchive = Utils.getTempFileName(target.id));
|
||||
}
|
||||
@Override
|
||||
protected boolean validate() {
|
||||
return packageArchive !=null&& packageArchive.exists();
|
||||
return tmpArchive != null && tmpArchive.exists();
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
@@ -44,9 +44,9 @@ public class DownloadSapforTasksPackage extends TestingSystemPass<SapforTasksPac
|
||||
File packageWorkspace = new File(Global.SapforPackagesDirectory, target.id);
|
||||
Utils.forceDeleteWithCheck(packageWorkspace);
|
||||
if (passes.get(PassCode_2021.UnzipFolderPass).Do(
|
||||
packageArchive.getAbsolutePath(),
|
||||
tmpArchive.getAbsolutePath(),
|
||||
Global.SapforPackagesDirectory.getAbsolutePath(), false
|
||||
));
|
||||
)) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user