From c6eb26107d672cc8291991d6aa8d133d07bb821a Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Tue, 9 Jan 2024 10:57:08 +0100 Subject: [PATCH] fix(temporal): do not restore geo-properties in temporal or aggregated representation --- .../kotlin/com/egm/stellio/shared/util/JsonLdUtils.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shared/src/main/kotlin/com/egm/stellio/shared/util/JsonLdUtils.kt b/shared/src/main/kotlin/com/egm/stellio/shared/util/JsonLdUtils.kt index 5e951b035a..c548ba70c2 100644 --- a/shared/src/main/kotlin/com/egm/stellio/shared/util/JsonLdUtils.kt +++ b/shared/src/main/kotlin/com/egm/stellio/shared/util/JsonLdUtils.kt @@ -250,7 +250,8 @@ object JsonLdUtils { when (it.value) { is Map<*, *> -> { val geoValues = it.value as MutableMap - if (geoValues.isNotEmpty()) { + // in case of an aggregated or temporalValues query, there is no "value" member + if (geoValues.isNotEmpty() && geoValues.containsKey(JSONLD_VALUE_TERM)) { geoValues[JSONLD_VALUE_TERM] = wktToGeoJson(geoValues[JSONLD_VALUE_TERM] as String) geoValues } else geoValues @@ -259,8 +260,11 @@ object JsonLdUtils { is List<*> -> (it.value as List>).map { geoInstance -> val geoValues = geoInstance.toMutableMap() - geoValues[JSONLD_VALUE_TERM] = wktToGeoJson(geoValues[JSONLD_VALUE_TERM] as String) - geoValues + // in case of an aggregated or temporalValues query, there is no "value" member + if (geoValues.containsKey(JSONLD_VALUE_TERM)) { + geoValues[JSONLD_VALUE_TERM] = wktToGeoJson(geoValues[JSONLD_VALUE_TERM] as String) + geoValues + } else geoValues } else -> it.value }