From 9cd44831f95354ead7f65936e8f71e12d687208d Mon Sep 17 00:00:00 2001 From: GeorgCantor Date: Sat, 28 Sep 2024 21:50:05 +0300 Subject: [PATCH 1/3] Update PatchOrdering.kt --- .../fhir/sync/upload/patch/PatchOrdering.kt | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt index d0bfb5f364..37350e6a6f 100644 --- a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt +++ b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt @@ -126,21 +126,12 @@ internal object PatchOrdering { private fun PatchMapping.findOutgoingReferences( localChangeIdToReferenceMap: Map>, ): Set { + if (generatedPatch.type == Patch.Type.DELETE) return emptySet() val references = mutableSetOf() - when (generatedPatch.type) { - Patch.Type.INSERT, - Patch.Type.UPDATE, -> { - localChanges.forEach { localChange -> - localChange.token.ids.forEach { id -> - localChangeIdToReferenceMap[id]?.let { - references.addAll(it.map { it.resourceReferenceValue }) - } - } - } - } - Patch.Type.DELETE -> { - // do nothing - } + localChanges.forEach { localChange -> + localChange.token.ids.flatMap { id -> + localChangeIdToReferenceMap[id]?.map { it.resourceReferenceValue } ?: emptyList() + }.let { references.addAll(it) } } return references } From 5ce034b019726a75a0e711cd95f0f95a87fba0fa Mon Sep 17 00:00:00 2001 From: GeorgCantor Date: Tue, 1 Oct 2024 18:28:29 +0300 Subject: [PATCH 2/3] Update engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt Co-authored-by: Jing Tang --- .../google/android/fhir/sync/upload/patch/PatchOrdering.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt index 37350e6a6f..d04c3acea0 100644 --- a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt +++ b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt @@ -129,9 +129,11 @@ internal object PatchOrdering { if (generatedPatch.type == Patch.Type.DELETE) return emptySet() val references = mutableSetOf() localChanges.forEach { localChange -> - localChange.token.ids.flatMap { id -> + references.addAll( + localChange.token.ids.flatMap { id -> localChangeIdToReferenceMap[id]?.map { it.resourceReferenceValue } ?: emptyList() - }.let { references.addAll(it) } + } + ) } return references } From 17fe3e348241b2d403f50265093fb3fcac2db74e Mon Sep 17 00:00:00 2001 From: GeorgCantor Date: Tue, 1 Oct 2024 18:34:10 +0300 Subject: [PATCH 3/3] Update PatchOrdering.kt --- .../fhir/sync/upload/patch/PatchOrdering.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt index d04c3acea0..c03b1cb1be 100644 --- a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt +++ b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchOrdering.kt @@ -126,14 +126,21 @@ internal object PatchOrdering { private fun PatchMapping.findOutgoingReferences( localChangeIdToReferenceMap: Map>, ): Set { - if (generatedPatch.type == Patch.Type.DELETE) return emptySet() val references = mutableSetOf() - localChanges.forEach { localChange -> - references.addAll( - localChange.token.ids.flatMap { id -> - localChangeIdToReferenceMap[id]?.map { it.resourceReferenceValue } ?: emptyList() - } - ) + when (generatedPatch.type) { + Patch.Type.INSERT, + Patch.Type.UPDATE, -> { + localChanges.forEach { localChange -> + references.addAll( + localChange.token.ids.flatMap { id -> + localChangeIdToReferenceMap[id]?.map { it.resourceReferenceValue } ?: emptyList() + } + ) + } + } + Patch.Type.DELETE -> { + // do nothing + } } return references }