You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jo...@apache.org on 2021/09/10 11:01:23 UTC

[isis] 06/07: ISIS-2846 link tree diagram / clean up

This is an automated email from the ASF dual-hosted git repository.

joergrade pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 290c6817a7f436bcf70ca5cb9394b0c96c6f96e5
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Fri Sep 10 12:56:48 2021 +0200

    ISIS-2846 link tree diagram / clean up
---
 .../apache/isis/client/kroviz/core/event/LogEntry.kt  |  4 ++--
 .../isis/client/kroviz/ui/diagram/LinkTreeDiagram.kt  | 19 +++++++++----------
 .../apache/isis/client/kroviz/ui/diagram/PumlCode.kt  | 16 +++++++++++++++-
 3 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
index 61e53c1..6e16d20 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
@@ -180,8 +180,8 @@ data class LogEntry(
             }
         }
         if (type == "") {
-            console.log("[LE.initType]")
-            console.log(this)
+            val stringList = url.split("/")
+            type = stringList.last()
         }
     }
 
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LinkTreeDiagram.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LinkTreeDiagram.kt
index 48685f4..e11cfc8 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LinkTreeDiagram.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LinkTreeDiagram.kt
@@ -26,6 +26,7 @@ import org.apache.isis.client.kroviz.core.event.ResourceSpecification
 import org.apache.isis.client.kroviz.to.HasLinks
 import org.apache.isis.client.kroviz.to.Property
 import org.apache.isis.client.kroviz.to.Relation
+import org.apache.isis.client.kroviz.to.Represention
 import org.apache.isis.client.kroviz.ui.core.UiManager
 import org.apache.isis.client.kroviz.utils.StringUtils
 
@@ -40,7 +41,7 @@ object LinkTreeDiagram {
             val root = tree.root
             pc.code += toPumlCode(root, 1)
         }
-        pc.mindmap()
+        pc.toMindmap()
         return pc.code
     }
 
@@ -51,18 +52,16 @@ object LinkTreeDiagram {
         val pc = PumlCode()
         if (le != null) {
             val title = StringUtils.shortTitle(url, protocolHostPort)
-            val depth = "*".repeat(level)
-            pc.add(depth).add(":")
             pc.addStereotype(le.type)
             pc.addLink(url, title)
             pc.addHorizontalLine()
             pc.add(linkInfo(le))
-            pc.addLine(";")
+            pc.toMindmapNode(level)
             node.children.forEach {
                 val childCode = toPumlCode(it, level + 1)
                 pc.add(childCode)
             }
-            if (le.type == "property-description") {
+            if (le.type == Represention.PROPERTY_DESCRIPTION.type) {
                 val pdCode = propertyDescriptionInfo(le, level + 1)
                 pc.add(pdCode)
             }
@@ -86,19 +85,19 @@ object LinkTreeDiagram {
                 }
             }
         }
+        pc.trim()
         return pc.code
     }
 
-    private fun propertyDescriptionInfo(logEntry: LogEntry, level: Int) : String {
+    private fun propertyDescriptionInfo(logEntry: LogEntry, level: Int): String {
         val pc = PumlCode()
         val obj = logEntry.obj
         if (obj != null) {
-            val depth = "*".repeat(level)
-            pc.add(depth).add(":")
             val ets = (obj as Property).extensions!!
             pc.addLine("friendlyName: " + ets.friendlyName)
-            pc.addLine("descriptions: " + ets.description)
-            pc.addLine(";")
+            pc.addHorizontalLine()
+            pc.add("descriptions: " + ets.description)
+            pc.toMindmapNode(level)
         }
         return pc.code
     }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/PumlCode.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/PumlCode.kt
index 86410eb..ebc57e6 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/PumlCode.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/PumlCode.kt
@@ -55,11 +55,17 @@ class PumlCode() {
         return this
     }
 
-    fun mindmap(): PumlCode {
+    fun toMindmap(): PumlCode {
         code += "@startmindmap$NL" + code + "@endmindmap$NL"
         return this
     }
 
+    fun toMindmapNode(level:Int): PumlCode {
+        val depth = "*".repeat(level)
+        code = depth + ":" + code + ";" + NL
+        return this
+    }
+
     private fun center(s: String): String {
         return ".." + s + ".."
     }
@@ -80,4 +86,12 @@ class PumlCode() {
         code += "----" + NL
         return this
     }
+
+    fun trim(): PumlCode {
+        if (code.endsWith(NL)) {
+            code = code.dropLast(1)
+        }
+        return this
+    }
+
 }