You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by jo...@apache.org on 2023/02/23 20:09:09 UTC

[causeway] 09/10: ISIS-3171 more cleanup

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

joergrade pushed a commit to branch ISIS-3171
in repository https://gitbox.apache.org/repos/asf/causeway.git

commit cabe94b0c156ff6b1ef9560c411f22971a0fb3a9
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Thu Feb 16 23:36:07 2023 +0100

    ISIS-3171 more cleanup
---
 .../kroviz/core/aggregator/CollectionAggregator.kt | 26 +++++++++++++---------
 .../kroviz/core/aggregator/ObjectAggregator.kt     |  5 ++---
 .../client/kroviz/core/model/CollectionDM.kt       | 24 ++------------------
 .../causeway/client/kroviz/core/model/ObjectDM.kt  |  9 ++++----
 .../client/kroviz/core/model/ObjectLayout.kt       |  7 +++---
 .../causeway/client/kroviz/core/model/SystemDM.kt  |  3 +--
 .../causeway/client/kroviz/to/bs/PropertyBs.kt     |  2 +-
 7 files changed, 30 insertions(+), 46 deletions(-)

diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregator.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregator.kt
index c1c4efa53f..558fda52ac 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregator.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregator.kt
@@ -20,7 +20,6 @@ package org.apache.causeway.client.kroviz.core.aggregator
 
 import org.apache.causeway.client.kroviz.core.event.EventState
 import org.apache.causeway.client.kroviz.core.event.LogEntry
-import org.apache.causeway.client.kroviz.core.event.ResourceProxy
 import org.apache.causeway.client.kroviz.core.event.ResourceSpecification
 import org.apache.causeway.client.kroviz.core.model.CollectionDM
 import org.apache.causeway.client.kroviz.to.*
@@ -106,8 +105,18 @@ class CollectionAggregator(actionTitle: String, private val parent: ObjectAggreg
             dm.setProtoType(tObj)
             invokeLayoutLink(tObj, this, referrer = referrer)
         }
-        //TODO fold layout into model
-        getDisplayModel().addObject(tObj, this, referrer = referrer)
+
+        // collection layout needs only to be initialized once with an object (pars pro toto, prototype)
+        // obj acts as a kind prototype - we assume all elements in the collection have the same structure
+        val propertySpecificationHolder = getDisplayModel().propertySpecificationHolder
+        if (!propertySpecificationHolder.isInitialized()) {
+            val members = tObj.getProperties()
+            members.forEach { m ->
+                propertySpecificationHolder.addMember(m)
+                val l = m.getInvokeLink()!!
+                invoke(l, this, referrer = referrer)
+            }
+        }
 
         invokeIconLink(tObj, this, referrer = referrer)
     }
