From 22730f9984c3cf4ebf64888dc6ec9e424f079dae Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Fri, 7 May 2021 11:07:27 +0200 Subject: [PATCH] fix: force attributes compaction before being extracted #393 --- .../kotlin/com/egm/stellio/shared/util/JsonLdUtils.kt | 8 +++++--- 1 file changed, 5 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 0c8305221..af89a97a8 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 @@ -525,8 +525,10 @@ fun extractAttributeInstanceFromCompactedEntity( attributeName: String, datasetId: URI? ): CompactedJsonLdAttribute { - return if (compactedJsonLdEntity[attributeName] is List<*>) { - val attributePayload = compactedJsonLdEntity[attributeName] as List + // Since some attributes cannot be well compacted, to be improved later + val compactedAttributeName = attributeName.extractShortTypeFromExpanded() + return if (compactedJsonLdEntity[compactedAttributeName] is List<*>) { + val attributePayload = compactedJsonLdEntity[compactedAttributeName] as List attributePayload.first { it["datasetId"] as String? == datasetId?.toString() } - } else compactedJsonLdEntity[attributeName]!! as CompactedJsonLdAttribute + } else compactedJsonLdEntity[compactedAttributeName]!! as CompactedJsonLdAttribute }