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/04/14 15:28:12 UTC
[isis] 01/04: ISIS-2505_Catch_Up_With_Demo_Examples
This is an automated email from the ASF dual-hosted git repository.
joergrade pushed a commit to branch ISIS-2505_Catch_Up_With_Demo_Examples
in repository https://gitbox.apache.org/repos/asf/isis.git
commit d74ab00bebdf3356c6b0cb02f50a888ddbdcd89b
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Thu Jan 28 10:27:16 2021 +0100
ISIS-2505_Catch_Up_With_Demo_Examples
---
.../kroviz/core/aggregator/AggregatorWithLayout.kt | 34 ++++++++++++++++++++++
.../kroviz/core/aggregator/ListAggregator.kt | 31 ++------------------
.../kroviz/core/aggregator/ObjectAggregator.kt | 27 ++---------------
.../kroviz/snapshots/ResponseRegressionTest.kt | 2 ++
4 files changed, 42 insertions(+), 52 deletions(-)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/AggregatorWithLayout.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/AggregatorWithLayout.kt
new file mode 100644
index 0000000..ec26351
--- /dev/null
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/AggregatorWithLayout.kt
@@ -0,0 +1,34 @@
+package org.apache.isis.client.kroviz.core.aggregator
+
+import org.apache.isis.client.kroviz.core.model.DisplayModelWithLayout
+import org.apache.isis.client.kroviz.layout.Layout
+import org.apache.isis.client.kroviz.to.Represention
+import org.apache.isis.client.kroviz.to.TObject
+import org.apache.isis.client.kroviz.ui.kv.Constants
+
+abstract class AggregatorWithLayout : BaseAggregator() {
+
+ protected fun handleLayout(layout: Layout, dm: DisplayModelWithLayout) {
+ if (dm.layout == null) {
+ dm.addLayout(layout)
+ dm.propertyLayoutList.forEach { p ->
+ val l = p.link!!
+ val isDn = l.href.contains("datanucleus")
+ if (isDn) {
+ //invoking DN links leads to an error
+ invoke(l, this)
+ }
+ }
+ }
+ }
+
+ protected fun invokeLayoutLink(obj: TObject) {
+ val l = obj.getLayoutLink()!!
+ if (l.representation() == Represention.OBJECT_LAYOUT_BS3) {
+ invoke(l, this, Constants.subTypeXml)
+ } else {
+ invoke(l, this)
+ }
+ }
+
+}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ListAggregator.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ListAggregator.kt
index 7832d17..a1f5c8a 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ListAggregator.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ListAggregator.kt
@@ -24,7 +24,6 @@ import org.apache.isis.client.kroviz.core.model.ListDM
import org.apache.isis.client.kroviz.layout.Layout
import org.apache.isis.client.kroviz.to.*
import org.apache.isis.client.kroviz.to.bs3.Grid
-import org.apache.isis.client.kroviz.ui.kv.Constants
import org.apache.isis.client.kroviz.ui.kv.UiManager
/** sequence of operations:
@@ -34,7 +33,7 @@ import org.apache.isis.client.kroviz.ui.kv.UiManager
* (3) FR_OBJECT_PROPERTY PropertyHandler -> invoke()
* (4) FR_PROPERTY_DESCRIPTION <PropertyDescriptionHandler>
*/
-class ListAggregator(actionTitle: String) : BaseAggregator() {
+class ListAggregator(actionTitle: String) : AggregatorWithLayout() {
init {
dpm = ListDM(actionTitle)
@@ -49,7 +48,7 @@ class ListAggregator(actionTitle: String) : BaseAggregator() {
null -> log(logEntry)
is ResultList -> handleList(obj)
is TObject -> handleObject(obj)
- is Layout -> handleLayout(obj)
+ is Layout -> handleLayout(obj, dpm as ListDM)
is Grid -> handleGrid(obj)
is Property -> handleProperty(obj)
else -> log(logEntry)
@@ -72,33 +71,9 @@ class ListAggregator(actionTitle: String) : BaseAggregator() {
private fun handleObject(obj: TObject) {
dpm.addData(obj)
- val l = obj.getLayoutLink()!!
- if (l.representation() == Represention.OBJECT_LAYOUT_BS3) {
- invoke(l, this, Constants.subTypeXml)
- } else {
- invoke(l, this)
- }
+ invokeLayoutLink(obj)
}
- //TODO same code in ObjectAggregator? -> pullup refactoring to be applied
- private fun handleLayout(layout: Layout) {
- val dm = dpm as ListDM
- // TODO layout is passed in at least twice.
- // Eventually due to parallel invocations - only once required -> IMPROVE
- if (dm.layout == null) {
- dm.addLayout(layout)
- dm.propertyLayoutList.forEach { p ->
- val l = p.link!!
- val isDn = l.href.contains("datanucleus")
- val id = p.id!!
- dm.addPropertyDescription(id, id)
- if (!isDn) {
- //invoking DN links leads to an error
- invoke(l, this)
- }
- }
- }
- }
private fun handleGrid(grid: Grid) {
(dpm as ListDM).grid = grid
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ObjectAggregator.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ObjectAggregator.kt
index a432561..53b88bb 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ObjectAggregator.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ObjectAggregator.kt
@@ -24,7 +24,6 @@ import org.apache.isis.client.kroviz.layout.Layout
import org.apache.isis.client.kroviz.to.*
import org.apache.isis.client.kroviz.to.bs3.Grid
import org.apache.isis.client.kroviz.ui.ErrorDialog
-import org.apache.isis.client.kroviz.ui.kv.Constants
import org.apache.isis.client.kroviz.ui.kv.UiManager
/** sequence of operations:
@@ -34,7 +33,7 @@ import org.apache.isis.client.kroviz.ui.kv.UiManager
* (3) ???_OBJECT_PROPERTY PropertyHandler -> invoke()
* (4) ???_PROPERTY_DESCRIPTION <PropertyDescriptionHandler>
*/
-class ObjectAggregator(val actionTitle: String) : BaseAggregator() {
+class ObjectAggregator(val actionTitle: String) : AggregatorWithLayout() {
init {
dpm = ObjectDM(actionTitle)
@@ -46,7 +45,7 @@ class ObjectAggregator(val actionTitle: String) : BaseAggregator() {
is TObject -> handleObject(obj)
is ResultObject -> handleResultObject(obj)
is Property -> handleProperty(obj)
- is Layout -> handleLayout(obj)
+ is Layout -> handleLayout(obj, dpm as ObjectDM)
is Grid -> handleGrid(obj)
is HttpError -> ErrorDialog(logEntry).open()
else -> log(logEntry)
@@ -65,12 +64,7 @@ class ObjectAggregator(val actionTitle: String) : BaseAggregator() {
} else {
dpm.addData(obj)
}
- val l = obj.getLayoutLink()!!
- if (l.representation() == Represention.OBJECT_LAYOUT_BS3) {
- invoke(l, this, Constants.subTypeXml)
- } else {
- invoke(l, this)
- }
+ invokeLayoutLink(obj)
}
private fun invokeInstance(obj: TObject) {
@@ -94,21 +88,6 @@ class ObjectAggregator(val actionTitle: String) : BaseAggregator() {
console.log(property)
}
- private fun handleLayout(layout: Layout) {
- val dm = dpm as ObjectDM
- if (dm.layout == null) {
- dm.addLayout(layout)
- dm.propertyLayoutList.forEach { p ->
- val l = p.link!!
- val isDn = l.href.contains("datanucleus")
- if (isDn) {
- //invoking DN links leads to an error
- invoke(l, this)
- }
- }
- }
- }
-
private fun handleGrid(grid: Grid) {
(dpm as ObjectDM).grid = grid
}
diff --git a/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/snapshots/ResponseRegressionTest.kt b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/snapshots/ResponseRegressionTest.kt
index 6fcdb38..50679b9 100644
--- a/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/snapshots/ResponseRegressionTest.kt
+++ b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/snapshots/ResponseRegressionTest.kt
@@ -22,6 +22,7 @@ import org.apache.isis.client.kroviz.snapshots.demo2_0_0.Response2Handler
import org.apache.isis.client.kroviz.to.Link
import org.apache.isis.client.kroviz.to.Method
import org.apache.isis.client.kroviz.ui.kv.UiManager
+import pl.treksoft.kvision.require
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
@@ -36,6 +37,7 @@ class ResponseRegressionTest {
@BeforeTest
fun setup() {
+// require("xmlhttprequest").XmlHttpRequest;
val user = "sven"
val pw = "pass"
val url = "http://${user}:${pw}@localhost:8080/restful/"