diff --git a/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/JsonToHtmlConverter.java b/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/JsonToHtmlConverter.java
index ba5f3e4a..4d125e20 100644
--- a/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/JsonToHtmlConverter.java
+++ b/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/JsonToHtmlConverter.java
@@ -2,6 +2,7 @@ package org.diylc.plugins.chatbot.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.swing.JLabel;
import java.io.IOException;
@@ -24,7 +25,7 @@ public class JsonToHtmlConverter {
.append(" \n")
.append("
Validation Report\n")
.append(" \n");
+ html.append(" Circuit Comparison Results\n");
+ html.append(" \n");
html.append("\n");
html.append("\n");
- // Start with bold results
- if (results.matches()) {
- html.append("The circuits match exactly.
\n");
- } else {
- html.append("The circuits do not match.
\n");
- }
+ // Main result
+ html.append(" The circuits ").append(results.matches() ? "match" : "do not match").append(".
\n");
if (!results.matches()) {
+ // Component differences section
if (!results.componentDiffs().isEmpty()) {
- html.append("Component Differences
\n");
- html.append("\n");
- html.append("| Component | Status |
\n");
-
- for (ComponentDiff diff : results.componentDiffs()) {
- html.append("\n");
- html.append("| ").append(diff.componentName()).append(" | \n");
- html.append("");
- html.append(diff.presentInCurrent() ? "Missing in target circuit" : "Extra in target circuit");
- html.append(" | \n");
- html.append("
\n");
+ html.append(" \n");
+ html.append("
Component Differences
\n");
+ html.append("
\n");
+ html.append(" \n");
+ html.append(" | Component | \n");
+ html.append(" Status | \n");
+ html.append("
\n");
+
+ List missingComponents = results.componentDiffs().stream()
+ .filter(ComponentDiff::presentInCurrent)
+ .collect(Collectors.toList());
+ List extraComponents = results.componentDiffs().stream()
+ .filter(diff -> !diff.presentInCurrent())
+ .collect(Collectors.toList());
+
+ for (ComponentDiff diff : missingComponents) {
+ html.append(" \n");
+ html.append(" | ").append(diff.componentName()).append(" | \n");
+ html.append(" Missing in target circuit | \n");
+ html.append("
\n");
}
-
- html.append("
\n");
+
+ for (ComponentDiff diff : extraComponents) {
+ html.append("
\n");
+ html.append(" | ").append(diff.componentName()).append(" | \n");
+ html.append(" Extra in target circuit | \n");
+ html.append("
\n");
+ }
+
+ html.append("
\n");
+ html.append(" \n");
}
+ // Connection differences section
if (!results.connectionDiffs().isEmpty()) {
- html.append("Connection Differences
\n");
- html.append("\n");
- html.append("| From Component | From Node | To Component | To Node | Status |
\n");
-
- for (ConnectionDiff diff : results.connectionDiffs()) {
- html.append("\n");
- html.append("| ").append(diff.fromComponent()).append(" | \n");
- html.append("").append(diff.fromNodeName()).append(" | \n");
- html.append("").append(diff.toComponent()).append(" | \n");
- html.append("").append(diff.toNodeName()).append(" | \n");
- html.append("");
- html.append(diff.presentInCurrent() ? "Missing in target circuit" : "Extra in target circuit");
- html.append(" | \n");
- html.append("
\n");
+ html.append(" \n");
+ html.append("
Connection Differences
\n");
+ html.append("
\n");
+ html.append(" \n");
+ html.append(" | From Component | \n");
+ html.append(" From Node | \n");
+ html.append(" To Component | \n");
+ html.append(" To Node | \n");
+ html.append(" Status | \n");
+ html.append("
\n");
+
+ List missingConnections = results.connectionDiffs().stream()
+ .filter(ConnectionDiff::presentInCurrent)
+ .collect(Collectors.toList());
+ List extraConnections = results.connectionDiffs().stream()
+ .filter(diff -> !diff.presentInCurrent())
+ .collect(Collectors.toList());
+
+ for (ConnectionDiff diff : missingConnections) {
+ html.append(" \n");
+ html.append(" | ").append(diff.fromComponent()).append(" | \n");
+ html.append(" ").append(diff.fromNodeName()).append(" | \n");
+ html.append(" ").append(diff.toComponent()).append(" | \n");
+ html.append(" ").append(diff.toNodeName()).append(" | \n");
+ html.append(" Missing in target circuit | \n");
+ html.append("
\n");
}
-
- html.append("
\n");
+
+ for (ConnectionDiff diff : extraConnections) {
+ html.append("
\n");
+ html.append(" | ").append(diff.fromComponent()).append(" | \n");
+ html.append(" ").append(diff.fromNodeName()).append(" | \n");
+ html.append(" ").append(diff.toComponent()).append(" | \n");
+ html.append(" ").append(diff.toNodeName()).append(" | \n");
+ html.append(" Extra in target circuit | \n");
+ html.append("
\n");
+ }
+
+ html.append("
\n");
+ html.append(" \n");
}
}
html.append("\n");
html.append("