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 4e685851d2e30187c7055352be26c965e8e3a79c Author: Jörg Rade <[email protected]> AuthorDate: Wed Feb 8 17:36:04 2023 +0100 ISIS-3171 Basic_Types.Strings opens, but table is without icons and columns --- .../design/collection_layout_aggregation.adoc | 126 --------------------- .../collection_layout_aggregation_diagram.adoc | 125 ++++++++++++++++++++ .../kroviz/core/aggregator/BaseAggregator.kt | 2 - .../kroviz/core/aggregator/CollectionAggregator.kt | 88 ++++++++------ .../kroviz/core/aggregator/ObjectAggregator.kt | 51 +++------ .../client/kroviz/core/model/BaseLayout.kt | 4 +- .../client/kroviz/core/model/CollectionDM.kt | 1 + .../client/kroviz/core/model/CollectionLayout.kt | 76 +++++++------ .../causeway/client/kroviz/core/model/ObjectDM.kt | 7 +- .../client/kroviz/core/model/ObjectLayout.kt | 52 ++++++--- .../kroviz/core/model/PropertySpecification.kt | 46 +++----- .../client/kroviz/ui/builder/ColBuilder.kt | 16 ++- .../client/kroviz/ui/core/ColumnFactory.kt | 2 + .../causeway/client/kroviz/ui/core/ViewManager.kt | 2 + .../core/aggregator/CollectionAggregatorTest.kt | 2 +- 15 files changed, 304 insertions(+), 296 deletions(-) diff --git a/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation.adoc b/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation.adoc index 903ab69a23..a5f29bfcdf 100644 --- a/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation.adoc +++ b/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation.adoc @@ -1,4 +1,3 @@ - |=== |repr-type |Aggregator |referrer (parent)|link @@ -33,128 +32,3 @@ |http://localhost:9090/restful/domain-types/demo.JavaLangStringEntity/properties/mixinProperty |=== -.Collection Layout Aggregation -[plantuml,file="layout_aggregation.png"] ----- -allowmixing - -() START -() END -together { - file "..<<xml>>..\nobject-layout" as OL - class "<<TransferObject>>\nGridBs" as GRID {} - OL . GRID -} -together { - file "..<<json>>..\nobject-collection" as OC - class "<<TransferObject>>\nCollection" as COL { - id - memberType= Collection - value[] = data - } - COL . OC -} -together { - file "<<json>>\n..object.." as O - class "<<TransferObject>>\nTObject" as TOBJ { - members[] - } - TOBJ . O -} -file "..<<json>>..\ncollection-description" as CD - -together { - file "..<<json>>..\nobject-property" as OP - class "<<TransferObject>>\nObjectProperty" as OPR { - disabledReason - } - OP . OPR -} -together { - file "..<<json>>..\nproperty-description" as PD - class "<<TransferObject>>\nPropertyDescription" as PRD { - extensions.friendlyName - } - PD .r. PRD -} - -' references between TransferObjects (xml/json) -START --> OL : menu action \ninvoked by user -OL --> OC : contains\nreference\nto -OC --> CD : contains\ncollection\ntitle -OC --> O : contains\nreference\nto -O --> OP : contains\nreference\nto -OP --> PD : contains\nreference\nto -PD --> END - -' references between TO classes -GRID o->"0.n" COL -COL o-> TOBJ : first element is required - -' object -together { - class "ObjectAggregator" as OBJAGR { - collectionMap - update() - handleGrid() - } - class "ObjectDM" as OBJDM { - layout - data: Exposer - readyToRender() - } - class "<<2nd level aggregator>>\nObjectLayout" as OBJLO { - grid - collectionLayout:Map - readyToRender() - } - OBJAGR --> OBJDM - OBJDM --> OBJLO -} -OBJLO --> GRID - -'collection -together { - class "CollectionAggregator" as COLAGR { - update() - } - class "CollectionDM" as COLDM { - layout - data[]: Exposer - readyToRender() - } - class "<<2nd level aggregator>>\nCollectionLayout" as COLLO { - numberOfColumns - columnDescriptions - objectPropertyList - propertyDescriptionList - readyToRender() - } - COLAGR --> COLDM - COLDM --> COLLO -} -OBJLO o-> COLLO -' references between Layout and TO classes -COLLO -> TOBJ -COLLO -> OPR -COLLO -> PRD - -note bottom of COLLO -the number of columns is to be set from object/TObject -for each attribute/property/column get object-property -for each object-property, get the property-description (friendlyName) -end note - - -note bottom of COLAGR -iterate over value[] -and add data to DisplayModel -end note - -OBJAGR o--> COLAGR ----- -Colors -TO -AGR -DM -LO diff --git a/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation_diagram.adoc b/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation_diagram.adoc new file mode 100644 index 0000000000..365fb2890b --- /dev/null +++ b/incubator/clients/kroviz/adoc/modules/kroviz/partials/design/collection_layout_aggregation_diagram.adoc @@ -0,0 +1,125 @@ +.Collection Layout Aggregation +[plantuml,file="layout_aggregation.png"] +---- +allowmixing + +() START +() END +together { + file "object-layout" <<BootStrap XML>> as OL #lightblue + class GridBs <<(T,tomato)TransferObject>> #lightgreen {} + OL . GridBs +} +together { + file "object-collection" <<JSON>> as OC #lightblue + class Collection <<(T,tomato)TransferObject>> #lightgreen { + id + memberType= Collection + value[] = data + } + 'Collection .. OC +} +together { + file "object" <<JSON>> as O #lightblue + class TObject <<(T,tomato)TransferObject>> #lightgreen { + members[] + } + TObject .. O +} +file "collection-description" <<JSON>> as CD #lightblue + +together { + file "object-property" <<JSON>> as OP #lightblue + class ObjectProperty <<(T,tomato)TransferObject>> #lightgreen { + disabledReason + } + OP .u. ObjectProperty +} +together { + file "property-description" <<JSON>> as PD #lightblue + class PropertyDescription <<(T,tomato)TransferObject>> #lightgreen { + extensions.friendlyName + } + PD .u. PropertyDescription +} + +' references between TransferObjects (xml/json) +START --> OL : menu action \ninvoked by user +OL --> OC : contains\nreference\nto +OC --> CD : contains\ncollection\ntitle +OC --> O : contains\nreference\nto +O --> OP : contains\nreference\nto +OP -> PD : contains\nreference\nto +PD --> END + +' references between TO classes +GridBs o-->"0.n" Collection +Collection o--> TObject : first\nelement\nis\nrequired + +' object +together { + class ObjectAggregator <<(A,orange)Aggregator>> #pink { + update() + handleGrid() + } + class ObjectDM <<(M,orange)DisplayModel>> #lightyellow { + layout + collectionDmMap + data: Exposer + readyToRender() + } + class ObjectLayout <<(L,orange)Layout>> #pink { + grid + readyToRender() + } + ObjectAggregator --> ObjectDM + ObjectDM --> ObjectLayout +} +ObjectAggregator ..> GridBs : handles + +'collection +together { + class CollectionAggregator <<(A, coral)Aggregator>> #pink { + update() + handleCollection() + isStandAloneCollection() + isParentedCollection() + } + class CollectionDM <<(M,coral)DisplayModel>> #lightyellow { + layout + data[]: Exposer + readyToRender() + } + class CollectionLayout <<(L,coral)Layout>> #pink{ + numberOfColumns + propertySpecificationMap + readyToRender() + } + CollectionAggregator --> CollectionDM + CollectionDM --> CollectionLayout +} +ObjectDM o-r-> CollectionDM + +' references between Layout and TO classes +CollectionLayout ..> TObject : handles +CollectionLayout ..> ObjectProperty : handles +CollectionLayout ..> PropertyDescription : handles + +note left of CollectionLayout #gold +* the number of columns +is to be set from object/TObject +* for each +attribute/property/column +get object-property +*for each object-property, +get the property-description +(friendlyName) +end note + +note right of CollectionAggregator #gold +iterate over value[] +and add data to DisplayModel +end note + + +---- diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/BaseAggregator.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/BaseAggregator.kt index 9d8a93be23..14eeb07def 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/BaseAggregator.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/aggregator/BaseAggregator.kt @@ -92,8 +92,6 @@ abstract class BaseAggregator { subType: String = Constants.subTypeJson, referrer: String, ) { - // console.log("[BA.invoke]") - // console.log("$link ${aggregator::class.simpleName} $referrer") ResourceProxy().fetch(link, aggregator, subType, referrer = referrer) } 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 3dd93f44ba..17aabcb0f7 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 @@ -25,7 +25,6 @@ import org.apache.causeway.client.kroviz.core.event.ResourceSpecification import org.apache.causeway.client.kroviz.core.model.CollectionDM import org.apache.causeway.client.kroviz.core.model.CollectionLayout import org.apache.causeway.client.kroviz.to.* -import org.apache.causeway.client.kroviz.to.bs.GridBs import org.apache.causeway.client.kroviz.ui.core.ViewManager /** sequence of operations: @@ -41,47 +40,57 @@ class CollectionAggregator(actionTitle: String, private val parent: ObjectAggreg displayModel = CollectionDM(actionTitle) } + var referrer = "" + override fun update(logEntry: LogEntry, subType: String?) { super.update(logEntry, subType) if (logEntry.state == EventState.DUPLICATE) { throw IllegalStateException("duplicates should not be propagated to handlers") //TODO this may not hold true for changed and deleted objects - object version required to deal with it? } else { - val referrer = logEntry.url + referrer = logEntry.url when (val obj = logEntry.getTransferObject()) { null -> log(logEntry) - is ResultList -> handleList(obj, referrer) - is TObject -> handleObject(obj, referrer) - is DomainType -> handleDomainType(obj, referrer) - is GridBs -> handleGrid(obj, referrer) - is Property -> handleProperty(obj, referrer) - is Collection -> handleCollection(obj, referrer) + is ResultList -> handleList(obj) + is TObject -> handleObject(obj) + is DomainType -> handleDomainType(obj) + //is GridBs -> Unit //In the case of CollectionDM, object-layout can be ignored + is Property -> handleProperty(obj) + is Collection -> handleCollection(obj) is Icon -> handleIcon(obj) else -> log(logEntry) } - if (parent == null) { - if (displayModel.readyToRender()) { + when { + isStandAloneCollection() && readyToRender() -> { ViewManager.openCollectionView(this) } - } else { - val le = LogEntry(ResourceSpecification("")) - // in case of a _parented_collection_ an empty LogEntry is passed on - parent.update(le, subType) + + isParentedCollection() -> { + // A LogEntry with an empty url is passed on to the parent AGGT + // in order to decide, if the whole tree is ready to be rendered. + val le = LogEntry(ResourceSpecification("")) + parent!!.update(le, subType) + } + + else -> Unit } } } - private fun handleGrid(grid: GridBs, referrer: String) { - val cdm = displayModel as CollectionDM - console.log("[CA.handleGrid] In the case of CollectionDM, object-layout can be ignored?") - console.log(grid) - console.log(cdm) - console.log(referrer) - //TODO("In the case of CollectionDM, object-layout can be ignored: " + vars) + private fun readyToRender(): Boolean { + return getDisplayModel().readyToRender() } - private fun handleList(resultList: ResultList, referrer: String) { + private fun getDisplayModel(): CollectionDM { + return displayModel as CollectionDM + } + + private fun getLayout(): CollectionLayout { + return getDisplayModel().layout as CollectionLayout + } + + private fun handleList(resultList: ResultList) { if (resultList.resulttype != ResultType.VOID.type) { val result = resultList.result!! result.value.forEach { @@ -90,28 +99,30 @@ class CollectionAggregator(actionTitle: String, private val parent: ObjectAggreg } } - private fun handleObject(obj: TObject, referrer: String) { + private fun handleObject(obj: TObject) { displayModel.addData(obj, this, referrer) + + getLayout().initColumns(obj) + if (isStandAloneCollection()) { invokeLayoutLink(obj, this, referrer = referrer) } invokeIconLink(obj, this, referrer = referrer) - // set the number of columns - val numberOfColumns = obj.getProperties().size - val cdm = displayModel as CollectionDM - val cl = cdm.layout as CollectionLayout - cl.numberOfColumns = numberOfColumns } private fun isStandAloneCollection(): Boolean { return parent == null } + private fun isParentedCollection(): Boolean { + return parent != null + } + private fun handleIcon(obj: TransferObject?) { - (displayModel as CollectionDM).addIcon(obj) + getDisplayModel().addIcon(obj) } - private fun handleDomainType(obj: DomainType, referrer: String) { + private fun handleDomainType(obj: DomainType) { obj.links.forEach { if (it.relation() == Relation.LAYOUT) { invoke(it, this, referrer = referrer) @@ -125,14 +136,19 @@ class CollectionAggregator(actionTitle: String, private val parent: ObjectAggreg } } - private fun handleProperty(property: Property, referrer: String) { - console.log("[CA.handleProperty]") - val dm = displayModel as CollectionDM - val layout = dm.layout!! - handleProperty(property, referrer, layout) + private fun handleProperty(property: Property) { + handleProperty(property, referrer, getLayout()) } - private fun handleCollection(collection: Collection, referrer: String) { + private fun handleCollection(collection: Collection) { + console.log("[CA_handleCollection]") + if (isParentedCollection()) { + val cdm = getDisplayModel() + cdm.id = collection.id + // add displayModel to parent.displayModel + val parentDM = parent!!.getDisplayModel() + parentDM.collectionModelList.add(cdm) + } collection.links.forEach { if (it.relation() == Relation.DESCRIBED_BY) { ResourceProxy().fetch(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 53b1bd1ca4..351aea89cf 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 @@ -37,8 +37,6 @@ import org.apache.causeway.client.kroviz.ui.dialog.ErrorDialog */ class ObjectAggregator(val actionTitle: String) : AggregatorWithLayout() { - private var collectionMap = mutableMapOf<String, CollectionAggregator>() - init { displayModel = ObjectDM(actionTitle) } @@ -58,7 +56,7 @@ class ObjectAggregator(val actionTitle: String) : AggregatorWithLayout() { } } - if (displayModel.readyToRender()) { + if (getDisplayModel().readyToRender()) { ViewManager.openObjectView(this) } } @@ -71,9 +69,6 @@ class ObjectAggregator(val actionTitle: String) : AggregatorWithLayout() { } else { displayModel.addData(obj, this, referrer) } - if (collectionMap.isEmpty()) { - handleCollections(obj, referrer) - } invokeLayoutLink(obj, this, referrer = referrer) } @@ -84,8 +79,16 @@ class ObjectAggregator(val actionTitle: String) : AggregatorWithLayout() { invoke(selfLink!!, this, referrer = referrer) } + fun getDisplayModel(): ObjectDM { + return displayModel as ObjectDM + } + + private fun getLayout(): ObjectLayout { + return getDisplayModel().layout as ObjectLayout + } + private fun handleResultObject(resultObject: ResultObject) { - (displayModel as ObjectDM).addResult(resultObject) + getDisplayModel().addResult(resultObject) } private fun handleResultValue(resultValue: ResultValue) { @@ -96,47 +99,19 @@ class ObjectAggregator(val actionTitle: String) : AggregatorWithLayout() { return displayModel.getObject() } - private fun handleCollections(obj: TObject, referrer: String) { - console.log("[OA_handleCollection] collections") - val collections = obj.getCollections() - console.log(collections) - collections.forEach { - val key = it.id - val aggregator = CollectionAggregator(key, this) - collectionMap[key] = aggregator - val link = it.links.first() - ResourceProxy().fetch(link, aggregator, referrer = referrer) - } - } - private fun handleProperty(property: Property, referrer: String) { - val dm = displayModel as ObjectDM - val layout = dm.layout!! - handleProperty(property, referrer, layout) + handleProperty(property, referrer, getLayout()) //FIXME } private fun handleGrid(grid: GridBs, referrer: String) { - val odm = displayModel as ObjectDM - val ol = odm.layout as ObjectLayout + val ol = getLayout() // for a yet unknown reason, handleGrid may be called twice, therefore we check if it's already set if (ol.grid == null) { - console.log("[OA_handleGrid]") ol.addGrid(grid, this, referrer = referrer) - val pl = grid.getPropertyList() - pl.forEach { + grid.getPropertyList().forEach { val link = it.link!! - // properties to be handled by ObjectAggregator ResourceProxy().fetch(link, this, subType = Constants.subTypeJson, referrer = referrer) } - val cl = grid.getCollectionList() - cl.forEach { - val href = it.linkList.first().href - console.log("CollectionBs") - console.log(href) - val l = Link(href = href) - // collections to be handled by ObjectAggregator - ResourceProxy().fetch(l, this, subType = Constants.subTypeJson, referrer = referrer) - } } } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/BaseLayout.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/BaseLayout.kt index 55d0856cdd..206ae67da1 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/BaseLayout.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/BaseLayout.kt @@ -25,13 +25,13 @@ import org.apache.causeway.client.kroviz.to.PropertyDescription abstract class BaseLayout { abstract fun addObjectProperty( - property: ObjectProperty, + objectProperty: ObjectProperty, aggregator: AggregatorWithLayout, referrer: String ) abstract fun addPropertyDescription( - property: PropertyDescription, + propertyDescription: PropertyDescription, aggregator: AggregatorWithLayout, referrer: String ) 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 45cb4f48f3..2f7aa90034 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 @@ -28,6 +28,7 @@ class CollectionDM(override val title: String) : DisplayModelWithLayout() { layout = CollectionLayout() } + var id = "" var data = observableListOf<Exposer>() private var rawData = observableListOf<TransferObject>() diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt index c2ab4612b3..2f69d7148e 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/CollectionLayout.kt @@ -22,6 +22,7 @@ import org.apache.causeway.client.kroviz.core.aggregator.AggregatorWithLayout import org.apache.causeway.client.kroviz.core.event.ResourceProxy import org.apache.causeway.client.kroviz.to.ObjectProperty import org.apache.causeway.client.kroviz.to.PropertyDescription +import org.apache.causeway.client.kroviz.to.TObject /** * For (parented) collections aggregate information for each column @@ -31,28 +32,51 @@ import org.apache.causeway.client.kroviz.to.PropertyDescription * - hidden : will the column be displayed or not */ class CollectionLayout : BaseLayout() { - var numberOfColumns = 0 - private val propertySpecificationMap = mutableMapOf<String, PropertySpecification>() - private val objectPropertyList = mutableListOf<ObjectProperty>() - private val propertyDescriptionList = mutableListOf<PropertyDescription>() + private var numberOfColumns = 0 + private val propertySpecificationList = mutableListOf<PropertySpecification>() override fun readyToRender(): Boolean { - console.log("[CL.readyToRender]") - console.log(this) - return (numberOfColumns > 0) && - (numberOfColumns == propertyDescriptionList.size) + console.log("[CL_readyToRender]") + console.log(propertySpecificationList.size) + val isReady = isInitialized() && allPropertySpecificationsAreCreated() + if (isReady) { + propertySpecificationList.forEach { + console.log(it) + } + } + return isReady } /** - * One element is to be added for each column. - * Duplicates are not allowed. + * 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 initColumns(obj: TObject) { + if (!isInitialized()) { + // members contain all properties, regardless if hidden, disabled, etc. + val members = obj.getProperties() + numberOfColumns = members.size + members.forEach { m -> + val ps = PropertySpecification(m) + propertySpecificationList.add(ps) + } + } + } + + fun isInitialized(): Boolean { + return numberOfColumns > 0 + } + + private fun allPropertySpecificationsAreCreated(): Boolean { + return (numberOfColumns == propertySpecificationList.size) + } + override fun addObjectProperty( objectProperty: ObjectProperty, aggregator: AggregatorWithLayout, referrer: String ) { - objectPropertyList.add(objectProperty) + console.log("[CL_addObjectProperty]") val l = objectProperty.getDescriptionLink()!! // FIXME NPE -> ISIS-2846 ? //invoking DN links leads to an error @@ -60,7 +84,6 @@ class CollectionLayout : BaseLayout() { if (!isDn) { ResourceProxy().fetch(l, aggregator, referrer = referrer) } - updatePropertySpecification(objectProperty) } override fun addPropertyDescription( @@ -68,32 +91,15 @@ class CollectionLayout : BaseLayout() { aggregator: AggregatorWithLayout, referrer: String ) { - console.log("[CL.addPropertyDescription]") - propertyDescriptionList.add(propertyDescription) - updatePropertySpecification(propertyDescription) - } - - private fun updatePropertySpecification(propertyDescription: PropertyDescription) { - val ps: PropertySpecification = findOrCreateFor(propertyDescription.id) - ps.addPropertyDescription(propertyDescription) - } - - private fun updatePropertySpecification(objectProperty: ObjectProperty) { - val ps: PropertySpecification = findOrCreateFor(objectProperty.id) - ps.addObjectProperty(objectProperty) - } - - private fun findOrCreateFor(id: String): PropertySpecification { - var ps = propertySpecificationMap[id] - if (ps == null) { - ps = PropertySpecification(id) - propertySpecificationMap[id] = ps - } - return ps + console.log("[CL_addPropertyDescription]") + val id = propertyDescription.id + val ps: PropertySpecification = propertySpecificationList.firstOrNull { it.id == id }!! + console.log(ps) + ps.amendWith(propertyDescription) } fun getColumnDescriptions(): List<PropertySpecification> { - return propertySpecificationMap.values.toList() + return propertySpecificationList } } \ 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 f4e67d73a0..b0bfb49362 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 @@ -31,7 +31,7 @@ class ObjectDM(override val title: String) : DisplayModelWithLayout() { layout = ObjectLayout() } - val collectionMap = mutableMapOf<String, CollectionDM>() + val collectionModelList = mutableListOf<CollectionDM>() var data: Exposer? = null private var dirty: Boolean = false @@ -43,7 +43,12 @@ class ObjectDM(override val title: String) : DisplayModelWithLayout() { TODO("Not yet implemented") } + fun getCollectionDisplayModelFor(id: String): CollectionDM { + return collectionModelList.find { it.id == id }!! + } + override fun readyToRender(): Boolean { + console.log("[ODM_readyToRender]") return when { data == null -> false isRendered -> false 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 9f8472a14a..f2e85ee268 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 @@ -19,10 +19,13 @@ package org.apache.causeway.client.kroviz.core.model import org.apache.causeway.client.kroviz.core.aggregator.AggregatorWithLayout +import org.apache.causeway.client.kroviz.core.aggregator.CollectionAggregator +import org.apache.causeway.client.kroviz.core.aggregator.ObjectAggregator import org.apache.causeway.client.kroviz.core.event.ResourceProxy import org.apache.causeway.client.kroviz.to.Link import org.apache.causeway.client.kroviz.to.ObjectProperty import org.apache.causeway.client.kroviz.to.PropertyDescription +import org.apache.causeway.client.kroviz.to.bs.CollectionBs import org.apache.causeway.client.kroviz.to.bs.GridBs import org.apache.causeway.client.kroviz.to.bs.RowBs @@ -33,59 +36,72 @@ class ObjectLayout : BaseLayout() { override fun readyToRender(): Boolean { console.log("[OL_readyToRender]") - return when (grid) { +// val o = js(arrayOf(collectionLayoutMap.values)) + console.log(collectionLayoutMap.keys) + var answer = when (grid) { null -> false else -> { var answer = true collectionLayoutMap.values.forEach { - console.log(it) - if (!it.readyToRender()) answer = false + if (!it.readyToRender()) { + answer = false + } } answer } } + return answer } override fun addObjectProperty( - property: ObjectProperty, + objectProperty: ObjectProperty, aggregator: AggregatorWithLayout, referrer: String ) { - TODO("Not yet implemented") + console.log("[OL_addObjectProperty]") +// TODO("Not yet implemented") } override fun addPropertyDescription( - property: PropertyDescription, + propertyDescription: PropertyDescription, aggregator: AggregatorWithLayout, referrer: String ) { - TODO("Not yet implemented") + console.log("[OL_addPropertyDescription]") +// TODO("Not yet implemented") } - fun addGrid(grid: GridBs, aggregator: AggregatorWithLayout?, referrer: String?) { + fun addGrid(grid: GridBs, aggregator: ObjectAggregator, referrer: String?) { this.grid = grid grid.rows.forEach { r -> - initRow(r, aggregator!!, referrer = referrer!!) + initRow(r, aggregator, referrer = referrer!!) } } - private fun initRow(r: RowBs, aggregator: AggregatorWithLayout, referrer: String) { + private fun initRow(r: RowBs, aggregator: ObjectAggregator, referrer: String) { r.colList.forEach { c -> - c.collectionList.forEach { col -> - collectionLayoutMap[col.id] = - CollectionLayout() // create empty entry for id - for later usage when response arrives - val href = col.linkList.first().href // we assume, linklist has always one element - val l = Link(href = href) - ResourceProxy().fetch(l, aggregator, referrer = referrer) + c.rowList.forEach { r2 -> + r2.colList.forEach { c2 -> + c2.collectionList.forEach { col -> + initCollection(col, aggregator, referrer) + } + } } c.tabGroupList.forEach { tg -> tg.tabList.forEach { t -> - t.rowList.forEach { r2 -> - initRow(r2, aggregator, referrer) + t.rowList.forEach { r3 -> + initRow(r3, aggregator, referrer) } } } } } + private fun initCollection(collection: CollectionBs, parent: ObjectAggregator, referrer: String) { + val href = collection.linkList.first().href // we assume, linklist has always one element + val l = Link(href = href) + val aggt = CollectionAggregator("", parent) + ResourceProxy().fetch(l, aggt, referrer = referrer) + } + } \ No newline at end of file diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertySpecification.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertySpecification.kt index 935a9a2d13..539d8fd979 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertySpecification.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/core/model/PropertySpecification.kt @@ -18,7 +18,7 @@ */ package org.apache.causeway.client.kroviz.core.model -import org.apache.causeway.client.kroviz.to.ObjectProperty +import org.apache.causeway.client.kroviz.to.Member import org.apache.causeway.client.kroviz.to.PropertyDescription /** @@ -31,37 +31,27 @@ import org.apache.causeway.client.kroviz.to.PropertyDescription * * All are required in order to be correctly displayed (in a table). */ -class PropertySpecification(val id: String) { - var name = "" // aka: columnName, named, label +class PropertySpecification(member: Member) { + var id = "" + var name = "" // aka: columnName, named, label, title var hidden = false - var disabledReason = "" + var disabled = false - fun addObjectProperty(op: ObjectProperty) {} - fun addPropertyDescription(pd: PropertyDescription) { + init { + id = member.id + name = member.id // can be changed later via property-description + hidden = false // can be changed later via ... + disabled = member.disabledReason.isNotEmpty() + } + + fun amendWith(pd: PropertyDescription) { + console.log("[PS_addPropertyDescription]") val ex = pd.extensions!! - name = ex.getFriendlyName() - if (name.isEmpty()) { - name = id - console.log(pd) + val fn = ex.getFriendlyName() + if (fn.isNotEmpty()) { + name = fn } + console.log(this) } - //FIXME use setter Methods using: - /** Property - *ObjectProperty - PropertyDescription */ - /*init { - id = grid.id - when { - grid.named.isNotEmpty() -> columnName = grid.named - else -> columnName = id - } - // console.log("[CD.init]") - when { - // grid.hidden can be null -- intellij inference is wrong - (grid.hidden == null) || grid.hidden.isEmpty() -> {} - grid.hidden.contains("TABLE") -> hidden = true - } - // console.log("$id $columnName Hidden: $hidden") - } */ } \ No newline at end of file diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/builder/ColBuilder.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/builder/ColBuilder.kt index 6ee6430970..6db3b9f247 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/builder/ColBuilder.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/builder/ColBuilder.kt @@ -65,16 +65,14 @@ class ColBuilder : UiBuilder() { val rowCpt = RowBuilder().create(row, tObject, dsp) panel.add(rowCpt) } - for (c in col.collectionList) { - val key = c.id // entities + col.collectionList.forEach { + val id = it.id val objectDM = dsp.displayModel - val collectionDM = objectDM.collectionMap[key] - if (collectionDM != null) { - val tblCpt = RoTable(collectionDM) - val fsPanel = FieldsetPanel(legend = StringUtils.capitalize(key)).add(tblCpt) - panel.add(fsPanel) - collectionDM.isRendered = true - } + val cdm = objectDM.getCollectionDisplayModelFor(id) + val tblCpt = RoTable(cdm) + val fsPanel = FieldsetPanel(legend = StringUtils.capitalize(cdm.title)).add(tblCpt) + panel.add(fsPanel) + cdm.isRendered = true } return panel } 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 4b8bc9eb3a..398d1bb8a8 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 @@ -42,10 +42,12 @@ class ColumnFactory { } fun buildColumns(displayCollection: CollectionDM): List<ColumnDefinition<dynamic>> { + console.log("[CF_buildColumns]") val columns = mutableListOf<ColumnDefinition<Exposer>>() addColumnForObjectIcon(displayCollection, columns) addColumnsForProperties(displayCollection, columns) columns.add(columnForObjectMenu()) + console.log(columns) return columns } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ViewManager.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ViewManager.kt index 3ce091643e..457fe0ae00 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ViewManager.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/causeway/client/kroviz/ui/core/ViewManager.kt @@ -173,7 +173,9 @@ object ViewManager { } fun openObjectView(aggregator: ObjectAggregator) { + console.log("[VM_openObjectView]") val dm = aggregator.displayModel as ObjectDM + console.log(dm) var title: String = StringUtils.extractTitle(dm.title) if (title.isEmpty()) { title = aggregator.actionTitle diff --git a/incubator/clients/kroviz/src/test/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregatorTest.kt b/incubator/clients/kroviz/src/test/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregatorTest.kt index 9e201b791e..a7af7d948e 100644 --- a/incubator/clients/kroviz/src/test/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregatorTest.kt +++ b/incubator/clients/kroviz/src/test/kotlin/org/apache/causeway/client/kroviz/core/aggregator/CollectionAggregatorTest.kt @@ -74,7 +74,7 @@ class CollectionAggregatorTest : IntegrationTest() { val expected = "ResultListResult class" // assertEquals(expected, lbl) // 6 val vars = "$property , $cdm, $expected" - console.log(vars) +// console.log(vars) } }
