fix rendering of permissions and target table in INSERT-Permission in runtime RBAC-diagrams

This commit is contained in:
Michael Hoennig 2024-05-07 06:27:53 +02:00
parent 2e9e5d6ef0
commit b56e27b1a9

View File

@ -8,6 +8,7 @@ import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
@ -25,6 +26,7 @@ public class RbacGrantsDiagramService {
public static void writeToFile(final String title, final String graph, final String fileName) { public static void writeToFile(final String title, final String graph, final String fileName) {
new File("doc/temp").mkdirs();
try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
writer.write(""" writer.write("""
### all grants to %s ### all grants to %s
@ -192,8 +194,9 @@ public class RbacGrantsDiagramService {
return "[" + roleType + "\nref:" + uuid + "]"; return "[" + roleType + "\nref:" + uuid + "]";
} }
if (refType.equals("perm")) { if (refType.equals("perm")) {
final var roleType = idName.split(":")[1]; final var parts = idName.split(":");
return "{{" + roleType + "\nref:" + uuid + "}}"; final var permType = parts[2];
return "{{" + permType + "\nref:" + uuid + "}}";
} }
return ""; return "";
} }
@ -205,7 +208,7 @@ public class RbacGrantsDiagramService {
@NotNull @NotNull
private static String cleanId(final String idName) { private static String cleanId(final String idName) {
return idName.replaceAll("@.*", "") return idName.replaceAll("@.*", "")
.replace("[", "").replace("]", "").replace("(", "").replace(")", "").replace(",", ""); .replace("[", "").replace("]", "").replace("(", "").replace(")", "").replace(",", "").replace(">", ":");
} }