@@ -143,7 +152,7 @@ class CollectionAggregator(actionTitle: String, private val parent: ObjectAggreg
             property.isObjectProperty() -> {
                 val op = ObjectProperty(property)
                 val pdLink = op.getDescriptionLink()!!
-                ResourceProxy().fetch(pdLink, this, referrer = referrer)
+                invoke(pdLink, this, referrer = referrer)
             }
 
             property.isPropertyDescription() -> {
@@ -157,23 +166,20 @@ class CollectionAggregator(actionTitle: String, private val parent: ObjectAggreg
         }
     }
 
-
     private fun handleCollection(collection: Collection) {
         if (isParentedCollection()) {
-            //TODO is _id_ required in both CollectionDM and CollectionLayout?
-            val id = collection.id
-            getDisplayModel().id = id
+            getDisplayModel().id = collection.id
             // add displayModel to parent.displayModel
             val objectDM = parent!!.getDisplayModel()
             objectDM.addCollectionModel(getDisplayModel())
         }
         collection.links.forEach {
             if (it.relation() == Relation.DESCRIBED_BY) {
-                ResourceProxy().fetch(it, this, referrer = referrer)
+                invoke(it, this, referrer = referrer)
             }
         }
         collection.value.forEach {
-            ResourceProxy().fetch(it, this, referrer = referrer)
+            invoke(it, this, referrer = referrer)
         }
     }
 
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/ObjectAggregator.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/ObjectAggregator.kt
index 3bbc286a5c..32b12dce3b 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/ObjectAggregator.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/ObjectAggregator.kt
@@ -19,7 +19,6 @@
 package org.apache.causeway.client.kroviz.core.aggregator
 
 import org.apache.causeway.client.kroviz.core.event.LogEntry
-import org.apache.causeway.client.kroviz.core.event.ResourceProxy
 import org.apache.causeway.client.kroviz.core.model.ObjectDM
 import org.apache.causeway.client.kroviz.core.model.ObjectLayout
 import org.apache.causeway.client.kroviz.to.*
@@ -68,7 +67,7 @@ class ObjectAggregator(val actionTitle: String) : AggregatorWithLayout() {
         if (obj.getProperties().size == 0) {
             invokeInstance(obj, referrer)
         } else {
-            displayModel.addData(obj, this, referrer)
+            displayModel.addData(obj)
         }
         invokeLayoutLink(obj, this, referrer = referrer)
     }
@@ -113,7 +112,7 @@ class ObjectAggregator(val actionTitle: String) : AggregatorWithLayout() {
             ol.addGrid(grid, this, referrer = referrer)
             grid.getPropertyList().forEach {
                 val link = it.link!!
-                ResourceProxy().fetch(link, this, subType = Constants.subTypeJson, referrer = referrer)
+                invoke(link, this, subType = Constants.subTypeJson, referrer = referrer)
             }
         }
     }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionDM.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionDM.kt
index 881ffd0a63..84ded48825 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionDM.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionDM.kt
@@ -19,8 +19,6 @@
 package org.apache.causeway.client.kroviz.core.model
 
 import io.kvision.state.observableListOf
-import org.apache.causeway.client.kroviz.core.aggregator.CollectionAggregator
-import org.apache.causeway.client.kroviz.core.event.ResourceProxy
 import org.apache.causeway.client.kroviz.to.PropertyDescription
 import org.apache.causeway.client.kroviz.to.TObject
 import org.apache.causeway.client.kroviz.to.TransferObject
@@ -45,36 +43,18 @@ class CollectionDM(override val title: String) : DisplayModelWithLayout() {
         }
     }
 
-    /**
-     * collection layout needs only to be initialized once with an object (pars pro toto, prototype)
-     * obj acts as a kind prototype - we assume all elements in the collection have the same structure
-     */
-    fun addObject(obj: TObject, aggregator: CollectionAggregator, referrer: String) {
-        if (!propertySpecificationHolder.isInitialized()) {
-            // members contain all properties, regardless if hidden, disabled, etc.
-            val members = obj.getProperties()
-            members.forEach { m ->
-                propertySpecificationHolder.addMember(m)
-                val l = m.getInvokeLink()!!
-                //TODO pull up to Aggregator
-                ResourceProxy().fetch(l, aggregator, referrer = referrer)
-            }
-        }
-    }
-
     private fun addPropertyDetails(propertyBs: PropertyBs) {
         val id = propertyBs.id
-        val ps: PropertySpecification = propertySpecificationHolder.getPropertySpecification(id)
+        val ps = propertySpecificationHolder.getPropertySpecification(id)
         ps.amendWith(propertyBs)
     }
 
     fun addPropertyDescription(propertyDescription: PropertyDescription) {
         val id = propertyDescription.id
-        val ps: PropertySpecification = propertySpecificationHolder.getPropertySpecification(id)
+        val ps = propertySpecificationHolder.getPropertySpecification(id)
         ps.amendWith(propertyDescription)
     }
 
-
     fun hasProtoType(): Boolean {
         return protoType != null
     }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectDM.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectDM.kt
index 57a952fe52..3ed71589f1 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectDM.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectDM.kt
@@ -18,7 +18,6 @@
  */
 package org.apache.causeway.client.kroviz.core.model
 
-import org.apache.causeway.client.kroviz.core.aggregator.AggregatorWithLayout
 import org.apache.causeway.client.kroviz.core.event.ResourceProxy
 import org.apache.causeway.client.kroviz.core.event.ResourceSpecification
 import org.apache.causeway.client.kroviz.layout.Layout
