TEIV: update graph generator to include attributes 13/13813/5
authorJvD_Ericsson <jeff.van.dam@est.tech>
Thu, 5 Dec 2024 08:38:51 +0000 (08:38 +0000)
committerJohn Keeney <john.keeney@est.tech>
Fri, 13 Dec 2024 13:54:01 +0000 (13:54 +0000)
Issue-ID: SMO-???
Change-Id: I682402e952f4ba37730db04504dbff42440bcb3c
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
pgsql-schema-generator/src/main/java/org/oran/smo/teiv/pgsqlgenerator/graphgenerator/EntityGraphGenerator.java
pgsql-schema-generator/src/main/java/org/oran/smo/teiv/pgsqlgenerator/graphgenerator/EntityGraphGeneratorUml.java

index 8245b66..9b150f4 100644 (file)
@@ -36,6 +36,7 @@ import org.springframework.stereotype.Component;
 import java.io.File;
 import java.io.IOException;
 import java.util.List;
+import java.util.Optional;
 
 import static guru.nidi.graphviz.attribute.Rank.RankDir;
 
@@ -93,11 +94,22 @@ public class EntityGraphGenerator {
 
     private void addAttributeNodeToGraph(MutableGraph graph, List<Attribute> attributes, Entity moduleEntity,
             MutableNode moduleNode) {
-        String label = "<TABLE border='1' cellborder='0' cellspacing='0' cellpadding='4'>";
+        String label = "<TABLE border='0' cellborder='0' cellspacing='0' cellpadding='0'>";
+        Optional<Attribute> optionalId = attributes.stream().filter(att -> "id".equals(att.getName())).findFirst();
+        if (optionalId.isPresent()) {
+            Attribute id = optionalId.get();
+            label = label.concat("<TR> <TD align='left'>" + id.getName() + "</TD> <TD align='right'>" + helperFunctions
+                    .escapeHtml(id.getYangDataType()) + "</TD> </TR>");
+        }
+
+        label += "<TR> <TD align='left'>sourceIds</TD> <TD align='right' >&lt;&lt; Refer to Module &gt;&gt;</TD> </TR>";
+        label = label.concat("<TR> <TD colspan='2' align='left'> attributes: </TD> </TR>");
         for (Attribute attribute : attributes) {
-            label = label.concat("<TR> <TD bgcolor='#EEEEEE' align='left'>" + attribute
-                    .getName() + "</TD> <TD align='right' bgcolor='#EEEEEE'>" + helperFunctions.escapeHtml(attribute
-                            .getYangDataType()) + "</TD> </TR>");
+            if (!"id".equals(attribute.getName())) {
+                label = label.concat("<TR> <TD align='left'>        " + attribute
+                        .getName() + "</TD> <TD align='right'>" + helperFunctions.escapeHtml(attribute
+                                .getYangDataType()) + "</TD> </TR>");
+            }
         }
         label = label.concat("</TABLE>");
         MutableNode attributeNode = Factory.mutNode(moduleEntity.getEntityName() + "-attributes").attrs().add(Label.html(
index 276edf5..72893f4 100644 (file)
@@ -24,6 +24,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.List;
+import java.util.Optional;
 
 import org.oran.smo.teiv.pgsqlgenerator.Attribute;
 import org.oran.smo.teiv.pgsqlgenerator.Entity;
@@ -71,15 +72,25 @@ public class EntityGraphGeneratorUml {
         StringBuilder sb = new StringBuilder();
         sb.append("@startuml\n");
         sb.append("skinparam class {\n");
-        sb.append("    BackgroundColor<<Entity>> " + helperFunctions.getNodeFillColour(moduleName) + " \n");
+        sb.append("    BackgroundColor<<Entity>> ").append(helperFunctions.getNodeFillColour(moduleName)).append("\n");
         sb.append("    BackgroundColor<<Module>> LightBlue\n");
         sb.append("}\n");
         sb.append(String.format("class %s <<Module>> {%n}%n", moduleName));
+
         for (Entity entity : entities) {
             sb.append(String.format("class %s <<Entity>> {%n", entity.getEntityName()));
             List<Attribute> attributes = entity.getAttributes();
+            Optional<Attribute> optionalId = attributes.stream().filter(att -> "id".equals(att.getName())).findFirst();
+            if (optionalId.isPresent()) {
+                Attribute id = optionalId.get();
+                sb.append(String.format("    %s : %s%n", id.getName(), id.getYangDataType()));
+            }
+            sb.append("    sourceIds : << Refer to Module >>\n");
+            sb.append("    attributes:\n");
             for (Attribute attribute : attributes) {
-                sb.append(String.format("    %s : %s\n", attribute.getName(), attribute.getYangDataType()));
+                if (!"id".equals(attribute.getName())) {
+                    sb.append(String.format("        %s : %s%n", attribute.getName(), attribute.getYangDataType()));
+                }
             }
             sb.append("}\n");
             sb.append(String.format("\"%s\" --> %s\n", moduleName, entity.getEntityName()));