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:22 UTC

[isis] 05/07: ISIS-2846 link tree diagram works correctly, including extension properties

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 8ce7c80b3ff75d6e2f520d1b6321f31e6c1839ae
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Thu Sep 9 18:20:46 2021 +0200

    ISIS-2846 link tree diagram works correctly, including extension properties
---
 .../isis/client/kroviz/core/event/LogEntry.kt      | 11 +++++--
 .../client/kroviz/ui/diagram/LinkTreeDiagram.kt    | 34 ++++++++++++----------
 2 files changed, 27 insertions(+), 18 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 b53d774..61e53c1 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
@@ -56,8 +56,9 @@ data class LogEntry(
         val method: String? = "",
         val request: String = "",
         @Contextual val createdAt: Date = Date()) {
-    val url:String = rs.url
-    val referrer = rs.referrerUrl
+    val url: String = rs.url
+
+    //    val referrer = rs.referrerUrl
     val subType = rs.subType
     var state = EventState.INITIAL
     var title: String = ""
@@ -175,9 +176,13 @@ data class LogEntry(
             val self = (obj as HasLinks).getLinks().firstOrNull() { it.relation() == Relation.SELF }
             if (self != null) {
                 val t = self.type.removePrefix("application/json;profile=\"urn:org.restfulobjects:repr-types/")
-                this.type = t.removeSuffix("\"")
+                type = t.removeSuffix("\"")
             }
         }
+        if (type == "") {
+            console.log("[LE.initType]")
+            console.log(this)
+        }
     }
 
 // region response
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 4a09ec3..48685f4 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
@@ -24,6 +24,7 @@ import org.apache.isis.client.kroviz.core.event.EventStore
 import org.apache.isis.client.kroviz.core.event.LogEntry
 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.ui.core.UiManager
 import org.apache.isis.client.kroviz.utils.StringUtils
@@ -33,16 +34,13 @@ object LinkTreeDiagram {
     private val protocolHostPort = UiManager.getUrl()
 
     fun build(aggregator: BaseAggregator): String {
-        console.log("[LTD.build]")
         val pc = PumlCode()
         if (aggregator is AggregatorWithLayout) {
             val tree = aggregator.tree!!
             val root = tree.root
-            console.log(root)
             pc.code += toPumlCode(root, 1)
         }
         pc.mindmap()
-        console.log(pc.code)
         return pc.code
     }
 
@@ -53,23 +51,26 @@ object LinkTreeDiagram {
         val pc = PumlCode()
         if (le != null) {
             val title = StringUtils.shortTitle(url, protocolHostPort)
-            val type = le.selfType()
             val depth = "*".repeat(level)
             pc.add(depth).add(":")
-            pc.addStereotype(type)
+            pc.addStereotype(le.type)
             pc.addLink(url, title)
             pc.addHorizontalLine()
-            pc.add(traceInfo(le))
+            pc.add(linkInfo(le))
             pc.addLine(";")
             node.children.forEach {
                 val childCode = toPumlCode(it, level + 1)
                 pc.add(childCode)
             }
+            if (le.type == "property-description") {
+                val pdCode = propertyDescriptionInfo(le, level + 1)
+                pc.add(pdCode)
+            }
         }
         return pc.code
     }
 
-    private fun traceInfo(logEntry: LogEntry): String {
+    private fun linkInfo(logEntry: LogEntry): String {
         val pc = PumlCode()
         val obj = logEntry.obj
         if (obj != null) {
@@ -88,15 +89,18 @@ object LinkTreeDiagram {
         return pc.code
     }
 
-    private fun LogEntry.selfType(): String {
-        val selfLink = this.selfLink()
-        return if (selfLink != null) {
-            selfLink.representation().type
-        } else {
-            console.log("[LE.selfType]")
-            console.log(this)
-            ""
+    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(";")
         }
+        return pc.code
     }
 
 }