@@ -31,7 +30,7 @@ class ObjectDM(override val title: String) : DisplayModelWithLayout() {
         layout = ObjectLayout()
     }
 
-    val collectionModelList = mutableListOf<CollectionDM>()
+    private val collectionModelList = mutableListOf<CollectionDM>()
     var data: Exposer? = null
     private var dirty: Boolean = false
 
@@ -41,7 +40,7 @@ class ObjectDM(override val title: String) : DisplayModelWithLayout() {
 
     fun addCollectionModel(collectionModel: CollectionDM) {
         val id = collectionModel.id
-        val foundModel = collectionModelList.firstOrNull() {
+        val foundModel = collectionModelList.firstOrNull {
             it.id == id
         }
         if (foundModel == null) {
@@ -75,7 +74,7 @@ class ObjectDM(override val title: String) : DisplayModelWithLayout() {
         return true
     }
 
-    override fun addData(obj: TransferObject, aggregator: AggregatorWithLayout?, referrer: String?) {
+    override fun addData(obj: TransferObject) {
         (obj as TObject)
         val exo = Exposer(obj)
         data = exo.dynamise() as? Exposer
@@ -102,7 +101,7 @@ class ObjectDM(override val title: String) : DisplayModelWithLayout() {
             val href = getLink.href
             val reSpec = ResourceSpecification(href)
             val es = SessionManager.getEventStore()
-            //WATCHOUT this is sequence dependent: GET and PUT share the same URL - if called after PUTting, it may fail
+            //WATCHOUT this is sequence dependent: GET and PUT share the same URL - if called after PUTing, it may fail
             val getLogEntry = es.findBy(reSpec)!!
             getLogEntry.setReload()
 
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectLayout.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectLayout.kt
index 9ca18153de..0d165f817e 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectLayout.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectLayout.kt
@@ -29,18 +29,19 @@ import org.apache.causeway.client.kroviz.to.bs.RowBs
 class ObjectLayout : BaseLayout() {
 
     var grid: GridBs? = null
-    private val collectionLayoutList = mutableListOf< CollectionLayout>()
+    //FIXME
+//    private val collectionLayoutList = mutableListOf< CollectionLayout>()
 
     override fun readyToRender(): Boolean {
         return when (grid) {
             null -> false
             else -> {
                 var answer = true
-                collectionLayoutList.forEach {
+ /*               collectionLayoutList.forEach {
                     if (!it.readyToRender()) {
                         answer = false
                     }
-                }
+                }*/
                 answer
             }
         }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/SystemDM.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/SystemDM.kt
index 3ebf1d3deb..319a87836c 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/SystemDM.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/SystemDM.kt
@@ -18,7 +18,6 @@
  */
 package org.apache.causeway.client.kroviz.core.model
 
-import org.apache.causeway.client.kroviz.core.aggregator.AggregatorWithLayout
 import org.apache.causeway.client.kroviz.to.*
 
 class SystemDM(override val title: String) : BaseDisplayModel() {
@@ -32,7 +31,7 @@ class SystemDM(override val title: String) : BaseDisplayModel() {
         return !isRendered
     }
 
-    override fun addData(obj: TransferObject, aggregator: AggregatorWithLayout?, referrer: String?) {
+    override fun addData(obj: TransferObject) {
         when (obj) {
             is User -> user = obj
             is Version -> version = obj
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/to/bs/PropertyBs.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/to/bs/PropertyBs.kt
index 29d3773225..a9a42ee5cc 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/to/bs/PropertyBs.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/to/bs/PropertyBs.kt
@@ -34,7 +34,7 @@ class PropertyBs(node: Node) : XmlLayout() {
     lateinit var action: ActionBs
 
     init {
-        // TODO improve casting
+        // TODO improve casting, in PropertySpecification some extra check have to be performed
         val dn = node.asDynamic()
         hidden = dn.getAttribute("hidden").unsafeCast<String>()
         id = dn.getAttribute("id").unsafeCast<String>()