import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.util.Optional;
import static guru.nidi.graphviz.attribute.Rank.RankDir;
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' ><< Refer to Module >></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(
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;
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()));