From f91a4f9576cc6fcc3350bcf6c79663ac355e557c Mon Sep 17 00:00:00 2001 From: Tadgh Date: Fri, 16 Apr 2021 14:18:01 -0400 Subject: [PATCH] wip tidy implementaion --- .../jpa/packages/PackageInstallerSvcImpl.java | 2 +- .../partition/RequestPartitionHelperSvc.java | 30 ++++++++----------- .../jpa/bulk/BulkDataExportSvcImplR4Test.java | 6 +++- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java index beb787dc32e..7c044f667db 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java @@ -347,7 +347,7 @@ public class PackageInstallerSvcImpl implements IPackageInstallerSvc { private IBundleProvider searchResource(IFhirResourceDao theDao, SearchParameterMap theMap) { if (myPartitionSettings.isPartitioningEnabled()) { SystemRequestDetails requestDetails = new SystemRequestDetails(); - requestDetails.setTenantId(JpaConstants.DEFAULT_PARTITION_NAME); +// requestDetails.setTenantId(JpaConstants.DEFAULT_PARTITION_NAME); return theDao.search(theMap, requestDetails); } else { return theDao.search(theMap); 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 ceecbb9458d..05707da2e10 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 @@ -103,10 +103,6 @@ public class RequestPartitionHelperSvc implements IRequestPartitionHelperSvc { return RequestPartitionId.defaultPartition(); } - //Shortcircuit and write system calls out to default partition. - if (theRequest instanceof SystemRequestDetails) { - return getSystemRequestPartitionId(theRequest); - } // Interceptor call: STORAGE_PARTITION_IDENTIFY_READ if (hasHooks(Pointcut.STORAGE_PARTITION_IDENTIFY_READ, myInterceptorBroadcaster, theRequest)) { @@ -118,6 +114,10 @@ public class RequestPartitionHelperSvc implements IRequestPartitionHelperSvc { requestPartitionId = null; } + if (theRequest instanceof SystemRequestDetails) { + requestPartitionId = getSystemRequestPartitionId(theRequest); + } + validateRequestPartitionNotNull(requestPartitionId, Pointcut.STORAGE_PARTITION_IDENTIFY_READ); return validateNormalizeAndNotifyHooksForRead(requestPartitionId, theRequest); @@ -159,23 +159,19 @@ public class RequestPartitionHelperSvc implements IRequestPartitionHelperSvc { if (myPartitionSettings.isPartitioningEnabled()) { - //Shortcircuit and write system calls out to default partition. - if (theRequest instanceof SystemRequestDetails) { - return getSystemRequestPartitionId(theRequest); - } - - - // Interceptor call: STORAGE_PARTITION_IDENTIFY_CREATE - HookParams params = new HookParams() - .add(IBaseResource.class, theResource) - .add(RequestDetails.class, theRequest) - .addIfMatchesType(ServletRequestDetails.class, theRequest); - requestPartitionId = (RequestPartitionId) doCallHooksAndReturnObject(myInterceptorBroadcaster, theRequest, Pointcut.STORAGE_PARTITION_IDENTIFY_CREATE, params); // Handle system requests boolean nonPartitionableResource = myNonPartitionableResourceNames.contains(theResourceType); - if (nonPartitionableResource && requestPartitionId == null) { + if (nonPartitionableResource) { requestPartitionId = RequestPartitionId.defaultPartition(); + } else if(theRequest instanceof SystemRequestDetails) { + requestPartitionId = getSystemRequestPartitionId(theRequest); + } else { + HookParams params = new HookParams()// Interceptor call: STORAGE_PARTITION_IDENTIFY_CREATE + .add(IBaseResource.class, theResource) + .add(RequestDetails.class, theRequest) + .addIfMatchesType(ServletRequestDetails.class, theRequest); + requestPartitionId = (RequestPartitionId) doCallHooksAndReturnObject(myInterceptorBroadcaster, theRequest, Pointcut.STORAGE_PARTITION_IDENTIFY_CREATE, params); } String resourceName = myFhirContext.getResourceType(theResource); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java index 432bab10282..ede4c871584 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportSvcImplR4Test.java @@ -18,6 +18,7 @@ import ca.uhn.fhir.jpa.entity.BulkExportCollectionEntity; import ca.uhn.fhir.jpa.entity.BulkExportCollectionFileEntity; import ca.uhn.fhir.jpa.entity.BulkExportJobEntity; import ca.uhn.fhir.jpa.entity.MdmLink; +import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; @@ -1104,6 +1105,7 @@ public class BulkDataExportSvcImplR4Test extends BaseBatchJobR4Test { assertThat(nextContents, is(containsString("IMM999"))); assertThat(nextContents, is(not(containsString("Flu")))); + myPartitionSettings.setPartitioningEnabled(false); } private void createResources() { @@ -1113,7 +1115,9 @@ public class BulkDataExportSvcImplR4Test extends BaseBatchJobR4Test { //Manually create a golden record Patient goldenPatient = new Patient(); goldenPatient.setId("PAT999"); - DaoMethodOutcome g1Outcome = myPatientDao.update(goldenPatient, new SystemRequestDetails()); + SystemRequestDetails srd = new SystemRequestDetails(); + srd.setTenantId(JpaConstants.ALL_PARTITIONS_NAME); + DaoMethodOutcome g1Outcome = myPatientDao.update(goldenPatient, srd); Long goldenPid = myIdHelperService.getPidOrNull(g1Outcome.getResource()); //Create our golden records' data.