201 lines
8.3 KiB
Java
201 lines
8.3 KiB
Java
package SapforTestingSystem.SapforTasksPackage;
|
|
import Common.Constants;
|
|
import Common.Database.DBObject;
|
|
import Common.Database.nDBObject;
|
|
import Common.Global;
|
|
import Common.Utils.Utils;
|
|
import GlobalData.Tasks.TaskState;
|
|
import SapforTestingSystem.Json.SapforTasksResults_json;
|
|
import SapforTestingSystem.SapforTask.SapforTask;
|
|
import SapforTestingSystem.SapforTasksPackage.UI.ConfigurationSummary;
|
|
import SapforTestingSystem.SapforTasksPackage.UI.GroupSummary;
|
|
import SapforTestingSystem.SapforTasksPackage.UI.PackageSummary;
|
|
import SapforTestingSystem.SapforTasksPackage.UI.StateSummary;
|
|
import TestingSystem.TasksPackage.TasksPackageState;
|
|
import com.sun.org.glassfish.gmbal.Description;
|
|
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
import java.io.File;
|
|
import java.nio.file.Paths;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Vector;
|
|
public class SapforTasksPackage extends nDBObject {
|
|
@Description("DEFAULT ''")
|
|
public String testsNames = "";//имена тестов через ; для отображения
|
|
//---
|
|
public int sapforId = Constants.Nan;
|
|
public String sapfor_version = "?"; //тестируемая версия SAPFOR
|
|
public long sapfor_build_date = 0;
|
|
public String sapfor_drv = "";
|
|
public String sapfor_process_name = "";
|
|
//---
|
|
public String workspace = ""; //домашняя папка
|
|
//---
|
|
public int tasksCount = 0; //Общее число задач
|
|
//---
|
|
public int needsEmail = 0;
|
|
public long StartDate = 0; //дата начала выполнения
|
|
public long ChangeDate = 0;//дата окончания выполнения
|
|
//-
|
|
public int kernels = 1; //количество потоков.
|
|
@Description("DEFAULT 'TestsSynchronize'")
|
|
public TasksPackageState state = TasksPackageState.TestsSynchronize;
|
|
@Description("DEFAULT ''")
|
|
public String testsIds = "";
|
|
@Description("DEFAULT ''")
|
|
public String configurationsIds = "";
|
|
@Description("DEFAULT ''")
|
|
public String summary = "";
|
|
@Override
|
|
public void SynchronizeFields(DBObject src) {
|
|
super.SynchronizeFields(src);
|
|
SapforTasksPackage p = (SapforTasksPackage) src;
|
|
sapforId = p.sapforId;
|
|
testsNames = p.testsNames;
|
|
sapfor_version = p.sapfor_version;
|
|
sapfor_build_date = p.sapfor_build_date;
|
|
workspace = p.workspace;
|
|
tasksCount = p.tasksCount;
|
|
StartDate = p.StartDate;
|
|
ChangeDate = p.ChangeDate;
|
|
kernels = p.kernels;
|
|
sapfor_process_name = p.sapfor_process_name;
|
|
state = p.state;
|
|
needsEmail = p.needsEmail;
|
|
}
|
|
//---
|
|
@Description("IGNORE")
|
|
public PackageSummary root = null;
|
|
@Description("IGNORE")
|
|
public DefaultMutableTreeNode comparison_root = null;
|
|
//---
|
|
@Description("IGNORE")
|
|
public SapforTasksResults_json results = null;
|
|
///---
|
|
public File getArchive() {
|
|
return new File(Global.SapforPackagesDirectory, id + ".zip");
|
|
}
|
|
public File getLocalWorkspace() {
|
|
return new File(Global.SapforPackagesDirectory, id);
|
|
}
|
|
public File getLoadedSign() {
|
|
return Paths.get(Global.SapforPackagesDirectory.getAbsolutePath(), id, Constants.LOADED).toFile();
|
|
}
|
|
public boolean isLoaded() {
|
|
return getLoadedSign().exists();
|
|
}
|
|
public void getLocalResults() {
|
|
File json_file = new File(getLocalWorkspace(), Constants.results_json);
|
|
results = null;
|
|
try {
|
|
results = (SapforTasksResults_json) Utils.jsonFromFile(json_file,
|
|
SapforTasksResults_json.class);
|
|
results.SortTasks();
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
}
|
|
public void buildTree() {
|
|
//--
|
|
if (results == null) {
|
|
getLocalResults();
|
|
}
|
|
//--
|
|
root = new PackageSummary();
|
|
LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> task_states =
|
|
results.sortTasksForTree();
|
|
//---
|
|
for (TaskState state : task_states.keySet()) {
|
|
//--
|
|
StateSummary stateSummary = new StateSummary(state);
|
|
//--
|
|
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = task_states.get(state);
|
|
for (String configuration_id : tasksByConfigurations.keySet()) {
|
|
//--
|
|
DefaultMutableTreeNode configurationNode = null;
|
|
//--
|
|
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = tasksByConfigurations.get(configuration_id);
|
|
for (String group : groups_tasks.keySet()) {
|
|
//--
|
|
GroupSummary groupSummary = new GroupSummary(group);
|
|
//--
|
|
for (SapforTask task : groups_tasks.get(group)) {
|
|
//--
|
|
stateSummary.count++;
|
|
root.count++;
|
|
//--
|
|
if (configurationNode == null) {
|
|
configurationNode = new ConfigurationSummary(configuration_id, task);
|
|
}
|
|
//--
|
|
groupSummary.add(task.getVersionsTree(new File(getLocalWorkspace(), configuration_id)));
|
|
}
|
|
if (configurationNode != null)
|
|
configurationNode.add(groupSummary);
|
|
}
|
|
stateSummary.add(configurationNode);
|
|
}
|
|
if (stateSummary.count > 0) {
|
|
root.add(stateSummary);
|
|
}
|
|
}
|
|
}
|
|
/*
|
|
public static DefaultMutableTreeNode buildTree_old(SapforTasksPackage package_in) {
|
|
PackageSummary root = new PackageSummary();
|
|
|
|
SapforTasksResults_json results_json = getLocalResults(package_in);
|
|
LinkedHashMap<MatchState, LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>>> sortedTasks =
|
|
results_json.sortTasksForComparisonTree();
|
|
//--
|
|
for (MatchState match_state : sortedTasks.keySet()) {
|
|
//--
|
|
MatchesSummary matchesSummary = new MatchesSummary(match_state);
|
|
//---
|
|
LinkedHashMap<TaskState, LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>>> task_states = sortedTasks.get(match_state);
|
|
//---
|
|
for (TaskState state : task_states.keySet()) {
|
|
//--
|
|
StateSummary stateSummary = new StateSummary(state);
|
|
//--
|
|
LinkedHashMap<String, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = task_states.get(state);
|
|
for (String configuration_id : tasksByConfigurations.keySet()) {
|
|
//--
|
|
DefaultMutableTreeNode configurationNode = null;
|
|
//--
|
|
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = tasksByConfigurations.get(configuration_id);
|
|
for (String group : groups_tasks.keySet()) {
|
|
//--
|
|
GroupSummary groupSummary = new GroupSummary(group);
|
|
//--
|
|
for (SapforTask task : groups_tasks.get(group)) {
|
|
//--
|
|
stateSummary.count++;
|
|
matchesSummary.count++;
|
|
root.count++;
|
|
//--
|
|
if (configurationNode == null) {
|
|
configurationNode = new ConfigurationSummary(configuration_id, task);
|
|
}
|
|
//--
|
|
groupSummary.add(task.getVersionsTree(new File(getLocalWorkspace(package_in), configuration_id)));
|
|
}
|
|
if (configurationNode != null)
|
|
configurationNode.add(groupSummary);
|
|
}
|
|
stateSummary.add(configurationNode);
|
|
}
|
|
if (stateSummary.count > 0) {
|
|
matchesSummary.add(stateSummary);
|
|
}
|
|
}
|
|
//---
|
|
if (matchesSummary.count > 0) {
|
|
root.add(matchesSummary);
|
|
}
|
|
}
|
|
return root;
|
|
}
|
|
*/
|
|
}
|