From 93febc403d04182d1e1f14f0f51d08131dc886e3 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Tue, 16 Apr 2024 11:10:15 +0200 Subject: [PATCH] fix(core): entities core members are not processed in batch operations (#1134) --- .../com/egm/stellio/search/service/EntityOperationService.kt | 4 ++-- .../egm/stellio/search/service/EntityPayloadServiceTests.kt | 2 +- .../kotlin/com/egm/stellio/shared/model/ExpandedEntity.kt | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/search-service/src/main/kotlin/com/egm/stellio/search/service/EntityOperationService.kt b/search-service/src/main/kotlin/com/egm/stellio/search/service/EntityOperationService.kt index baedc1590..2b8e3301e 100644 --- a/search-service/src/main/kotlin/com/egm/stellio/search/service/EntityOperationService.kt +++ b/search-service/src/main/kotlin/com/egm/stellio/search/service/EntityOperationService.kt @@ -205,7 +205,7 @@ class EntityOperationService( temporalEntityAttributeService.deleteTemporalAttributesOfEntity(ngsiLdEntity.id).bind() val updateResult = entityPayloadService.appendAttributes( ngsiLdEntity.id, - jsonLdEntity.getAttributes(), + jsonLdEntity.getModifiableMembers(), disallowOverwrite, sub ).bind() @@ -233,7 +233,7 @@ class EntityOperationService( val (jsonLdEntity, ngsiLdEntity) = entity val updateResult = entityPayloadService.appendAttributes( ngsiLdEntity.id, - jsonLdEntity.getAttributes(), + jsonLdEntity.getModifiableMembers(), disallowOverwrite, sub ).bind() diff --git a/search-service/src/test/kotlin/com/egm/stellio/search/service/EntityPayloadServiceTests.kt b/search-service/src/test/kotlin/com/egm/stellio/search/service/EntityPayloadServiceTests.kt index 0264dc0bd..06e436bab 100644 --- a/search-service/src/test/kotlin/com/egm/stellio/search/service/EntityPayloadServiceTests.kt +++ b/search-service/src/test/kotlin/com/egm/stellio/search/service/EntityPayloadServiceTests.kt @@ -219,7 +219,7 @@ class EntityPayloadServiceTests : WithTimescaleContainer, WithKafkaContainer { entityPayloadService.mergeEntity( beehiveTestCId, - jsonLdEntity.getAttributes(), + jsonLdEntity.getModifiableMembers(), now, "0123456789-1234-5678-987654321" ).shouldSucceed() diff --git a/shared/src/main/kotlin/com/egm/stellio/shared/model/ExpandedEntity.kt b/shared/src/main/kotlin/com/egm/stellio/shared/model/ExpandedEntity.kt index 9c699bf1b..0893f678e 100644 --- a/shared/src/main/kotlin/com/egm/stellio/shared/model/ExpandedEntity.kt +++ b/shared/src/main/kotlin/com/egm/stellio/shared/model/ExpandedEntity.kt @@ -4,6 +4,7 @@ import arrow.core.Either import arrow.core.left import arrow.core.right import com.egm.stellio.shared.util.JsonLdUtils +import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_CONTEXT import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_EXPANDED_ENTITY_CORE_MEMBERS import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_ID import com.egm.stellio.shared.util.JsonLdUtils.JSONLD_TYPE @@ -28,6 +29,10 @@ data class ExpandedEntity( members.filter { !JSONLD_EXPANDED_ENTITY_CORE_MEMBERS.contains(it.key) } .mapValues { castAttributeValue(it.value) } + fun getModifiableMembers(): ExpandedAttributes = + members.filter { !listOf(JSONLD_ID, JSONLD_CONTEXT).contains(it.key) } + .mapValues { castAttributeValue(it.value) } + fun getScopes(): List? = (members as Map>).getScopes()