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/26 16:32:59 UTC

[causeway] branch ISIS-3171 updated: ISIS-3171 more renaming and refactoring

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


The following commit(s) were added to refs/heads/ISIS-3171 by this push:
     new 62f4be6e45 ISIS-3171 more renaming and refactoring
62f4be6e45 is described below

commit 62f4be6e4571b22ed9b8c3e2e66cff6931460b72
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Sun Feb 26 17:32:49 2023 +0100

    ISIS-3171 more renaming and refactoring
---
 .../kroviz/core/aggregator/AggregatorWithLayout.kt |  5 +--
 .../kroviz/core/aggregator/CollectionAggregator.kt |  6 +--
 .../kroviz/core/aggregator/ObjectAggregator.kt     |  6 +--
 .../client/kroviz/core/model/CollectionDM.kt       |  8 ++--
 ...nSpecificationHolder.kt => CollectionLayout.kt} | 16 ++++----
 .../client/kroviz/core/model/ColumnProperties.kt   | 41 -------------------
 .../causeway/client/kroviz/core/model/ObjectDM.kt  | 11 -----
 .../kroviz/core/model/ObjectSpecificationHolder.kt | 47 ----------------------
 .../{ColumnSpecification.kt => PropertyDetails.kt} |  2 +-
 .../causeway/client/kroviz/to/bs/PropertyBs.kt     |  2 +-
 .../client/kroviz/ui/core/ColumnFactory.kt         |  4 +-
 11 files changed, 22 insertions(+), 126 deletions(-)

diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/AggregatorWithLayout.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/AggregatorWithLayout.kt
index 66bcd434e3..00aadd9694 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/AggregatorWithLayout.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/AggregatorWithLayout.kt
@@ -19,9 +19,8 @@
 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.BaseLayout
