Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): entities core members are not processed in batch operations #1134

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class EntityOperationService(
temporalEntityAttributeService.deleteTemporalAttributesOfEntity(ngsiLdEntity.id).bind()
val updateResult = entityPayloadService.appendAttributes(
ngsiLdEntity.id,
jsonLdEntity.getAttributes(),
jsonLdEntity.getModifiableMembers(),
disallowOverwrite,
sub
).bind()
Expand Down Expand Up @@ -233,7 +233,7 @@ class EntityOperationService(
val (jsonLdEntity, ngsiLdEntity) = entity
val updateResult = entityPayloadService.appendAttributes(
ngsiLdEntity.id,
jsonLdEntity.getAttributes(),
jsonLdEntity.getModifiableMembers(),
disallowOverwrite,
sub
).bind()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class EntityPayloadServiceTests : WithTimescaleContainer, WithKafkaContainer {

entityPayloadService.mergeEntity(
beehiveTestCId,
jsonLdEntity.getAttributes(),
jsonLdEntity.getModifiableMembers(),
now,
"0123456789-1234-5678-987654321"
).shouldSucceed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<String>? =
(members as Map<String, List<Any>>).getScopes()

Expand Down
Loading