рефакторинг сравнения
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
package TestingSystem.SAPFOR.Json;
|
||||
import GlobalData.Tasks.TaskState;
|
||||
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||
import TestingSystem.SAPFOR.SapforTask.MatchState;
|
||||
import TestingSystem.SAPFOR.SapforTask.ComparisonState;
|
||||
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
import TestingSystem.SAPFOR.SapforTasksPackage.UI.PackageComparisonSummary;
|
||||
import TestingSystem.SAPFOR.SapforTasksPackage.UI.PackageSummary;
|
||||
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 {
|
||||
@@ -77,14 +77,16 @@ public class SapforPackage_json implements Serializable {
|
||||
//---------
|
||||
public void DropComparison() {
|
||||
comparison_root = null;
|
||||
for (SapforTask task : tasks)
|
||||
task.comparisonState = MatchState.Unknown;
|
||||
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) {
|
||||
//--
|
||||
for (SapforTask task : tasks)
|
||||
task.comparisonState = MatchState.Unknown;
|
||||
//---
|
||||
root = new PackageSummary();
|
||||
root.count = tasks.size();
|
||||
root.errors_count = 0;
|
||||
@@ -116,8 +118,25 @@ public class SapforPackage_json implements Serializable {
|
||||
String.valueOf(task.sapfor_configuration_id)
|
||||
).toFile());
|
||||
comparison_root.add(taskNode);
|
||||
if (task.comparisonState.equals(MatchState.NotMatch))
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package TestingSystem.SAPFOR.Json;
|
||||
public enum SapforVersionMatchState {
|
||||
Unknown,
|
||||
Match, //версия совпадает
|
||||
FilesQuantityMissmatch, //количество выходных файлов в версии не совпадает
|
||||
CodeMissmatch //код файлов не совпадает.
|
||||
}
|
||||
@@ -2,6 +2,5 @@ package TestingSystem.SAPFOR.Json;
|
||||
import java.io.Serializable;
|
||||
public enum SapforVersionState implements Serializable {
|
||||
Empty, //версия оказалась пуста.
|
||||
Normal, //версия построена
|
||||
HasErrors //в журнале версии есть ошибки. то есть, не удалось построить следующую версию.
|
||||
Normal //версия построена
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ public class SapforVersion_json implements Serializable {
|
||||
public SapforTask task = null; //родная задача. Нужна для построения дерева версий.
|
||||
public db_project_info project = null;
|
||||
//--
|
||||
public SapforVersionState state = SapforVersionState.Empty;
|
||||
public SapforVersionMatchState matchState = SapforVersionMatchState.Unknown;
|
||||
public SapforVersionState state = null;
|
||||
public VersionComparisonState comparisonState = null;
|
||||
//--
|
||||
public SapforVersion_json(String version_in, String description_in) {
|
||||
version = version_in;
|
||||
@@ -49,10 +49,10 @@ public class SapforVersion_json implements Serializable {
|
||||
description = description_in;
|
||||
}
|
||||
|
||||
public SapforVersionState init(File configurationRoot) {
|
||||
public void getFiles(File configurationRoot) {
|
||||
//--
|
||||
state = SapforVersionState.Empty;
|
||||
matchState = SapforVersionMatchState.Unknown;
|
||||
comparisonState = VersionComparisonState.Unknown;
|
||||
//--
|
||||
String relativePath = Global.isWindows ? Utils.toW(version) : version;
|
||||
Home = Paths.get(configurationRoot.getAbsolutePath(), relativePath).toFile();
|
||||
@@ -76,7 +76,6 @@ public class SapforVersion_json implements Serializable {
|
||||
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());
|
||||
return state;
|
||||
}
|
||||
public boolean isMatch(SapforVersion_json version_json) {
|
||||
if (!description.equals(version_json.description)) {
|
||||
@@ -292,6 +291,6 @@ public class SapforVersion_json implements Serializable {
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return Home.getName() + " : " + Utils.Brackets(description);
|
||||
return Home.getName() + " : " + Utils.Brackets(description)+" файлы: " +files.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package TestingSystem.SAPFOR.Json;
|
||||
public enum VersionComparisonState {
|
||||
Unknown,
|
||||
Match, //версия совпадает
|
||||
NotMatch
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import Common.UI.StatusEnum;
|
||||
import Common.UI.Themes.VisualiserFonts;
|
||||
|
||||
import java.awt.*;
|
||||
public enum MatchState implements StatusEnum {
|
||||
public enum ComparisonState implements StatusEnum {
|
||||
Unknown,
|
||||
NotMatch,
|
||||
Match;
|
||||
@@ -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);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import TestingSystem.SAPFOR.SapforTask.MatchState;
|
||||
import TestingSystem.SAPFOR.SapforTask.ComparisonState;
|
||||
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
public class SapforTaskNode extends SapforPackageTreeNode {
|
||||
public SapforTaskNode(SapforTask task_in) {
|
||||
@@ -9,7 +9,7 @@ public class SapforTaskNode extends SapforPackageTreeNode {
|
||||
public String getImageKey() {
|
||||
SapforTask task = (SapforTask) getUserObject();
|
||||
//обычный режим
|
||||
if (task.comparisonState == MatchState.Unknown) {
|
||||
if (task.comparisonState == ComparisonState.Unknown) {
|
||||
return task.state.toString();
|
||||
}
|
||||
//режим сравнения.
|
||||
|
||||
@@ -12,7 +12,8 @@ public class SapforVersionsTreeCellRenderer extends StyledTreeCellRenderer {
|
||||
SapforPackageTreeNode node = (SapforPackageTreeNode) value;
|
||||
setForeground(tree.getForeground());
|
||||
setFont(getFont().deriveFont((float) 14.0));
|
||||
setIcon(node.getIcon());
|
||||
if (node.getIcon() != null)
|
||||
setIcon(node.getIcon());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import TestingSystem.SAPFOR.Json.SapforVersionState;
|
||||
import TestingSystem.SAPFOR.Json.SapforVersion_json;
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
|
||||
import TestingSystem.SAPFOR.Json.SapforVersionState;
|
||||
import TestingSystem.SAPFOR.Json.SapforVersion_json;
|
||||
public class VersionSummary extends SapforPackageTreeNode {
|
||||
public VersionSummary(SapforVersion_json version_json) {
|
||||
setUserObject(version_json);
|
||||
}
|
||||
@Override
|
||||
public String getImageKey() {
|
||||
return ((SapforVersion_json)getUserObject()).state.toString();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import Common.UI.Label.ShortLabel;
|
||||
import Common.UI.Menus_2023.VisualiserMenuBar;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.TextLog;
|
||||
import TestingSystem.SAPFOR.Json.SapforVersion_json;
|
||||
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||
import TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
import TestingSystem.SAPFOR.SapforTasksPackage.UI.SapforTasksPackageTree;
|
||||
@@ -115,14 +116,14 @@ public class SapforPackagesComparisonForm {
|
||||
if (object.package_json == null) {
|
||||
try {
|
||||
object.readJson();
|
||||
object.package_json.getVersionsFiles(object);
|
||||
object.package_json.buildTree(object);
|
||||
//---
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
object.package_json.DropComparison();
|
||||
}
|
||||
object.package_json.DropComparison();
|
||||
//--
|
||||
showCommonTree();
|
||||
}
|
||||
@@ -235,8 +236,16 @@ public class SapforPackagesComparisonForm {
|
||||
task1.checkMatch(task2);
|
||||
//--
|
||||
++i;
|
||||
//---
|
||||
}
|
||||
//--
|
||||
for (SapforTask task1 : package1.package_json.tasks) {
|
||||
SapforTask task2 = package2.package_json.getTaskByKey(task1.getUniqueKey());
|
||||
//---
|
||||
for (SapforVersion_json version: task1.versions){
|
||||
System.out.println(version+":"+version.comparisonState);
|
||||
}
|
||||
}
|
||||
//---
|
||||
package1.package_json.buildComparisonTree(package1);
|
||||
package2.package_json.buildComparisonTree(package2);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class SapforVersionsComparisonForm extends ComparisonForm<SapforVersion_j
|
||||
@Override
|
||||
protected void showObject() {
|
||||
lObjectName.setText(object.toString());
|
||||
lObjectName.setToolTipText(object.toString());
|
||||
lObjectName.setToolTipText(object.Home.getName() + " : " + Utils.Brackets(object.description));
|
||||
cbFile.removeAllItems();
|
||||
for (ProjectFile file : object.files.values())
|
||||
cbFile.addItem(file);
|
||||
|
||||
BIN
src/icons/versions/MatchNormal.png
Normal file
BIN
src/icons/versions/MatchNormal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/icons/versions/NotMatchNormal.png
Normal file
BIN
src/icons/versions/NotMatchNormal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user