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/12 05:29:54 UTC
[isis] 03/04: ISIS-2355 Convert object to JSON and vizualize as well
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 879a6ff617a759ebc38ad37632e5d42b5f654ed1
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Sun Sep 12 07:29:18 2021 +0200
ISIS-2355 Convert object to JSON and vizualize as well
---
incubator/clients/kroviz/build.gradle.kts | 1 +
.../isis/client/kroviz/ui/dialog/EventLogDetail.kt | 18 ++++++++++++++++
.../org/apache/isis/client/kroviz/utils/Flatted.kt | 25 ++++++++++++++++++++++
3 files changed, 44 insertions(+)
diff --git a/incubator/clients/kroviz/build.gradle.kts b/incubator/clients/kroviz/build.gradle.kts
index a498c12..455b821 100644
--- a/incubator/clients/kroviz/build.gradle.kts
+++ b/incubator/clients/kroviz/build.gradle.kts
@@ -93,6 +93,7 @@ kotlin {
implementation("io.kvision:kvision-moment:$kvisionVersion")
implementation("io.kvision:kvision-maps:$kvisionVersion")
implementation(npm("xmltojson", "1.3.5", false))
+ implementation(npm("flatted", "3.2.2", false))
}
sourceSets["test"].dependencies {
implementation(kotlin("test-js"))
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt
index afd9e98..cf63a15 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt
@@ -29,6 +29,7 @@ import org.apache.isis.client.kroviz.ui.core.RoDialog
import org.apache.isis.client.kroviz.ui.diagram.JsonDiagram
import org.apache.isis.client.kroviz.ui.diagram.LayoutDiagram
import org.apache.isis.client.kroviz.ui.diagram.LinkTreeDiagram
+import org.apache.isis.client.kroviz.utils.Flatted
import org.apache.isis.client.kroviz.utils.StringUtils
import org.apache.isis.client.kroviz.utils.XmlHelper
@@ -46,6 +47,7 @@ class EventLogDetail(val logEntryFromTabulator: LogEntry) : Command() {
// callback parameter
private val LOG: String = "log"
private val LNK: String = "lnk"
+ private val DPM: String = "dpm"
fun open() {
val responseStr = if (logEntry.subType == Constants.subTypeJson) {
@@ -61,6 +63,7 @@ class EventLogDetail(val logEntryFromTabulator: LogEntry) : Command() {
val customButtons = mutableListOf<FormItem>()
customButtons.add(FormItem("Link Tree Diagram", ValueType.BUTTON, null, callBack = this, callBackAction = LNK))
+ customButtons.add(FormItem("Display Model Diagram", ValueType.BUTTON, null, callBack = this, callBackAction = DPM))
customButtons.add(FormItem("Console", ValueType.BUTTON, null, callBack = this, callBackAction = LOG))
dialog = RoDialog(
@@ -82,6 +85,9 @@ class EventLogDetail(val logEntryFromTabulator: LogEntry) : Command() {
action == LNK -> {
linkTreeDiagram()
}
+ action == DPM -> {
+ displayModelDiagram()
+ }
else -> {
console.log(logEntry)
console.log("Action not defined yet: " + action)
@@ -97,6 +103,18 @@ class EventLogDetail(val logEntryFromTabulator: LogEntry) : Command() {
dialog.close()
}
+ private fun displayModelDiagram() {
+ logEntry.aggregators.forEach {
+ val dpm = it.dpm
+ val json = Flatted.stringify(dpm)
+ console.log("[ELD.displayModelDiagram]")
+ console.log(json)
+ val code = JsonDiagram.build(json)
+ DiagramDialog("Display Model Diagram", code).open()
+ }
+ dialog.close()
+ }
+
private fun defaultAction() {
val str = logEntry.response
var label = "Diagram"
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/Flatted.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/Flatted.kt
new file mode 100644
index 0000000..3245e3e
--- /dev/null
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/Flatted.kt
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.client.kroviz.utils
+
+@JsModule("flatted")
+@JsNonModule
+external object Flatted {
+ fun stringify(obj: Any): String
+}