-import org.apache.causeway.client.kroviz.to.*
+import org.apache.causeway.client.kroviz.to.Represention
+import org.apache.causeway.client.kroviz.to.TObject
 import org.apache.causeway.client.kroviz.ui.core.Constants
 import org.apache.causeway.client.kroviz.ui.diagram.Tree
 
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 e990959d77..2d8ba7484c 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
@@ -102,13 +102,13 @@ class CollectionAggregator(actionTitle: String, private val parent: ObjectAggreg
         val dm = getDisplayModel()
         dm.addData(tObj)
         if (!dm.hasProtoType()) {
+            // 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
             dm.setProtoType(tObj)
             invokeLayoutLink(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().columnSpecificationHolder
+        val propertySpecificationHolder = getDisplayModel().collectionLayout
         if (!propertySpecificationHolder.isInitialized()) {
             val members = tObj.getProperties()
             members.forEach { m ->
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 9f289787f8..bdfff78ac6 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
@@ -98,11 +98,7 @@ class ObjectAggregator(private val actionTitle: String) : AggregatorWithLayout()
     }
 
     private fun handleProperty(p: Property, referrer: String) {
-        val dm = getDisplayModel()
-        if (p.isPropertyDescription()) {
-            dm.addPropertyDescription(p)
-        } else {
-            dm.addProperty(p)
+        if (!p.isPropertyDescription()) {
             val pdl = p.getDescriptionLink() ?: return
             invoke(pdl, this, 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 50ffd989d4..63edeafe3e 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
@@ -27,7 +27,7 @@ import org.apache.causeway.client.kroviz.to.bs.PropertyBs
 import org.apache.causeway.client.kroviz.utils.StringUtils
 
 class CollectionDM(override val title: String) : DisplayModelWithLayout() {
-    val columnSpecificationHolder = ColumnSpecificationHolder()
+    val collectionLayout = CollectionLayout()
 
     var id = ""
     var data = observableListOf<Exposer>()
@@ -51,13 +51,13 @@ class CollectionDM(override val title: String) : DisplayModelWithLayout() {
 
     private fun addPropertyDetails(propertyBs: PropertyBs) {
         val id = propertyBs.id
-        val ps = columnSpecificationHolder.getPropertySpecification(id)
+        val ps = collectionLayout.getPropertySpecification(id)
         ps.amendWith(propertyBs)
     }
 
     fun addPropertyDescription(propertyDescription: PropertyDescription) {
         val id = propertyDescription.id
-        val ps = columnSpecificationHolder.getPropertySpecification(id)
+        val ps = collectionLayout.getPropertySpecification(id)
         ps.amendWith(propertyDescription)
     }
 
@@ -70,7 +70,7 @@ class CollectionDM(override val title: String) : DisplayModelWithLayout() {
     }
 
     override fun readyToRender(): Boolean {
-        return id.isNotEmpty() && columnSpecificationHolder.readyToRender()
+        return id.isNotEmpty() && collectionLayout.readyToRender()
     }
 
     override fun addData(obj: TransferObject) {
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ColumnSpecificationHolder.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt
similarity index 75%
rename from incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ColumnSpecificationHolder.kt
rename to incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt
index 15dca34982..413e4bf902 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ColumnSpecificationHolder.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt
@@ -20,11 +20,11 @@ package org.apache.causeway.client.kroviz.core.model
 
 import org.apache.causeway.client.kroviz.to.Member
 
-class ColumnSpecificationHolder {
-    var columnSpecificationList = mutableListOf<ColumnSpecification>()
+class CollectionLayout {
+    var propertyDetailsList = mutableListOf<PropertyDetails>()
 
-    fun getPropertySpecification(id: String): ColumnSpecification {
-        return columnSpecificationList.firstOrNull { it.id == id }!!
+    fun getPropertySpecification(id: String): PropertyDetails {
+        return propertyDetailsList.firstOrNull { it.id == id }!!
     }
 
     fun readyToRender(): Boolean {
@@ -32,7 +32,7 @@ class ColumnSpecificationHolder {
     }
 
     private fun arePropertySpecificationsReadyToRender(): Boolean {
-        columnSpecificationList.forEach {
+        propertyDetailsList.forEach {
             val ready = it.readyToRender()
             if (!ready) {
                 return false
@@ -42,12 +42,12 @@ class ColumnSpecificationHolder {
     }
 
     fun addMember(m: Member) {
-        val ps = ColumnSpecification(m)
-        columnSpecificationList.add(ps)
+        val ps = PropertyDetails(m)
+        propertyDetailsList.add(ps)
     }
 
     fun isInitialized(): Boolean {
-        return columnSpecificationList.isNotEmpty() && columnSpecificationList.size > 0
+        return propertyDetailsList.isNotEmpty() && propertyDetailsList.size > 0
     }
 
 }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ColumnProperties.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ColumnProperties.kt
deleted file mode 100644
index 19513ec867..0000000000
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ColumnProperties.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *  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.causeway.client.kroviz.core.model
-
-import org.apache.causeway.client.kroviz.layout.PropertyLt
-import org.apache.causeway.client.kroviz.to.Property
-import org.apache.causeway.client.kroviz.to.bs.PropertyBs
-
-/**
- * Properties have three aspects:
- *
- * - Member of a DomainObject
- * - Description (friendlyName, etc.)
- * - Layout (hidden, labelPosition, etc.)
- *
- * All three are required in order to display correctly in a table.
- */
-@Deprecated("Rework/Rename")
-class ColumnProperties(val key: String) {
-    var property: Property? = null
-    var friendlyName: String = ""
-    var layout: PropertyLt? = null
-    var grid: PropertyBs? = null
-    var hidden: Boolean = false
-}
\ No newline at end of file
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 e4349b6de2..d1a3349861 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
@@ -26,7 +26,6 @@ import org.apache.causeway.client.kroviz.to.bs.GridBs
 import org.apache.causeway.client.kroviz.ui.core.SessionManager
 
 class ObjectDM(override val title: String) : DisplayModelWithLayout() {
-    val properties = ObjectSpecificationHolder()
     private val collectionModelList = mutableListOf<CollectionDM>()
     var data: Exposer? = null
     private var dirty: Boolean = false
@@ -50,8 +49,6 @@ class ObjectDM(override val title: String) : DisplayModelWithLayout() {
     }
 
     fun getCollectionDisplayModelFor(id: String): CollectionDM {
-        console.log("[ODM_getCollectionDisplayModelFor] answers null under some conditions")
-        console.log(collectionModelList)
         return collectionModelList.firstOrNull { it.id == id }!!
     }
 
@@ -78,14 +75,6 @@ class ObjectDM(override val title: String) : DisplayModelWithLayout() {
         data = exo.dynamise() as? Exposer
     }
 
-    fun addPropertyDescription(p: Property) {
-        properties.addPropertyDescription(p)
-    }
-
-    fun addProperty(property: Property) {
-        properties.addProperty(property)
-    }
-
     fun addResult(resultObject: ResultObject) {
         val tObj = createObjectFrom(resultObject)
         this.addData(tObj)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectSpecificationHolder.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectSpecificationHolder.kt
deleted file mode 100644
index 4c1aa3457b..0000000000
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ObjectSpecificationHolder.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *  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.causeway.client.kroviz.core.model
-
-import org.apache.causeway.client.kroviz.layout.PropertyLt
-import org.apache.causeway.client.kroviz.to.Property
-
-@Deprecated("Rework/Rename")
-class ObjectSpecificationHolder {
-    private var propertyDescriptionList = mutableListOf<Property>()
-    private var propertyLayoutList = mutableListOf<PropertyLt>()
-    var propertyList = mutableListOf<Property>()
-    private var descriptionsComplete = false
-
-    fun readyToRender(): Boolean {
-        val ps = propertyList.size
-        val pls = propertyLayoutList.size
-        val pds = propertyDescriptionList.size
-        descriptionsComplete = (pds >= pls) && (ps >= pls)
-        return descriptionsComplete
-    }
-
-    fun addProperty(property: Property) {
-        propertyList.add(property)
-    }
-
-    fun addPropertyDescription(description: Property) {
-        propertyDescriptionList.add(description)
-    }
-
-}
\ No newline at end of file
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ColumnSpecification.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertyDetails.kt
similarity index 98%
rename from incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ColumnSpecification.kt
rename to incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertyDetails.kt
index ee009457b7..9da0ae4089 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/ColumnSpecification.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertyDetails.kt
@@ -28,7 +28,7 @@ import org.apache.causeway.client.kroviz.to.bs.PropertyBs
  * - id :           attribute to be used to retrieve the value of each cell (id)
  * - hidden :       will the column be displayed or not
  */
-class ColumnSpecification(member: Member) {
+class PropertyDetails(member: Member) {
     var id = member.id
     var name = "" // aka: columnName, named, label, title
     var hidden = true
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 f37f7a8131..cca4cffd94 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, in ColumnSpecification some extra check have to be performed
+        // TODO improve casting, in PropertyDetails some extra check have to be performed
         val dn = node.asDynamic()
         hidden = dn.getAttribute("hidden").unsafeCast<String>()
         id = dn.getAttribute("id").unsafeCast<String>()
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ColumnFactory.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ColumnFactory.kt
index bb3b1b9962..e21d79f37f 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ColumnFactory.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ColumnFactory.kt
@@ -103,8 +103,8 @@ class ColumnFactory {
         collectionModel: CollectionDM,
         columns: MutableList<ColumnDefinition<Exposer>>,
     ) {
-        val clo = collectionModel.columnSpecificationHolder
-        val propSpecList = clo.columnSpecificationList
+        val clo = collectionModel.collectionLayout
+        val propSpecList = clo.propertyDetailsList
         if (propSpecList.size == 0) {
             // without this, propSpecList is empty? problem with mutable list?
             throw IllegalStateException()