Skip to content

Commit

Permalink
#42 Combine XML (Grid) and JSON based Layout in DisplayList/Object 9/n.
Browse files Browse the repository at this point in the history
SimpleObject list with DN properties rendered (again)
  • Loading branch information
joerg-rade committed Mar 17, 2020
1 parent 12d40be commit f406395
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
20 changes: 12 additions & 8 deletions src/main/kotlin/org/ro/core/aggregator/ListAggregator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ListAggregator(actionTitle: String) : BaseAggregator() {

override fun update(logEntry: LogEntry, subType: String) {

//TODO duplicates should be caught earlier IMPROVE
//TODO duplicates should no be propagated to handlers at all: IMPROVE
if (logEntry.state != EventState.DUPLICATE) {
when (val obj = logEntry.getTransferObject()) {
null -> log(logEntry)
Expand All @@ -49,12 +49,11 @@ class ListAggregator(actionTitle: String) : BaseAggregator() {
}

private fun handleObject(obj: TObject) {
console.log("[LA.handleObject]")
dsp.addData(obj)
val l = obj.getLayoutLink()!!
// Json.Layout is invoked first
l.invokeWith(this)
// then Xml.Layout is to be called as well
// then Xml.Layout is to be invoked as well
l.invokeWith(this, "xml")
}

Expand All @@ -64,11 +63,16 @@ class ListAggregator(actionTitle: String) : BaseAggregator() {
// Eventually due to parallel invocations - only once required -> IMPROVE
if (dspl.layout == null) {
dspl.addLayout(layout)
}
dspl.propertyLayoutList.forEach { p ->
val l = p.link!!
if (!l.href.contains("datanucleus")) { //invoking DN links lead to an error
l.invokeWith(this)
dspl.propertyLayoutList.forEach { p ->
val l = p.link!!
val isDn = l.href.contains("datanucleus")
if (isDn) {
//invoking DN links leads to an error
val id = p.id!!
dspl.addPropertyDescription(id, id)
} else {
l.invokeWith(this)
}
}
}
}
Expand Down
19 changes: 7 additions & 12 deletions src/main/kotlin/org/ro/core/model/ListDM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,17 @@ class ListDM(override val title: String) : DisplayModel() {
layout == null -> return false
grid == null -> return false
else -> {
val ps = propertyList.size
val pls = propertyLayoutList.size
val pds = propertyDescriptionList.size
val descriptionsComplete = ps >= pls
if (descriptionsComplete) {
console.log("[ListDM.canBeDisplayed] properties: $ps")
console.log("[ListDM.canBeDisplayed] propertyLayout: $pls")
console.log("[ListDM.canBeDisplayed] propertyDescriptions: $pds")
}
return descriptionsComplete //&& propertiesComplete
val descriptionsComplete = pds >= pls
return descriptionsComplete
}
}
}

fun addLayout(layout: Layout) {
this.layout = layout
initPropertyLayoutList(layout)
console.log("[ListDM.addLayout] propertyLayoutList: ${propertyLayoutList.size}")
}

private fun initPropertyLayoutList(layout: Layout) {
Expand Down Expand Up @@ -72,15 +65,17 @@ class ListDM(override val title: String) : DisplayModel() {
}

fun addPropertyDescription(p: Property) {
console.log("[DL.addPropertyDescription]")
val id = p.id
val e: Extensions = p.extensions!!
val friendlyName = e.friendlyName
propertyDescriptionList.put(id, friendlyName)
addPropertyDescription(id, friendlyName)
}

fun addPropertyDescription(key: String, value: String) {
propertyDescriptionList.put(key, value)
}

fun addProperty(property: Property) {
// console.log("[DL.addProperty]")
propertyList.add(property)
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/org/ro/to/Link.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ data class Link(val rel: String = "",
}

fun isProperty() : Boolean {
return rel.endsWith("/property")
return type.endsWith("/object-property")
}

fun isPropertyDescription() : Boolean {
return type.endsWith("/property-description")
}

fun isAction() : Boolean {
Expand Down

0 comments on commit f406395

Please sign in to comment.