From 1b5b281ee3616c4bc76f0ded339064fad031b527 Mon Sep 17 00:00:00 2001 From: Luke deGruchy Date: Tue, 6 Feb 2024 11:20:33 -0500 Subject: [PATCH] Call EntityManager to remove resource links. Rename getter. --- .../main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java | 9 +++++++++ .../java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java | 2 +- .../extractor/ResourceIndexedSearchParams.java | 2 +- .../ca/uhn/fhir/jpa/dao/r5/DuplicateIndexR5Test.java | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java index 017fe65c314..b336a8405f5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java @@ -1245,6 +1245,7 @@ public abstract class BaseHapiFhirDao extends BaseStora */ if (thePerformIndexing) { if (newParams == null) { + // myExpungeService.deleteAllSearchParams(JpaPid.fromId(entity.getId())); removeSearchParams(entity); entity.clearAllParamsPopulated(); } else { @@ -1296,8 +1297,16 @@ public abstract class BaseHapiFhirDao extends BaseStora theEntity.getParamsQuantity().forEach(myEntityManager::remove); theEntity.getParamsQuantityNormalized().forEach(myEntityManager::remove); theEntity.getParamsString().forEach(myEntityManager::remove); + theEntity.getParamsComboStringUnique().forEach(myEntityManager::remove); theEntity.getParamsToken().forEach(myEntityManager::remove); theEntity.getParamsUri().forEach(myEntityManager::remove); + theEntity.getParamsComboTokensNonUnique().forEach(myEntityManager::remove); + theEntity.getResourceLinks().forEach(myEntityManager::remove); + + // LUKETODO: + // if (myStorageSettings.getIndexMissingFields() == JpaStorageSettings.IndexEnabledEnum.ENABLED) { + // mySearchParamPresentDao.deleteByResourceId(theResourceLongId); + // } } /** diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java index 4aad4fa503a..957ac60415a 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java @@ -519,7 +519,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas return myParamsComboStringUnique; } - public Collection getmyParamsComboTokensNonUnique() { + public Collection getParamsComboTokensNonUnique() { if (myParamsComboTokensNonUnique == null) { myParamsComboTokensNonUnique = new ArrayList<>(); } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ResourceIndexedSearchParams.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ResourceIndexedSearchParams.java index f1cabaf294d..19014d27796 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ResourceIndexedSearchParams.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ResourceIndexedSearchParams.java @@ -137,7 +137,7 @@ public final class ResourceIndexedSearchParams { myComboStringUniques.addAll(theEntity.getParamsComboStringUnique()); } if (theEntity.isParamsComboTokensNonUniquePresent()) { - myComboTokenNonUnique.addAll(theEntity.getmyParamsComboTokensNonUnique()); + myComboTokenNonUnique.addAll(theEntity.getParamsComboTokensNonUnique()); } } diff --git a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/dao/r5/DuplicateIndexR5Test.java b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/dao/r5/DuplicateIndexR5Test.java index 5ff8ec1c6f3..f5dfb0fccba 100644 --- a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/dao/r5/DuplicateIndexR5Test.java +++ b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/dao/r5/DuplicateIndexR5Test.java @@ -158,8 +158,8 @@ public class DuplicateIndexR5Test extends BaseJpaR5Test { runInTransaction(()->{ assertEquals(5, myResourceTableDao.count()); ResourceTable table = myResourceTableDao.findAll().stream().filter(t1 -> t1.getResourceType().equals("Patient")).findFirst().orElseThrow(); - assertEquals(1, table.getmyParamsComboTokensNonUnique().size()); - ResourceIndexedComboTokenNonUnique param = table.getmyParamsComboTokensNonUnique().iterator().next(); + assertEquals(1, table.getParamsComboTokensNonUnique().size()); + ResourceIndexedComboTokenNonUnique param = table.getParamsComboTokensNonUnique().iterator().next(); // Create a dupe ResourceIndexedComboTokenNonUnique dupe0 = new ResourceIndexedComboTokenNonUnique();