Commit 700dacec authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Fix issue where elements beyond number three were not added properly.

parent c3b58fa8
Pipeline #21411 passed with stages
in 4 minutes and 17 seconds
...@@ -165,17 +165,17 @@ class SAXContentHandler( ...@@ -165,17 +165,17 @@ class SAXContentHandler(
} }
if (innerElements.isEmpty()) { if (innerElements.isEmpty()) {
if (currentElementContent.isNotEmpty()) { if (currentElementContent.isNotEmpty()) {
when (val item = jsonResult[currentElementTag]){ when (val item = jsonResult[currentElementTag]) {
null -> jsonResult[currentElementTag] = currentElementContent null -> jsonResult[currentElementTag] = currentElementContent
is JsonArray<*> -> jsonResult[currentElementTag] = item + currentElementContent is List<*> -> jsonResult[currentElementTag] = item + listOf(currentElementContent)
else -> jsonResult[currentElementTag] = JsonArray(item, currentElementContent) else -> jsonResult[currentElementTag] = listOf(item, currentElementContent)
} }
} }
} else { } else {
when (val item = jsonResult[currentElementTag]) { when (val item = jsonResult[currentElementTag]) {
null -> jsonResult[currentElementTag] = innerElements.toMap() null -> jsonResult[currentElementTag] = innerElements.toMap()
is JsonArray<*> -> jsonResult[currentElementTag] = item + innerElements.toMap() is List<*> -> jsonResult[currentElementTag] = item + listOf(innerElements.toMap())
else -> jsonResult[currentElementTag] = JsonArray(item, innerElements.toMap()) else -> jsonResult[currentElementTag] = listOf(item, innerElements.toMap())
} }
innerElements.clear() innerElements.clear()
} }
......
...@@ -39,7 +39,6 @@ class LocalTestRun { ...@@ -39,7 +39,6 @@ class LocalTestRun {
"identifierMain", "identifierMain",
0, 0, 0, 0 0, 0, 0, 0
) )
@Test @Test
@Disabled @Disabled
fun `test single item`() { fun `test single item`() {
...@@ -47,9 +46,8 @@ class LocalTestRun { ...@@ -47,9 +46,8 @@ class LocalTestRun {
val transformFile = "/config/transform.xslt" val transformFile = "/config/transform.xslt"
val xslt = File(folder + transformFile).readBytes() val xslt = File(folder + transformFile).readBytes()
val transformer = XMLTransformer() val transformer = XMLTransformer()
val input = val input =
"{\"format\" : \"XML\", \"path\" : \"/home/jonas/memobase/data/snp-001/info%3Afedora%2Fmemobase%3AFonoteca-18BD1047%5FA29.xml\"}" "{\"format\" : \"XML\", \"path\" : \"/home/jonas/memobase/data/snp-001/info%3Afedora%2Fmemobase%3AFonoteca-18BD1012%5FB3.xml\"}"
val message = Message.fromJson(input)[0] val message = Message.fromJson(input)[0]
val items = transformer.applyXSLT( val items = transformer.applyXSLT(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment