Call EntityManager to remove resource links. Rename getter.

This commit is contained in:
Luke deGruchy 2024-02-06 11:20:33 -05:00
parent 8283e46da1
commit 1b5b281ee3
4 changed files with 13 additions and 4 deletions

View File

@ -1245,6 +1245,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
*/ */
if (thePerformIndexing) { if (thePerformIndexing) {
if (newParams == null) { if (newParams == null) {
// myExpungeService.deleteAllSearchParams(JpaPid.fromId(entity.getId()));
removeSearchParams(entity); removeSearchParams(entity);
entity.clearAllParamsPopulated(); entity.clearAllParamsPopulated();
} else { } else {
@ -1296,8 +1297,16 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
theEntity.getParamsQuantity().forEach(myEntityManager::remove); theEntity.getParamsQuantity().forEach(myEntityManager::remove);
theEntity.getParamsQuantityNormalized().forEach(myEntityManager::remove); theEntity.getParamsQuantityNormalized().forEach(myEntityManager::remove);
theEntity.getParamsString().forEach(myEntityManager::remove); theEntity.getParamsString().forEach(myEntityManager::remove);
theEntity.getParamsComboStringUnique().forEach(myEntityManager::remove);
theEntity.getParamsToken().forEach(myEntityManager::remove); theEntity.getParamsToken().forEach(myEntityManager::remove);
theEntity.getParamsUri().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);
// }
} }
/** /**

View File

@ -519,7 +519,7 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
return myParamsComboStringUnique; return myParamsComboStringUnique;
} }
public Collection<ResourceIndexedComboTokenNonUnique> getmyParamsComboTokensNonUnique() { public Collection<ResourceIndexedComboTokenNonUnique> getParamsComboTokensNonUnique() {
if (myParamsComboTokensNonUnique == null) { if (myParamsComboTokensNonUnique == null) {
myParamsComboTokensNonUnique = new ArrayList<>(); myParamsComboTokensNonUnique = new ArrayList<>();
} }

View File

@ -137,7 +137,7 @@ public final class ResourceIndexedSearchParams {
myComboStringUniques.addAll(theEntity.getParamsComboStringUnique()); myComboStringUniques.addAll(theEntity.getParamsComboStringUnique());
} }
if (theEntity.isParamsComboTokensNonUniquePresent()) { if (theEntity.isParamsComboTokensNonUniquePresent()) {
myComboTokenNonUnique.addAll(theEntity.getmyParamsComboTokensNonUnique()); myComboTokenNonUnique.addAll(theEntity.getParamsComboTokensNonUnique());
} }
} }

View File

@ -158,8 +158,8 @@ public class DuplicateIndexR5Test extends BaseJpaR5Test {
runInTransaction(()->{ runInTransaction(()->{
assertEquals(5, myResourceTableDao.count()); assertEquals(5, myResourceTableDao.count());
ResourceTable table = myResourceTableDao.findAll().stream().filter(t1 -> t1.getResourceType().equals("Patient")).findFirst().orElseThrow(); ResourceTable table = myResourceTableDao.findAll().stream().filter(t1 -> t1.getResourceType().equals("Patient")).findFirst().orElseThrow();
assertEquals(1, table.getmyParamsComboTokensNonUnique().size()); assertEquals(1, table.getParamsComboTokensNonUnique().size());
ResourceIndexedComboTokenNonUnique param = table.getmyParamsComboTokensNonUnique().iterator().next(); ResourceIndexedComboTokenNonUnique param = table.getParamsComboTokensNonUnique().iterator().next();
// Create a dupe // Create a dupe
ResourceIndexedComboTokenNonUnique dupe0 = new ResourceIndexedComboTokenNonUnique(); ResourceIndexedComboTokenNonUnique dupe0 = new ResourceIndexedComboTokenNonUnique();