From 672ce1f98ded97a5169485b89601e4494a24f1f0 Mon Sep 17 00:00:00 2001 From: Tadgh Date: Wed, 18 Dec 2024 07:30:19 -0800 Subject: [PATCH] wip --- .../java/ca/uhn/fhir/jpa/dao/data/IResourceTableDao.java | 2 ++ .../ca/uhn/fhir/jpa/partition/RequestPartitionHelperSvc.java | 1 + .../builder/predicate/BaseJoiningPredicateBuilder.java | 1 + .../jpa/mdm/provider/MdmProviderCrossPartitionR4Test.java | 1 + .../fhir/jpa/partition/RequestPartitionHelperSvcTest.java | 5 +++-- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceTableDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceTableDao.java index de5363765997..5c9f1dbeba7d 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceTableDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceTableDao.java @@ -68,6 +68,7 @@ Slice findIdsOfResourcesWithinUpdatedRangeOrderedFromNewest( Slice findIdsOfResourcesWithinUpdatedRangeOrderedFromOldest( Pageable thePage, @Param("low") Date theLow, @Param("high") Date theHigh); + //TODO A :Look at below TODO B, and note that these 2 queries are identical. @Query( "SELECT t.myPid, t.myResourceType, t.myUpdated FROM ResourceTable t WHERE t.myUpdated >= :low AND t.myUpdated <= :high ORDER BY t.myUpdated ASC") Stream streamIdsTypesAndUpdateTimesOfResourcesWithinUpdatedRangeOrderedFromOldest( @@ -80,6 +81,7 @@ Stream streamIdsTypesAndUpdateTimesOfResourcesWithinUpdatedRangeOrdere @Param("high") Date theHigh, @Param("partition_ids") List theRequestPartitionIds); + //TODO B: look at this query. This is not a default partition query, this is an all partitions query. @Query( "SELECT t.myPid, t.myResourceType, t.myUpdated FROM ResourceTable t WHERE t.myUpdated >= :low AND t.myUpdated <= :high ORDER BY t.myUpdated ASC") Stream streamIdsTypesAndUpdateTimesOfResourcesWithinUpdatedRangeOrderedFromOldestForDefaultPartition( diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperSvc.java index b757e99cd98f..8faa76161b35 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperSvc.java @@ -42,6 +42,7 @@ public class RequestPartitionHelperSvc extends BaseRequestPartitionHelperSvc { public RequestPartitionHelperSvc() {} + //TODO C: Looks like this code here corrects the null partition and converts it into the actual default partition, but is this called everywhere? @Override public RequestPartitionId validateAndNormalizePartitionIds(RequestPartitionId theRequestPartitionId) { List names = null; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/BaseJoiningPredicateBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/BaseJoiningPredicateBuilder.java index efbe336ce13f..2748bb2d10c5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/BaseJoiningPredicateBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/BaseJoiningPredicateBuilder.java @@ -111,6 +111,7 @@ public Condition createPredicateResourceIds(boolean theInverse, Collection replaceDefaultPartitionIdIfNonNull( PartitionSettings thePartitionSettings, List thePartitionIds) { List partitionIds = thePartitionIds; diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderCrossPartitionR4Test.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderCrossPartitionR4Test.java index c1b2fd04d484..59cc0ac47e10 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderCrossPartitionR4Test.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderCrossPartitionR4Test.java @@ -33,6 +33,7 @@ public void before() throws Exception { super.before(); myPartitionSettings.setPartitioningEnabled(true); + myPartitionSettings.setDefaultPartitionId(0); //TODO Note this change myPartitionLookupSvc.createPartition(new PartitionEntity().setId(1).setName(PARTITION_1), null); myPartitionLookupSvc.createPartition(new PartitionEntity().setId(2).setName(PARTITION_2), null); myPartitionLookupSvc.createPartition(new PartitionEntity().setId(3).setName(PARTITION_GOLDEN_RESOURCE), null); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperSvcTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperSvcTest.java index 4775c50cf512..e7d953869465 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperSvcTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperSvcTest.java @@ -7,11 +7,9 @@ import ca.uhn.fhir.jpa.test.BaseJpaR4Test; import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.r4.model.ConceptMap; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.Patient; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; @@ -37,6 +35,8 @@ class RequestPartitionHelperSvcTest extends BaseJpaR4Test { static final int UNKNOWN_PARTITION_ID = 1_000_000; static final String UNKNOWN_PARTITION_NAME = "UNKNOWN"; +// static final int CUSTOM_DEFAULT_PARTITION_ID = 666; + @Autowired IPartitionDao myPartitionDao; @Autowired @@ -49,6 +49,7 @@ class RequestPartitionHelperSvcTest extends BaseJpaR4Test { @BeforeEach public void before(){ myPartitionDao.deleteAll(); + myPartitionSettings.setDefaultPartitionId(null); myPartitionSettings.setPartitioningEnabled(true); myPatient = new Patient();