From 1f37cdd8cf2c1c6cea2d532ff92d13f73e2d0d07 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Tue, 21 Apr 2020 20:53:10 -0400 Subject: [PATCH] Address review comments --- .../ca/uhn/fhir/interceptor/api/Pointcut.java | 2 +- .../ca/uhn/fhir/i18n/hapi-messages.properties | 14 ++++---- .../hapi/fhir/docs/server_jpa/partitioning.md | 2 +- .../uhn/hapi/fhir/docs/server_jpa/schema.md | 2 +- .../ca/uhn/fhir/jpa/config/BaseConfig.java | 8 ++--- ...sourceIndexedCompositeStringUniqueDao.java | 2 +- .../fhir/jpa/dao/index/IdHelperService.java | 32 +++++++++++-------- ...onfigSvc.java => IPartitionLookupSvc.java} | 2 +- ...cImpl.java => PartitionLookupSvcImpl.java} | 24 +++++++------- .../PartitionManagementProvider.java | 2 +- .../RequestPartitionHelperService.java | 2 +- .../java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java | 4 +-- .../ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java | 4 +-- .../fhir/jpa/dao/r4/PartitioningR4Test.java | 27 +++++++--------- .../PartitionManagementProviderTest.java | 2 +- .../provider/r4/MultitenantServerR4Test.java | 2 +- .../matching/DaoSubscriptionMatcherTest.java | 2 +- .../module/config/TestSubscriptionConfig.java | 2 +- ...bscriptionSubmitInterceptorLoaderTest.java | 2 +- 19 files changed, 68 insertions(+), 69 deletions(-) rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/{IPartitionConfigSvc.java => IPartitionLookupSvc.java} (97%) rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/{PartitionConfigSvcImpl.java => PartitionLookupSvcImpl.java} (90%) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/Pointcut.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/Pointcut.java index 6d282350c56..e916b0b7a92 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/Pointcut.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/Pointcut.java @@ -1258,7 +1258,7 @@ public enum Pointcut { /** * Storage Hook: - * Invoked when a resource delete operation is about to fail due to referential integrity conflicts. + * Invoked when a resource delete operation is about to fail due to referential integrity hcts. *

* Hooks will have access to the list of resources that have references to the resource being deleted. *

diff --git a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties index ff001c3e1fc..07091a1fa7e 100644 --- a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties +++ b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties @@ -149,12 +149,12 @@ ca.uhn.fhir.jpa.dao.predicate.PredicateBuilderReference.invalidResourceType=Inva ca.uhn.fhir.jpa.dao.index.IdHelperService.nonUniqueForcedId=Non-unique ID specified, can not process request -ca.uhn.fhir.jpa.partition.PartitionConfigSvcImpl.missingPartitionIdOrName=Partition must have an ID and a Name -ca.uhn.fhir.jpa.partition.PartitionConfigSvcImpl.cantCreatePartition0=Can not create a partition with ID 0 (this is a reserved value) -ca.uhn.fhir.jpa.partition.PartitionConfigSvcImpl.unknownPartitionId=No partition exists with ID {0} -ca.uhn.fhir.jpa.partition.PartitionConfigSvcImpl.invalidName=Partition name "{0}" is not valid -ca.uhn.fhir.jpa.partition.PartitionConfigSvcImpl.cantCreateDuplicatePartitionName=Partition name "{0}" is already defined -ca.uhn.fhir.jpa.partition.PartitionConfigSvcImpl.cantDeleteDefaultPartition=Can not delete default partition -ca.uhn.fhir.jpa.partition.PartitionConfigSvcImpl.cantRenameDefaultPartition=Can not rename default partition +ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl.missingPartitionIdOrName=Partition must have an ID and a Name +ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl.cantCreatePartition0=Can not create a partition with ID 0 (this is a reserved value) +ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl.unknownPartitionId=No partition exists with ID {0} +ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl.invalidName=Partition name "{0}" is not valid +ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl.cantCreateDuplicatePartitionName=Partition name "{0}" is already defined +ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl.cantDeleteDefaultPartition=Can not delete default partition +ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl.cantRenameDefaultPartition=Can not rename default partition ca.uhn.fhir.rest.server.interceptor.partition.RequestTenantPartitionInterceptor.unknownTenantName=Unknown tenant: {0} diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa/partitioning.md b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa/partitioning.md index 9b9940612f5..0c01181d08c 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa/partitioning.md +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa/partitioning.md @@ -73,7 +73,7 @@ The criteria for determining the partition will depend on your use case. For exa * If you are implementing multi-tenancy the partition might be determined by using the [Request Tenant ID](/docs/server_plain/multitenancy.html). It could also be determined by looking at request headers, or the authorized user/session context, etc. -* If you are implementing segmented data partitioning, the partition might be determined by examining the actpartitionInterceptorHeadersual resource being created, by the identity of the sending system, etc. +* If you are implementing segmented data partitioning, the partition might be determined by examining the actual resource being created, by the identity of the sending system, etc. ## Identify Partition for Read (Optional) diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa/schema.md b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa/schema.md index c65cfe27a87..bb9b9b0c826 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa/schema.md +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa/schema.md @@ -2,7 +2,7 @@ **This page is a work in progress. It is not yet comprehensive.** -It contains a description of the tables within the HAPI FHIR JPA database. Note that columns are shown using Java datatypes as opposed to SQL datatypes, because the exact SQL datatype used will vary depending on the underlying database platform. +It contains a description of the tables within the HAPI FHIR JPA database. Note that columns are shown using Java datatypes as opposed to SQL datatypes, because the exact SQL datatype used will vary depending on the underlying database platform. The schema creation scripts can be used to determine the underlying column types. # Background: Persistent IDs (PIDs) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java index 6cfc235e3b9..06379bf1d55 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java @@ -16,9 +16,9 @@ import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.graphql.JpaStorageServices; import ca.uhn.fhir.jpa.interceptor.JpaConsentContextServices; import ca.uhn.fhir.jpa.model.sched.ISchedulerService; -import ca.uhn.fhir.jpa.partition.IPartitionConfigSvc; +import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc; import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperService; -import ca.uhn.fhir.jpa.partition.PartitionConfigSvcImpl; +import ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl; import ca.uhn.fhir.jpa.partition.PartitionManagementProvider; import ca.uhn.fhir.jpa.partition.RequestPartitionHelperService; import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider; @@ -241,8 +241,8 @@ public abstract class BaseConfig { @Bean @Lazy - public IPartitionConfigSvc partitionConfigSvc() { - return new PartitionConfigSvcImpl(); + public IPartitionLookupSvc partitionConfigSvc() { + return new PartitionLookupSvcImpl(); } @Bean diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceIndexedCompositeStringUniqueDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceIndexedCompositeStringUniqueDao.java index 29ea1e54730..1e142e91ca1 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceIndexedCompositeStringUniqueDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceIndexedCompositeStringUniqueDao.java @@ -33,5 +33,5 @@ public interface IResourceIndexedCompositeStringUniqueDao extends JpaRepository< ResourceIndexedCompositeStringUnique findByQueryString(@Param("str") String theQueryString); @Query("SELECT r FROM ResourceIndexedCompositeStringUnique r WHERE r.myResourceId = :resId") - List findAllForResourceId(@Param("resId") Long theResourceId); + List findAllForResourceIdForUnitTest(@Param("resId") Long theResourceId); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IdHelperService.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IdHelperService.java index 03ab4c5adaf..f4ba463b5da 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IdHelperService.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IdHelperService.java @@ -304,20 +304,7 @@ public class IdHelperService { .map(t -> t.getIdPartAsLong()) .collect(Collectors.toList()); if (!pids.isEmpty()) { - Collection lookup; - if (theRequestPartitionId != null) { - if (theRequestPartitionId.getPartitionId() != null) { - lookup = myResourceTableDao.findLookupFieldsByResourcePidInPartition(pids, theRequestPartitionId.getPartitionId()); - } else { - lookup = myResourceTableDao.findLookupFieldsByResourcePidInPartitionNull(pids); - } - } else { - lookup = myResourceTableDao.findLookupFieldsByResourcePid(pids); - } - lookup - .stream() - .map(t -> new ResourceLookup((String) t[0], (Long) t[1], (Date) t[2])) - .forEach(retVal::add); + resolvePids(theRequestPartitionId, pids, retVal); } } @@ -372,6 +359,23 @@ public class IdHelperService { return retVal; } + private void resolvePids(RequestPartitionId theRequestPartitionId, List thePidsToResolve, List theTarget) { + Collection lookup; + if (theRequestPartitionId != null) { + if (theRequestPartitionId.getPartitionId() != null) { + lookup = myResourceTableDao.findLookupFieldsByResourcePidInPartition(thePidsToResolve, theRequestPartitionId.getPartitionId()); + } else { + lookup = myResourceTableDao.findLookupFieldsByResourcePidInPartitionNull(thePidsToResolve); + } + } else { + lookup = myResourceTableDao.findLookupFieldsByResourcePid(thePidsToResolve); + } + lookup + .stream() + .map(t -> new ResourceLookup((String) t[0], (Long) t[1], (Date) t[2])) + .forEach(theTarget::add); + } + public void clearCache() { myPersistentIdCache.invalidateAll(); myResourceLookupCache.invalidateAll(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/IPartitionConfigSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/IPartitionLookupSvc.java similarity index 97% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/IPartitionConfigSvc.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/IPartitionLookupSvc.java index e3ab0740784..272b51834ac 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/IPartitionConfigSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/IPartitionLookupSvc.java @@ -22,7 +22,7 @@ package ca.uhn.fhir.jpa.partition; import ca.uhn.fhir.jpa.entity.PartitionEntity; -public interface IPartitionConfigSvc { +public interface IPartitionLookupSvc { /** * This is mostly here for unit test purposes. Regular code is not expected to call this method directly. diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionConfigSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionLookupSvcImpl.java similarity index 90% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionConfigSvcImpl.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionLookupSvcImpl.java index 052c196a157..696e38c5529 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionConfigSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionLookupSvcImpl.java @@ -44,13 +44,13 @@ import java.util.regex.Pattern; import static org.apache.commons.lang3.StringUtils.isBlank; -public class PartitionConfigSvcImpl implements IPartitionConfigSvc { +public class PartitionLookupSvcImpl implements IPartitionLookupSvc { public static final int DEFAULT_PERSISTED_PARTITION_ID = 0; public static final String DEFAULT_PERSISTED_PARTITION_NAME = "DEFAULT"; private static final String DEFAULT_PERSISTED_PARTITION_DESC = "Default partition"; private static final Pattern PARTITION_NAME_VALID_PATTERN = Pattern.compile("[a-zA-Z0-9_-]+"); - private static final Logger ourLog = LoggerFactory.getLogger(PartitionConfigSvcImpl.class); + private static final Logger ourLog = LoggerFactory.getLogger(PartitionLookupSvcImpl.class); @Autowired private PlatformTransactionManager myTxManager; @@ -115,7 +115,7 @@ public class PartitionConfigSvcImpl implements IPartitionConfigSvc { validatePartitionNameDoesntAlreadyExist(thePartition.getName()); if (thePartition.getId() == DEFAULT_PERSISTED_PARTITION_ID) { - String msg = myFhirCtx.getLocalizer().getMessage(PartitionConfigSvcImpl.class, "cantCreatePartition0"); + String msg = myFhirCtx.getLocalizer().getMessage(PartitionLookupSvcImpl.class, "cantCreatePartition0"); throw new InvalidRequestException(msg); } @@ -132,7 +132,7 @@ public class PartitionConfigSvcImpl implements IPartitionConfigSvc { Optional existingPartitionOpt = myPartitionDao.findById(thePartition.getId()); if (existingPartitionOpt.isPresent() == false) { - String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionConfigSvcImpl.class, "unknownPartitionId", thePartition.getId()); + String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionLookupSvcImpl.class, "unknownPartitionId", thePartition.getId()); throw new InvalidRequestException(msg); } @@ -143,7 +143,7 @@ public class PartitionConfigSvcImpl implements IPartitionConfigSvc { if (DEFAULT_PERSISTED_PARTITION_ID == thePartition.getId()) { if (!DEFAULT_PERSISTED_PARTITION_NAME.equals(thePartition.getName())) { - String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionConfigSvcImpl.class, "cantRenameDefaultPartition"); + String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionLookupSvcImpl.class, "cantRenameDefaultPartition"); throw new InvalidRequestException(msg); } } @@ -161,13 +161,13 @@ public class PartitionConfigSvcImpl implements IPartitionConfigSvc { Validate.notNull(thePartitionId); if (DEFAULT_PERSISTED_PARTITION_ID == thePartitionId) { - String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionConfigSvcImpl.class, "cantDeleteDefaultPartition"); + String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionLookupSvcImpl.class, "cantDeleteDefaultPartition"); throw new InvalidRequestException(msg); } Optional partition = myPartitionDao.findById(thePartitionId); if (!partition.isPresent()) { - String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionConfigSvcImpl.class, "unknownPartitionId", thePartitionId); + String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionLookupSvcImpl.class, "unknownPartitionId", thePartitionId); throw new IllegalArgumentException(msg); } @@ -178,19 +178,19 @@ public class PartitionConfigSvcImpl implements IPartitionConfigSvc { private void validatePartitionNameDoesntAlreadyExist(String theName) { if (myPartitionDao.findForName(theName).isPresent()) { - String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionConfigSvcImpl.class, "cantCreateDuplicatePartitionName", theName); + String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionLookupSvcImpl.class, "cantCreateDuplicatePartitionName", theName); throw new InvalidRequestException(msg); } } private void validateHaveValidPartitionIdAndName(PartitionEntity thePartition) { if (thePartition.getId() == null || isBlank(thePartition.getName())) { - String msg = myFhirCtx.getLocalizer().getMessage(PartitionConfigSvcImpl.class, "missingPartitionIdOrName"); + String msg = myFhirCtx.getLocalizer().getMessage(PartitionLookupSvcImpl.class, "missingPartitionIdOrName"); throw new InvalidRequestException(msg); } if (!PARTITION_NAME_VALID_PATTERN.matcher(thePartition.getName()).matches()) { - String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionConfigSvcImpl.class, "invalidName", thePartition.getName()); + String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionLookupSvcImpl.class, "invalidName", thePartition.getName()); throw new InvalidRequestException(msg); } @@ -203,7 +203,7 @@ public class PartitionConfigSvcImpl implements IPartitionConfigSvc { return myTxTemplate.execute(t -> myPartitionDao .findForName(theName) .orElseThrow(() -> { - String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionConfigSvcImpl.class, "invalidName", theName); + String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionLookupSvcImpl.class, "invalidName", theName); return new IllegalArgumentException(msg); })); } @@ -216,7 +216,7 @@ public class PartitionConfigSvcImpl implements IPartitionConfigSvc { return myTxTemplate.execute(t -> myPartitionDao .findById(theId) .orElseThrow(() -> { - String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionConfigSvcImpl.class, "unknownPartitionId", theId); + String msg = myFhirCtx.getLocalizer().getMessageSanitized(PartitionLookupSvcImpl.class, "unknownPartitionId", theId); return new IllegalArgumentException(msg); })); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionManagementProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionManagementProvider.java index 22ed62e95ea..62512764be1 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionManagementProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/PartitionManagementProvider.java @@ -47,7 +47,7 @@ public class PartitionManagementProvider { @Autowired private FhirContext myCtx; @Autowired - private IPartitionConfigSvc myPartitionConfigSvc; + private IPartitionLookupSvc myPartitionConfigSvc; /** * Add Partition: diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperService.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperService.java index fdc78699be5..861de5f6bd9 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperService.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/partition/RequestPartitionHelperService.java @@ -52,7 +52,7 @@ public class RequestPartitionHelperService implements IRequestPartitionHelperSer @Autowired private IInterceptorBroadcaster myInterceptorBroadcaster; @Autowired - private IPartitionConfigSvc myPartitionConfigSvc; + private IPartitionLookupSvc myPartitionConfigSvc; @Autowired private FhirContext myFhirContext; @Autowired diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java index 67d79984b8b..f1a87ee772c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java @@ -6,7 +6,7 @@ import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.interceptor.executor.InterceptorService; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; -import ca.uhn.fhir.jpa.partition.IPartitionConfigSvc; +import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc; import ca.uhn.fhir.test.BaseTest; import ca.uhn.fhir.jpa.bulk.IBulkDataExportSvc; import ca.uhn.fhir.jpa.entity.TermConcept; @@ -110,7 +110,7 @@ public abstract class BaseJpaTest extends BaseTest { @Autowired protected ISearchCacheSvc mySearchCacheSvc; @Autowired - protected IPartitionConfigSvc myPartitionConfigSvc; + protected IPartitionLookupSvc myPartitionConfigSvc; @After public void afterPerformCleanup() { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java index 8341403ecc9..c4fc933cc49 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java @@ -30,7 +30,7 @@ import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString; import ca.uhn.fhir.jpa.model.entity.ResourceTable; -import ca.uhn.fhir.jpa.partition.IPartitionConfigSvc; +import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc; import ca.uhn.fhir.jpa.provider.r4.JpaSystemProviderR4; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc; @@ -103,7 +103,7 @@ public abstract class BaseJpaR4Test extends BaseJpaTest { private static IFhirResourceDaoValueSet ourValueSetDao; @Autowired - protected IPartitionConfigSvc myPartitionConfigSvc; + protected IPartitionLookupSvc myPartitionConfigSvc; @Autowired protected ITermReadSvc myHapiTerminologySvc; @Autowired diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningR4Test.java index 7d76132060d..8a0a7ab0dc4 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningR4Test.java @@ -7,7 +7,7 @@ import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.entity.PartitionEntity; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.*; -import ca.uhn.fhir.jpa.partition.IPartitionConfigSvc; +import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc; import ca.uhn.fhir.jpa.searchparam.SearchParamConstants; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.api.Constants; @@ -76,7 +76,7 @@ public class PartitioningR4Test extends BaseJpaR4SystemTest { private int myPartitionId2; private boolean myHaveDroppedForcedIdUniqueConstraint; @Autowired - private IPartitionConfigSvc myPartitionConfigSvc; + private IPartitionLookupSvc myPartitionConfigSvc; @After public void after() { @@ -365,12 +365,11 @@ public class PartitioningR4Test extends BaseJpaR4SystemTest { createRequestId(); addCreatePartition(myPartitionId, myPartitionDate); - addCreatePartition(myPartitionId, myPartitionDate); - Organization org = new Organization(); org.setName("org"); IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless(); + addCreatePartition(myPartitionId, myPartitionDate); Patient p = new Patient(); p.getMeta().addTag("http://system", "code", "diisplay"); p.addName().setFamily("FAM"); @@ -436,7 +435,7 @@ public class PartitioningR4Test extends BaseJpaR4SystemTest { assertEquals(myPartitionDate, presents.get(0).getPartitionId().getPartitionDate()); // HFJ_IDX_CMP_STRING_UNIQ - List uniques = myResourceIndexedCompositeStringUniqueDao.findAllForResourceId(patientId); + List uniques = myResourceIndexedCompositeStringUniqueDao.findAllForResourceIdForUnitTest(patientId); assertEquals(1, uniques.size()); assertEquals(myPartitionId, uniques.get(0).getPartitionId().getPartitionId().intValue()); assertEquals(myPartitionDate, uniques.get(0).getPartitionId().getPartitionDate()); @@ -450,12 +449,11 @@ public class PartitioningR4Test extends BaseJpaR4SystemTest { createRequestId(); addCreateNoPartitionId(myPartitionDate); - addCreateNoPartitionId(myPartitionDate); - Organization org = new Organization(); org.setName("org"); IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless(); + addCreateNoPartitionId(myPartitionDate); Patient p = new Patient(); p.getMeta().addTag("http://system", "code", "diisplay"); p.addName().setFamily("FAM"); @@ -521,7 +519,7 @@ public class PartitioningR4Test extends BaseJpaR4SystemTest { assertEquals(myPartitionDate, presents.get(0).getPartitionId().getPartitionDate()); // HFJ_IDX_CMP_STRING_UNIQ - List uniques = myResourceIndexedCompositeStringUniqueDao.findAllForResourceId(patientId); + List uniques = myResourceIndexedCompositeStringUniqueDao.findAllForResourceIdForUnitTest(patientId); assertEquals(1, uniques.size()); assertEquals(null, uniques.get(0).getPartitionId().getPartitionId()); assertEquals(myPartitionDate, uniques.get(0).getPartitionId().getPartitionDate()); @@ -533,13 +531,12 @@ public class PartitioningR4Test extends BaseJpaR4SystemTest { @Test public void testCreate_ForcedId_WithPartition() { addCreatePartition(myPartitionId, myPartitionDate); - addCreatePartition(myPartitionId, myPartitionDate); - Organization org = new Organization(); org.setId("org"); org.setName("org"); IIdType orgId = myOrganizationDao.update(org).getId().toUnqualifiedVersionless(); + addCreatePartition(myPartitionId, myPartitionDate); Patient p = new Patient(); p.setId("pat"); p.getManagingOrganization().setReferenceElement(orgId); @@ -560,13 +557,12 @@ public class PartitioningR4Test extends BaseJpaR4SystemTest { @Test public void testCreate_ForcedId_NoPartition() { addCreateNoPartition(); - addCreateNoPartition(); - Organization org = new Organization(); org.setId("org"); org.setName("org"); IIdType orgId = myOrganizationDao.update(org).getId().toUnqualifiedVersionless(); + addCreateNoPartition(); Patient p = new Patient(); p.setId("pat"); p.getManagingOrganization().setReferenceElement(orgId); @@ -585,13 +581,12 @@ public class PartitioningR4Test extends BaseJpaR4SystemTest { @Test public void testCreate_ForcedId_DefaultPartition() { addCreateNoPartitionId(myPartitionDate); - addCreateNoPartitionId(myPartitionDate); - Organization org = new Organization(); org.setId("org"); org.setName("org"); IIdType orgId = myOrganizationDao.update(org).getId().toUnqualifiedVersionless(); + addCreateNoPartitionId(myPartitionDate); Patient p = new Patient(); p.setId("pat"); p.getManagingOrganization().setReferenceElement(orgId); @@ -613,10 +608,10 @@ public class PartitioningR4Test extends BaseJpaR4SystemTest { @Test public void testUpdateResourceWithPartition() { createRequestId(); - addCreatePartition(myPartitionId, myPartitionDate); - addCreatePartition(myPartitionId, myPartitionDate); // Create a resource + addCreatePartition(myPartitionId, myPartitionDate); + addCreatePartition(myPartitionId, myPartitionDate); Patient p = new Patient(); p.getMeta().addTag("http://system", "code", "diisplay"); p.setActive(true); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/partition/PartitionManagementProviderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/partition/PartitionManagementProviderTest.java index 367d733d8af..8a323060656 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/partition/PartitionManagementProviderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/partition/PartitionManagementProviderTest.java @@ -43,7 +43,7 @@ public class PartitionManagementProviderTest { @ClassRule public static RestfulServerRule ourServerRule = new RestfulServerRule(ourCtx); @MockBean - private IPartitionConfigSvc myPartitionConfigSvc; + private IPartitionLookupSvc myPartitionConfigSvc; @Autowired private PartitionManagementProvider myPartitionManagementProvider; private IGenericClient myClient; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantServerR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantServerR4Test.java index 330a33cb8e6..7235561d227 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantServerR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantServerR4Test.java @@ -21,7 +21,7 @@ import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import static ca.uhn.fhir.jpa.partition.PartitionConfigSvcImpl.DEFAULT_PERSISTED_PARTITION_NAME; +import static ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl.DEFAULT_PERSISTED_PARTITION_NAME; import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/DaoSubscriptionMatcherTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/DaoSubscriptionMatcherTest.java index 3b35945636a..63cfd62b281 100644 --- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/DaoSubscriptionMatcherTest.java +++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/matcher/matching/DaoSubscriptionMatcherTest.java @@ -67,7 +67,7 @@ public class DaoSubscriptionMatcherTest { public static class MyConfig { @Bean - public PartitionSettings partitionConfig() { + public PartitionSettings partitionSettings() { return new PartitionSettings(); } diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionConfig.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionConfig.java index c631aea1457..0a3e7b9f6f5 100644 --- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionConfig.java +++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/module/config/TestSubscriptionConfig.java @@ -17,7 +17,7 @@ import org.springframework.test.context.TestPropertySource; public class TestSubscriptionConfig { @Bean - public PartitionSettings partitionConfig() { + public PartitionSettings partitionSettings() { return new PartitionSettings(); } diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionSubmitInterceptorLoaderTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionSubmitInterceptorLoaderTest.java index 8a6081c8de1..f6d9d4c3761 100644 --- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionSubmitInterceptorLoaderTest.java +++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/submit/interceptor/SubscriptionSubmitInterceptorLoaderTest.java @@ -69,7 +69,7 @@ public class SubscriptionSubmitInterceptorLoaderTest { } @Bean - public PartitionSettings partitionConfig() { + public PartitionSettings partitionSettings() { return new PartitionSettings(); }