рефакторинг сравнения

This commit is contained in:
2024-02-26 00:36:35 +03:00
parent 848d95ee14
commit 75c196f611
16 changed files with 149 additions and 119 deletions

View File

@@ -1,13 +1,13 @@
package TestingSystem.SAPFOR.SapforTask;
import Common.Constants;
import Common.Database.DBObject;
import Common.UI.UI;
import Common.Utils.Utils;
import GlobalData.Tasks.TaskState;
import TestingSystem.SAPFOR.Json.SapforVersion_json;
import TestingSystem.SAPFOR.Json.VersionComparisonState;
import TestingSystem.SAPFOR.SapforTasksPackage.UI.SapforPackageTreeNode;
import TestingSystem.SAPFOR.SapforTasksPackage.UI.SapforTaskNode;
import TestingSystem.SAPFOR.SapforTasksPackage.UI.VersionSummary;
import 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;
@@ -55,7 +55,7 @@ public class SapforTask extends DBObject {
@Expose
public TaskState state = TaskState.Inactive;
@Description("IGNORE")
public MatchState comparisonState = MatchState.Unknown; //для сравнения. в обычном режиме всегда Unknown!
public ComparisonState comparisonState = ComparisonState.Unknown; //для сравнения. в обычном режиме всегда Unknown!
//--------------------------------------------------
public String getUniqueKey() {
return group_description + "_" + test_description + "_" + sapfor_configuration_id;
@@ -71,36 +71,6 @@ public class SapforTask extends DBObject {
//-----------
public SapforTask() {
}
public DefaultMutableTreeNode getVersionsTree(File configurationRoot) {
VersionSummary root = null;
VersionSummary child = null;
VersionSummary parent = null;
//--
for (SapforVersion_json version_json : versions) {
version_json.task = this;
// System.out.println(version_json.version);
//-
version_json.init(configurationRoot);
child = new VersionSummary(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;
version_json.init(configurationRoot);
parent.add(new VersionSummary(version_json));
}
}
//--
return root;
}
public void Reset() {
state = TaskState.Inactive;
versions.clear();
@@ -150,59 +120,46 @@ public class SapforTask extends DBObject {
return res;
}
public void checkMatch(SapforTask task2) {
//todo Для каждого случая подобрать иконку (?)
if (!state.equals(task2.state)) {
System.out.println("Не совпадение состояний задачи " + getUniqueKey());
//--
comparisonState = MatchState.NotMatch;
task2.comparisonState = MatchState.NotMatch;
return;
//--
comparisonState = ComparisonState.NotMatch;
task2.comparisonState = ComparisonState.NotMatch;
}
if ((versions.size() != task2.versions.size()) || (variants.size() != task2.variants.size())) {
System.out.println("Не совпадение количества версий в задаче " + getUniqueKey());
//--
comparisonState = MatchState.NotMatch;
task2.comparisonState = MatchState.NotMatch;
return;
//--
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)) {
System.out.println("Не совпадение имен версий в задаче " + getUniqueKey());
System.out.println("current version="+Utils.Brackets(name1));
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;
//-
// System.out.println(version1.comparisonState);
}else {
version1.comparisonState = VersionComparisonState.Match;
version2.comparisonState = VersionComparisonState.Match;
//-
// System.out.println(version1.comparisonState);
}
} else {
comparisonState = ComparisonState.NotMatch;
task2.comparisonState = ComparisonState.NotMatch;
//--
comparisonState = MatchState.NotMatch;
task2.comparisonState = MatchState.NotMatch;
//--
return;
}
}
System.out.println("сравнение версий.");
//--
for (String name1 : versions1.keySet()) {
System.out.println("version name=" + name1);
SapforVersion_json version1 = versions1.get(name1);
SapforVersion_json version2 = versions2.get(name1);
//---
if (!version1.isMatch(version2)) {
System.out.println("Не совпадение кода версий в задаче " + getUniqueKey());
//-
comparisonState = MatchState.NotMatch;
task2.comparisonState = MatchState.NotMatch;
//-
return;
}
}
comparisonState = MatchState.Match;
task2.comparisonState = MatchState.Match;
if (this.id==161){
UI.Info("!");
System.out.println(comparisonState+"/"+task2.comparisonState);
UI.Info("!!");
if (comparisonState.equals(ComparisonState.Unknown)) {
comparisonState = ComparisonState.Match;
task2.comparisonState = ComparisonState.Match;
}
}
public Date getStartDate() {
@@ -228,6 +185,33 @@ public class SapforTask extends DBObject {
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);
//-
@@ -236,8 +220,7 @@ public class SapforTask extends DBObject {
//-
int total_versions_count = versions.size() + variants.size();
DefaultMutableTreeNode versions_info = new DefaultMutableTreeNode("версии: " + total_versions_count);
versions_info.add(getVersionsTree(configurationRoot));
//--
versions_info.add(getVersionsTree());
res.add(flags_info);
res.add(passes_info);
res.add(versions_info);