autoCreatePlaceholderReferenceTargets true breaks multitenancy (#2215)

* Fix #2209 - autoCreatePlaceholderReferenceTargets true breaks multi-tenancy

* Add changelog

* Address fixme
This commit is contained in:
James Agnew 2020-12-03 08:53:37 -05:00 committed by GitHub
parent 35f4d48eee
commit 1eae5db374
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 220 additions and 196 deletions

View File

@ -0,0 +1,6 @@
---
type: fix
issue: 2215
title: "When using a partitioned JPA server, auto-create placeholder targets did not work if the partition interceptor was
registered against the server (e.g. for a multitenancy configuration). This has been corrected. Thanks to Rob Whelan for
reporting!"

View File

@ -609,7 +609,13 @@
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5-20081211</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>

View File

@ -361,7 +361,7 @@ public abstract class BaseConfig {
@Bean
public IInterceptorService jpaInterceptorService() {
return new InterceptorService();
return new InterceptorService("JPA");
}
/**

View File

@ -72,7 +72,7 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
ourLog.trace("Translated {}/{} to resource PID {}", theType, idPart, resolvedResource);
} catch (ResourceNotFoundException e) {
Optional<ResourceTable> createdTableOpt = createPlaceholderTargetIfConfiguredToDoSo(theType, theReference, idPart);
Optional<ResourceTable> createdTableOpt = createPlaceholderTargetIfConfiguredToDoSo(theType, theReference, idPart, theRequest);
if (!createdTableOpt.isPresent()) {
if (myDaoConfig.isEnforceReferentialIntegrityOnWrite() == false) {
@ -109,7 +109,7 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
/**
* @param theIdToAssignToPlaceholder If specified, the placeholder resource created will be given a specific ID
*/
public <T extends IBaseResource> Optional<ResourceTable> createPlaceholderTargetIfConfiguredToDoSo(Class<T> theType, IBaseReference theReference, @Nullable String theIdToAssignToPlaceholder) {
public <T extends IBaseResource> Optional<ResourceTable> createPlaceholderTargetIfConfiguredToDoSo(Class<T> theType, IBaseReference theReference, @Nullable String theIdToAssignToPlaceholder, RequestDetails theRequest) {
ResourceTable valueOf = null;
if (myDaoConfig.isAutoCreatePlaceholderReferenceTargets()) {
@ -128,9 +128,9 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
if (theIdToAssignToPlaceholder != null) {
newResource.setId(resName + "/" + theIdToAssignToPlaceholder);
valueOf = ((ResourceTable) placeholderResourceDao.update(newResource).getEntity());
valueOf = ((ResourceTable) placeholderResourceDao.update(newResource, theRequest).getEntity());
} else {
valueOf = ((ResourceTable) placeholderResourceDao.create(newResource).getEntity());
valueOf = ((ResourceTable) placeholderResourceDao.create(newResource, theRequest).getEntity());
}
}

View File

@ -254,7 +254,7 @@ public class SearchParamWithInlineReferencesExtractor {
ResourcePersistentId match;
if (matches.isEmpty()) {
Optional<ResourceTable> placeholderOpt = myDaoResourceLinkResolver.createPlaceholderTargetIfConfiguredToDoSo(matchResourceType, nextRef, null);
Optional<ResourceTable> placeholderOpt = myDaoResourceLinkResolver.createPlaceholderTargetIfConfiguredToDoSo(matchResourceType, nextRef, null, theRequest);
if (placeholderOpt.isPresent()) {
match = new ResourcePersistentId(placeholderOpt.get().getResourceId());
} else {

View File

@ -38,14 +38,13 @@ import ca.uhn.fhir.test.utilities.LoggingExtension;
import ca.uhn.fhir.test.utilities.ProxyUtil;
import ca.uhn.fhir.test.utilities.UnregisterScheduledProcessor;
import ca.uhn.fhir.util.BundleUtil;
import ca.uhn.fhir.util.FhirVersionIndependentConcept;
import ca.uhn.fhir.util.StopWatch;
import ca.uhn.fhir.util.TestUtil;
import ca.uhn.fhir.util.FhirVersionIndependentConcept;
import org.apache.commons.io.IOUtils;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.jdbc.Work;
import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu3.model.Resource;
@ -70,10 +69,9 @@ import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -85,6 +83,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import static ca.uhn.fhir.util.TestUtil.randomizeLocale;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.eq;
@ -116,7 +115,7 @@ public abstract class BaseJpaTest extends BaseTest {
public LoggingExtension myLoggingExtension = new LoggingExtension();
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
protected ServletRequestDetails mySrd;
protected InterceptorService myRequestOperationCallback;
protected InterceptorService mySrdInterceptorService;
@Autowired
protected DatabaseBackedPagingProvider myDatabaseBackedPagingProvider;
@Autowired
@ -173,18 +172,13 @@ public abstract class BaseJpaTest extends BaseTest {
AtomicBoolean isReadOnly = new AtomicBoolean();
Session currentSession;
try {
assert sessionFactory != null;
currentSession = sessionFactory.getCurrentSession();
} catch (HibernateException e) {
currentSession = null;
}
if (currentSession != null) {
currentSession.doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
isReadOnly.set(connection.isReadOnly());
}
});
currentSession.doWork(connection -> isReadOnly.set(connection.isReadOnly()));
assertFalse(isReadOnly.get());
}
@ -199,12 +193,12 @@ public abstract class BaseJpaTest extends BaseTest {
}
@BeforeEach
public void beforeInitMocks() {
myRequestOperationCallback = new InterceptorService();
public void beforeInitMocks() throws Exception {
mySrdInterceptorService = new InterceptorService();
MockitoAnnotations.initMocks(this);
when(mySrd.getInterceptorBroadcaster()).thenReturn(myRequestOperationCallback);
when(mySrd.getInterceptorBroadcaster()).thenReturn(mySrdInterceptorService);
when(mySrd.getUserData()).thenReturn(new HashMap<>());
when(mySrd.getHeaders(eq(JpaConstants.HEADER_META_SNAPSHOT_MODE))).thenReturn(new ArrayList<>());
when(mySrd.getServer().getDefaultPageSize()).thenReturn(null);
@ -231,7 +225,7 @@ public abstract class BaseJpaTest extends BaseTest {
public void runInTransaction(Runnable theRunnable) {
newTxTemplate().execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
theRunnable.run();
}
});
@ -250,16 +244,14 @@ public abstract class BaseJpaTest extends BaseTest {
/**
* Sleep until at least 1 ms has elapsed
*/
public void sleepUntilTimeChanges() throws InterruptedException {
public void sleepUntilTimeChanges() {
StopWatch sw = new StopWatch();
while (sw.getMillis() == 0) {
Thread.sleep(10);
}
await().until(() -> sw.getMillis() > 0);
}
protected org.hl7.fhir.dstu3.model.Bundle toBundle(IBundleProvider theSearch) {
org.hl7.fhir.dstu3.model.Bundle bundle = new org.hl7.fhir.dstu3.model.Bundle();
for (IBaseResource next : theSearch.getResources(0, theSearch.size())) {
for (IBaseResource next : theSearch.getResources(0, theSearch.sizeOrThrowNpe())) {
bundle.addEntry().setResource((Resource) next);
}
return bundle;
@ -267,7 +259,7 @@ public abstract class BaseJpaTest extends BaseTest {
protected org.hl7.fhir.r4.model.Bundle toBundleR4(IBundleProvider theSearch) {
org.hl7.fhir.r4.model.Bundle bundle = new org.hl7.fhir.r4.model.Bundle();
for (IBaseResource next : theSearch.getResources(0, theSearch.size())) {
for (IBaseResource next : theSearch.getResources(0, theSearch.sizeOrThrowNpe())) {
bundle.addEntry().setResource((org.hl7.fhir.r4.model.Resource) next);
}
return bundle;
@ -275,11 +267,11 @@ public abstract class BaseJpaTest extends BaseTest {
@SuppressWarnings({"rawtypes"})
protected List toList(IBundleProvider theSearch) {
return theSearch.getResources(0, theSearch.size());
return theSearch.getResources(0, theSearch.sizeOrThrowNpe());
}
protected List<String> toUnqualifiedIdValues(IBaseBundle theFound) {
List<String> retVal = new ArrayList<String>();
List<String> retVal = new ArrayList<>();
List<IBaseResource> res = BundleUtil.toListOfResources(getContext(), theFound);
int size = res.size();
@ -291,8 +283,8 @@ public abstract class BaseJpaTest extends BaseTest {
}
protected List<String> toUnqualifiedIdValues(IBundleProvider theFound) {
List<String> retVal = new ArrayList<String>();
int size = theFound.size();
List<String> retVal = new ArrayList<>();
int size = theFound.sizeOrThrowNpe();
ourLog.info("Found {} results", size);
List<IBaseResource> resources = theFound.getResources(0, size);
for (IBaseResource next : resources) {
@ -302,7 +294,7 @@ public abstract class BaseJpaTest extends BaseTest {
}
protected List<String> toUnqualifiedVersionlessIdValues(IBaseBundle theFound) {
List<String> retVal = new ArrayList<String>();
List<String> retVal = new ArrayList<>();
List<IBaseResource> res = BundleUtil.toListOfResources(getContext(), theFound);
int size = res.size();
@ -429,6 +421,7 @@ public abstract class BaseJpaTest extends BaseTest {
return retVal.toArray(new String[0]);
}
@SuppressWarnings("BusyWait")
protected void waitForActivatedSubscriptionCount(int theSize) throws Exception {
for (int i = 0; ; i++) {
if (i == 10) {
@ -473,6 +466,7 @@ public abstract class BaseJpaTest extends BaseTest {
return IOUtils.toByteArray(bundleRes);
}
@SuppressWarnings("BusyWait")
protected static void purgeDatabase(DaoConfig theDaoConfig, IFhirSystemDao<?, ?> theSystemDao, IResourceReindexingSvc theResourceReindexingSvc, ISearchCoordinatorSvc theSearchCoordinatorSvc, ISearchParamRegistry theSearchParamRegistry, IBulkDataExportSvc theBulkDataExportSvc) {
theSearchCoordinatorSvc.cancelAllActiveSearches();
theResourceReindexingSvc.cancelAndPurgeAllJobs();
@ -519,6 +513,7 @@ public abstract class BaseJpaTest extends BaseTest {
return retVal;
}
@SuppressWarnings("BusyWait")
public static void waitForSize(int theTarget, List<?> theList) {
StopWatch sw = new StopWatch();
while (theList.size() != theTarget && sw.getMillis() <= 16000) {
@ -549,6 +544,7 @@ public abstract class BaseJpaTest extends BaseTest {
waitForSize(theTarget, 10000, theCallable);
}
@SuppressWarnings("BusyWait")
public static void waitForSize(int theTarget, int theTimeout, Callable<Number> theCallable) throws Exception {
StopWatch sw = new StopWatch();
while (theCallable.call().intValue() != theTarget && sw.getMillis() < theTimeout) {
@ -568,6 +564,7 @@ public abstract class BaseJpaTest extends BaseTest {
waitForSize(theTarget, 10000, theCallable, theFailureMessage);
}
@SuppressWarnings("BusyWait")
public static void waitForSize(int theTarget, int theTimeout, Callable<Number> theCallable, Callable<String> theFailureMessage) throws Exception {
StopWatch sw = new StopWatch();
while (theCallable.call().intValue() != theTarget && sw.getMillis() < theTimeout) {

View File

@ -1,15 +1,10 @@
package ca.uhn.fhir.jpa.dao.r4;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.jpa.rp.r4.PatientResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.util.TestUtil;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
@ -17,17 +12,16 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public abstract class BaseJpaR4SystemTest extends BaseJpaR4Test {
protected ServletRequestDetails mySrd;
private RestfulServer myServer;
@Override
@SuppressWarnings("unchecked")
@BeforeEach
public void before() throws ServletException {
mySrd = mock(ServletRequestDetails.class);
when(mySrd.getInterceptorBroadcaster()).thenReturn(mock(IInterceptorBroadcaster.class));
public void beforeInitMocks() throws Exception {
super.beforeInitMocks();
if (myServer == null) {
myServer = new RestfulServer(myFhirCtx);
myServer = new RestfulServer(myFhirCtx, mySrdInterceptorService);
PatientResourceProvider patientRp = new PatientResourceProvider();
patientRp.setDao(myPatientDao);

View File

@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.dao.r4;
import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor;
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.config.TestR4Config;
import ca.uhn.fhir.jpa.entity.Search;
@ -52,7 +51,6 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
private static final Logger ourLog = LoggerFactory.getLogger(ConsentEventsDaoR4Test.class);
private List<String> myObservationIds;
private List<String> myPatientIds;
private InterceptorService myInterceptorService;
private List<String> myObservationIdsOddOnly;
private List<String> myObservationIdsEvenOnly;
private List<String> myObservationIdsWithVersions;
@ -64,16 +62,11 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
myDaoConfig.setIndexMissingFields(new DaoConfig().getIndexMissingFields());
}
@Override
@BeforeEach
public void before() throws ServletException {
super.before();
RestfulServer restfulServer = new RestfulServer();
restfulServer.setPagingProvider(myPagingProvider);
myInterceptorService = new InterceptorService();
when(mySrd.getInterceptorBroadcaster()).thenReturn(myInterceptorService);
when(mySrd.getServer()).thenReturn(restfulServer);
myDaoConfig.setSearchPreFetchThresholds(Arrays.asList(20, 50, 190));
@ -86,7 +79,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCounting(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
// Perform a search
SearchParameterMap map = new SearchParameterMap();
@ -118,7 +111,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCountingAndBlockOdd(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
// Perform a search
SearchParameterMap map = new SearchParameterMap();
@ -158,7 +151,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCountingAndBlockOdd(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
// Perform a search
SearchParameterMap map = new SearchParameterMap();
@ -191,7 +184,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCountingAndBlockOdd(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
// Perform a search
SearchParameterMap map = new SearchParameterMap();
@ -216,7 +209,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCountingAndBlockOdd(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
// Perform a search
SearchParameterMap map = new SearchParameterMap();
@ -244,7 +237,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCountingAndBlockOdd(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
// Perform a search
SearchParameterMap map = new SearchParameterMap();
@ -269,7 +262,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCounting(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
// Perform a search
SearchParameterMap map = new SearchParameterMap();
@ -292,7 +285,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCountingAndBlockOdd(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
// Perform a search
SearchParameterMap map = new SearchParameterMap();
@ -316,7 +309,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCountingAndBlockOdd(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
// Perform a history
SearchParameterMap map = new SearchParameterMap();
@ -346,7 +339,7 @@ public class ConsentEventsDaoR4Test extends BaseJpaR4SystemTest {
AtomicInteger hitCount = new AtomicInteger(0);
List<String> interceptedResourceIds = new ArrayList<>();
IAnonymousInterceptor interceptor = new PreAccessInterceptorCountingAndBlockOdd(hitCount, interceptedResourceIds);
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
mySrdInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PREACCESS_RESOURCES, interceptor);
myObservationDao.read(new IdType(myObservationIdsEvenOnly.get(0)), mySrd);
myObservationDao.read(new IdType(myObservationIdsEvenOnly.get(1)), mySrd);

View File

@ -7,7 +7,6 @@ import ca.uhn.fhir.jpa.api.model.DeleteMethodOutcome;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.interceptor.IServerOperationInterceptor;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.util.TestUtil;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.Bundle;
@ -16,7 +15,6 @@ import org.hl7.fhir.r4.model.Bundle.HTTPVerb;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Patient;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
@ -508,7 +506,7 @@ public class FhirResourceDaoR4InterceptorTest extends BaseJpaR4Test {
((Patient) theResource).setActive(true);
}
};
myRequestOperationCallback.registerInterceptor(interceptor);
mySrdInterceptorService.registerInterceptor(interceptor);
Patient p = new Patient();
p.setActive(false);

View File

@ -116,7 +116,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
myPartitionSettings.setPartitioningEnabled(new PartitionSettings().isPartitioningEnabled());
myPartitionSettings.setAllowReferencesAcrossPartitions(new PartitionSettings().getAllowReferencesAcrossPartitions());
myInterceptorRegistry.unregisterInterceptorsIf(t -> t instanceof MyReadWriteInterceptor);
mySrdInterceptorService.unregisterInterceptorsIf(t -> t instanceof MyReadWriteInterceptor);
myInterceptor = null;
if (myHaveDroppedForcedIdUniqueConstraint) {
@ -127,13 +127,11 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
}
myDaoConfig.setIndexMissingFields(new DaoConfig().getIndexMissingFields());
myDaoConfig.setAutoCreatePlaceholderReferenceTargets(new DaoConfig().isAutoCreatePlaceholderReferenceTargets());
}
@Override
@BeforeEach
public void before() throws ServletException {
super.before();
myPartitionSettings.setPartitioningEnabled(true);
myPartitionSettings.setIncludePartitionInSearchHashes(new PartitionSettings().isIncludePartitionInSearchHashes());
@ -147,7 +145,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
myPartitionId2 = 2;
myPartitionInterceptor = new MyReadWriteInterceptor();
myInterceptorRegistry.registerInterceptor(myPartitionInterceptor);
mySrdInterceptorService.registerInterceptor(myPartitionInterceptor);
myPartitionConfigSvc.createPartition(new PartitionEntity().setId(1).setName(PARTITION_1));
myPartitionConfigSvc.createPartition(new PartitionEntity().setId(2).setName(PARTITION_2));
@ -158,7 +156,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
// Ensure the partition names are resolved
myPartitionInterceptor.addReadPartition(RequestPartitionId.fromPartitionNames(JpaConstants.DEFAULT_PARTITION_NAME, PARTITION_1, PARTITION_2, PARTITION_3, PARTITION_4));
myPatientDao.search(new SearchParameterMap().setLoadSynchronous(true));
myPatientDao.search(new SearchParameterMap().setLoadSynchronous(true), mySrd);
}
@ -188,7 +186,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addCreatePartition(myPartitionId, myPartitionDate);
Patient patient = new Patient();
patient.setActive(true);
IIdType patientId = myPatientDao.create(patient).getId().toUnqualifiedVersionless();
IIdType patientId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
// Create observation in partition 2
addCreatePartition(myPartitionId2, myPartitionDate2);
@ -196,7 +194,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
obs.getSubject().setReference(patientId.getValue());
myCaptureQueriesListener.clear();
IIdType obsId = myObservationDao.create(obs).getId().toUnqualifiedVersionless();
IIdType obsId = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
List<SqlQuery> selectQueries = myCaptureQueriesListener.getSelectQueriesForCurrentThread();
assertEquals(2, selectQueries.size());
@ -222,7 +220,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addCreatePartition(myPartitionId, myPartitionDate);
Patient patient = new Patient();
patient.setActive(true);
IIdType patientId = myPatientDao.create(patient).getId().toUnqualifiedVersionless();
IIdType patientId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
// Create observation in partition 2
addCreatePartition(myPartitionId2, myPartitionDate2);
@ -230,7 +228,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
obs.getSubject().setReference(patientId.getValue());
try {
myObservationDao.create(obs).getId().toUnqualifiedVersionless();
myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
fail();
} catch (InvalidRequestException e) {
assertThat(e.getMessage(), startsWith("Resource Patient/" + patientId.getIdPart() + " not found, specified in path: Observation.subject"));
@ -248,13 +246,13 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
Patient patient = new Patient();
patient.setId("ONE");
patient.setActive(true);
IIdType patientId = myPatientDao.update(patient).getId().toUnqualifiedVersionless();
IIdType patientId = myPatientDao.update(patient, mySrd).getId().toUnqualifiedVersionless();
// Create observation in partition 2
addCreatePartition(myPartitionId2, myPartitionDate2);
Observation obs = new Observation();
obs.getSubject().setReference(patientId.getValue());
IIdType obsId = myObservationDao.create(obs).getId().toUnqualifiedVersionless();
IIdType obsId = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
runInTransaction(() -> {
List<ResourceLink> resLinks = myResourceLinkDao.findAll();
@ -274,7 +272,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
Patient patient = new Patient();
patient.setId("ONE");
patient.setActive(true);
IIdType patientId = myPatientDao.update(patient).getId().toUnqualifiedVersionless();
IIdType patientId = myPatientDao.update(patient, mySrd).getId().toUnqualifiedVersionless();
// Create observation in partition 2
addCreatePartition(myPartitionId2, myPartitionDate2);
@ -282,7 +280,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
obs.getSubject().setReference(patientId.getValue());
try {
myObservationDao.create(obs).getId().toUnqualifiedVersionless();
myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
fail();
} catch (InvalidRequestException e) {
assertThat(e.getMessage(), startsWith("Resource Patient/ONE not found, specified in path: Observation.subject"));
@ -296,13 +294,13 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addCreateDefaultPartition(myPartitionDate);
Patient patient = new Patient();
patient.setActive(true);
IIdType patientId = myPatientDao.create(patient).getId().toUnqualifiedVersionless();
IIdType patientId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
// Create observation in partition NULL
addCreateDefaultPartition(myPartitionDate);
Observation obs = new Observation();
obs.getSubject().setReference(patientId.getValue());
IIdType obsId = myObservationDao.create(obs).getId().toUnqualifiedVersionless();
IIdType obsId = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
runInTransaction(() -> {
List<ResourceLink> resLinks = myResourceLinkDao.findAll();
@ -321,13 +319,13 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
Patient patient = new Patient();
patient.setId("ONE");
patient.setActive(true);
IIdType patientId = myPatientDao.update(patient).getId().toUnqualifiedVersionless();
IIdType patientId = myPatientDao.update(patient, mySrd).getId().toUnqualifiedVersionless();
// Create observation in partition NULL
addCreateDefaultPartition(myPartitionDate);
Observation obs = new Observation();
obs.getSubject().setReference(patientId.getValue());
IIdType obsId = myObservationDao.create(obs).getId().toUnqualifiedVersionless();
IIdType obsId = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
runInTransaction(() -> {
List<ResourceLink> resLinks = myResourceLinkDao.findAll();
@ -381,15 +379,33 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
}
}
@Test
public void testCreate_AutoCreatePlaceholderTargets() {
myDaoConfig.setAutoCreatePlaceholderReferenceTargets(true);
addCreatePartition(1, null);
addCreatePartition(1, null);
addReadPartition(1);
IIdType patientId1 = createPatient(withOrganization(new IdType("Organization/FOO")));
addReadPartition(1);
IdType gotId1 = myPatientDao.read(patientId1, mySrd).getIdElement().toUnqualifiedVersionless();
assertEquals(patientId1, gotId1);
addReadPartition(1);
IdType gotIdOrg = myOrganizationDao.read(new IdType("Organization/FOO"), mySrd).getIdElement().toUnqualifiedVersionless();
assertEquals("Organization/FOO", gotIdOrg.toUnqualifiedVersionless().getValue());
}
@Test
public void testCreate_UnknownPartition() {
addCreatePartition(99, null);
Patient p = new Patient();
p.addIdentifier().setSystem("system").setValue("value");
p.setBirthDate(new Date());
Patient patient = new Patient();
patient.addIdentifier().setSystem("system").setValue("value");
patient.setBirthDate(new Date());
try {
myPatientDao.create(p);
myPatientDao.create(patient, mySrd);
fail();
} catch (ResourceNotFoundException e) {
assertEquals("No partition exists with ID 99", e.getMessage());
@ -401,10 +417,10 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
public void testCreate_ServerId_NoPartition() {
addCreateDefaultPartition();
Patient p = new Patient();
p.addIdentifier().setSystem("system").setValue("value");
p.setBirthDate(new Date());
Long patientId = myPatientDao.create(p).getId().getIdPartAsLong();
Patient patient = new Patient();
patient.addIdentifier().setSystem("system").setValue("value");
patient.setBirthDate(new Date());
Long patientId = myPatientDao.create(patient, mySrd).getId().getIdPartAsLong();
runInTransaction(() -> {
ResourceTable resourceTable = myResourceTableDao.findById(patientId).orElseThrow(IllegalArgumentException::new);
@ -421,7 +437,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addCreatePartition(myPartitionId, myPartitionDate);
Organization org = new Organization();
org.setName("org");
IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
IIdType orgId = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
addCreatePartition(myPartitionId, myPartitionDate);
Patient p = new Patient();
@ -505,7 +521,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addCreateDefaultPartition(myPartitionDate);
Organization org = new Organization();
org.setName("org");
IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
IIdType orgId = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
addCreateDefaultPartition(myPartitionDate);
Patient p = new Patient();
@ -589,7 +605,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
Organization org = new Organization();
org.setId("org");
org.setName("org");
IIdType orgId = myOrganizationDao.update(org).getId().toUnqualifiedVersionless();
IIdType orgId = myOrganizationDao.update(org, mySrd).getId().toUnqualifiedVersionless();
addReadPartition(myPartitionId);
addCreatePartition(myPartitionId, myPartitionDate);
@ -617,7 +633,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
Organization org = new Organization();
org.setId("org");
org.setName("org");
IIdType orgId = myOrganizationDao.update(org).getId().toUnqualifiedVersionless();
IIdType orgId = myOrganizationDao.update(org, mySrd).getId().toUnqualifiedVersionless();
addReadDefaultPartition();
addCreateDefaultPartition();
@ -643,7 +659,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
Organization org = new Organization();
org.setId("org");
org.setName("org");
IIdType orgId = myOrganizationDao.update(org).getId().toUnqualifiedVersionless();
IIdType orgId = myOrganizationDao.update(org, mySrd).getId().toUnqualifiedVersionless();
addReadDefaultPartition();
addCreateDefaultPartition(myPartitionDate);
@ -713,10 +729,10 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
// Create a resource
addCreatePartition(myPartitionId, myPartitionDate);
Patient p = new Patient();
p.getMeta().addTag("http://system", "code", "diisplay");
p.setActive(true);
Long patientId = myPatientDao.create(p).getId().getIdPartAsLong();
Patient patient = new Patient();
patient.getMeta().addTag("http://system", "code", "diisplay");
patient.setActive(true);
Long patientId = myPatientDao.create(patient, mySrd).getId().getIdPartAsLong();
runInTransaction(() -> {
// HFJ_RESOURCE
ResourceTable resourceTable = myResourceTableDao.findById(patientId).orElseThrow(IllegalArgumentException::new);
@ -726,10 +742,10 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
// Update that resource
addReadPartition(myPartitionId);
p = new Patient();
p.setId("Patient/" + patientId);
p.setActive(false);
myPatientDao.update(p, mySrd);
patient = new Patient();
patient.setId("Patient/" + patientId);
patient.setActive(false);
myPatientDao.update(patient, mySrd);
runInTransaction(() -> {
// HFJ_RESOURCE
@ -1067,6 +1083,21 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
} catch (ResourceNotFoundException e) {
assertThat(e.getMessage(), matchesPattern("Resource Patient/TWO is not known"));
}
// Read in wrong Partition
addReadPartition(2);
try {
myPatientDao.read(patientId1, mySrd).getIdElement().toUnqualifiedVersionless();
fail();
} catch (ResourceNotFoundException e) {
assertThat(e.getMessage(), matchesPattern("Resource Patient/ONE is not known"));
}
// Read in correct Partition
addReadPartition(2);
IdType gotId2 = myPatientDao.read(patientId2, mySrd).getIdElement().toUnqualifiedVersionless();
assertEquals(patientId2, gotId2);
}
@Test
@ -1152,7 +1183,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadPartition(1);
SearchParameterMap map = SearchParameterMap.newSynchronous(Patient.SP_RES_ID, new TokenParam(patientId1.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(1, searchOutcome.size());
IIdType gotId1 = searchOutcome.getResources(0,1).get(0).getIdElement().toUnqualifiedVersionless();
assertEquals(patientId1, gotId1);
@ -1170,7 +1201,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadPartition(1);
SearchParameterMap map = SearchParameterMap.newSynchronous(Patient.SP_RES_ID, new TokenParam(patientIdNull.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(0, searchOutcome.size());
}
@ -1179,7 +1210,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadPartition(1);
SearchParameterMap map = SearchParameterMap.newSynchronous(Patient.SP_RES_ID, new TokenParam(patientId2.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(0, searchOutcome.size());
}
@ -1204,7 +1235,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = SearchParameterMap.newSynchronous()
.add(Patient.SP_ACTIVE, new TokenParam("true"))
.add(Patient.SP_RES_ID, new TokenParam(patientId1.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(1, searchOutcome.size());
IIdType gotId1 = searchOutcome.getResources(0,1).get(0).getIdElement().toUnqualifiedVersionless();
assertEquals(patientId1, gotId1);
@ -1224,7 +1255,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = SearchParameterMap.newSynchronous()
.add(Patient.SP_ACTIVE, new TokenParam("true"))
.add(Patient.SP_RES_ID, new TokenParam(patientIdNull.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(0, searchOutcome.size());
}
@ -1235,7 +1266,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = SearchParameterMap.newSynchronous()
.add(Patient.SP_ACTIVE, new TokenParam("true"))
.add(Patient.SP_RES_ID, new TokenParam(patientId2.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(0, searchOutcome.size());
}
@ -1261,7 +1292,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadPartition(1);
SearchParameterMap map = SearchParameterMap.newSynchronous(Patient.SP_RES_ID, new TokenParam(patientId1.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(1, searchOutcome.size());
IIdType gotId1 = searchOutcome.getResources(0,1).get(0).getIdElement().toUnqualifiedVersionless();
assertEquals(patientId1, gotId1);
@ -1279,7 +1310,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadPartition(1);
SearchParameterMap map = SearchParameterMap.newSynchronous(Patient.SP_RES_ID, new TokenParam(patientIdNull.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(0, searchOutcome.size());
}
@ -1288,7 +1319,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadPartition(1);
SearchParameterMap map = SearchParameterMap.newSynchronous(Patient.SP_RES_ID, new TokenParam(patientId2.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(0, searchOutcome.size());
}
@ -1316,7 +1347,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = SearchParameterMap.newSynchronous()
.add(Patient.SP_ACTIVE, new TokenParam("true"))
.add(Patient.SP_RES_ID, new TokenParam(patientId1.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(1, searchOutcome.size());
IIdType gotId1 = searchOutcome.getResources(0,1).get(0).getIdElement().toUnqualifiedVersionless();
assertEquals(patientId1, gotId1);
@ -1341,7 +1372,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = SearchParameterMap.newSynchronous()
.add(Patient.SP_ACTIVE, new TokenParam("true"))
.add(Patient.SP_RES_ID, new TokenParam(patientIdNull.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(0, searchOutcome.size());
}
@ -1352,7 +1383,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = SearchParameterMap.newSynchronous()
.add(Patient.SP_ACTIVE, new TokenParam("true"))
.add(Patient.SP_RES_ID, new TokenParam(patientId2.toUnqualifiedVersionless().getValue()));
IBundleProvider searchOutcome = myPatientDao.search(map);
IBundleProvider searchOutcome = myPatientDao.search(map, mySrd);
assertEquals(0, searchOutcome.size());
}
@ -1376,7 +1407,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_ACTIVE, new StringParam().setMissing(true));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -1393,7 +1424,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_FAMILY, new StringParam().setMissing(false));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -1418,7 +1449,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_ACTIVE, new StringParam().setMissing(true));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -1435,7 +1466,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_FAMILY, new StringParam().setMissing(false));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -1459,7 +1490,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_ACTIVE, new StringParam().setMissing(true));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull));
@ -1476,7 +1507,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_FAMILY, new StringParam().setMissing(false));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull));
@ -1502,7 +1533,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_GENERAL_PRACTITIONER, new StringParam().setMissing(true));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -1529,7 +1560,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_GENERAL_PRACTITIONER, new StringParam().setMissing(true));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -1557,7 +1588,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_GENERAL_PRACTITIONER, new StringParam().setMissing(true));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -1583,7 +1614,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_GENERAL_PRACTITIONER, new StringParam().setMissing(true));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdDefault));
@ -1608,7 +1639,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
myCaptureQueriesListener.clear();
SearchParameterMap map = new SearchParameterMap();
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -1628,7 +1659,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
myCaptureQueriesListener.clear();
SearchParameterMap map = new SearchParameterMap();
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -1649,7 +1680,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
myCaptureQueriesListener.clear();
SearchParameterMap map = new SearchParameterMap();
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, Matchers.contains(patientId1, patientId2));
@ -1670,7 +1701,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
myCaptureQueriesListener.clear();
SearchParameterMap map = new SearchParameterMap();
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids.toString(), ids, Matchers.containsInAnyOrder(patientIdNull, patientId2));
@ -1698,7 +1729,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateParam("2020-04-20"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -1714,7 +1745,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateOrListParam().addOr(new DateParam("2020-04-20")).addOr(new DateParam("2020-04-22")));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -1730,7 +1761,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateAndListParam().addAnd(new DateOrListParam().addOr(new DateParam("2020"))).addAnd(new DateOrListParam().addOr(new DateParam("2020-04-20"))));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -1746,7 +1777,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateRangeParam(new DateParam("2020-01-01"), new DateParam("2020-04-25")));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -1778,7 +1809,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map.add(Patient.SP_BIRTHDATE, new DateParam("2020-04-20"));
map.setLoadSynchronous(true);
myCaptureQueriesListener.clear();
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -1795,7 +1826,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateOrListParam().addOr(new DateParam("2020-04-20")).addOr(new DateParam("2020-04-22")));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -1811,7 +1842,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateAndListParam().addAnd(new DateOrListParam().addOr(new DateParam("2020"))).addAnd(new DateOrListParam().addOr(new DateParam("2020-04-20"))));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -1827,7 +1858,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateRangeParam(new DateParam("2020-01-01"), new DateParam("2020-04-25")));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -1857,7 +1888,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateParam("2020-04-20"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull));
@ -1873,7 +1904,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateOrListParam().addOr(new DateParam("2020-04-20")).addOr(new DateParam("2020-04-22")));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull));
@ -1889,7 +1920,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateAndListParam().addAnd(new DateOrListParam().addOr(new DateParam("2020"))).addAnd(new DateOrListParam().addOr(new DateParam("2020-04-20"))));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull));
@ -1905,7 +1936,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateRangeParam(new DateParam("2020-01-01"), new DateParam("2020-04-25")));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull));
@ -1923,14 +1954,14 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
Organization org = new Organization();
org.setId("ORG");
org.setName("ORG");
myOrganizationDao.update(org);
myOrganizationDao.update(org, mySrd);
addReadPartition(1);
addCreatePartition(1, null);
Practitioner practitioner = new Practitioner();
practitioner.setId("PRACT");
practitioner.addName().setFamily("PRACT");
myPractitionerDao.update(practitioner);
myPractitionerDao.update(practitioner, mySrd);
addReadPartition(1);
addCreatePartition(1, null);
@ -1938,7 +1969,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
role.setId("ROLE");
role.getPractitioner().setReference("Practitioner/PRACT");
role.getOrganization().setReference("Organization/ORG");
myPractitionerRoleDao.update(role);
myPractitionerRoleDao.update(role, mySrd);
addReadPartition(1);
SearchParameterMap params = SearchParameterMap.newSynchronous();
@ -1946,7 +1977,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
value.addAnd(new HasOrListParam().addOr(new HasParam("PractitionerRole", "practitioner", "_id", "ROLE")));
params.add("_has", value);
myCaptureQueriesListener.clear();
IBundleProvider outcome = myPractitionerDao.search(params);
IBundleProvider outcome = myPractitionerDao.search(params, mySrd);
myCaptureQueriesListener.logSelectQueriesForCurrentThread(1);
assertEquals(1, outcome.getResources(0, 1).size());
@ -1970,7 +2001,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_FAMILY, new StringParam("FAMILY"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -1992,7 +2023,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_FAMILY, new StringParam("FAMILY"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull));
@ -2016,7 +2047,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_FAMILY, new StringParam("FAMILY"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, contains(patientId1));
@ -2049,7 +2080,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadPartition(1, 2);
myCaptureQueriesListener.clear();
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids.toString(), ids, Matchers.containsInAnyOrder(patientId1, patientId2));
@ -2064,7 +2095,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadPartition(1, null);
myCaptureQueriesListener.clear();
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids.toString(), ids, Matchers.containsInAnyOrder(patientId1, patientIdNull));
@ -2087,7 +2118,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadPartition(1, 2);
try {
myPatientDao.search(map);
myPatientDao.search(map, mySrd);
fail();
} catch (InternalErrorException e) {
assertEquals("Can not search multiple partitions when partitions are included in search hashes", e.getMessage());
@ -2105,7 +2136,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map.add(Patient.SP_FAMILY, new StringParam("FAMILY"));
map.setLoadSynchronous(true);
try {
IBundleProvider value = myPatientDao.search(map);
IBundleProvider value = myPatientDao.search(map, mySrd);
value.size();
fail();
} catch (PreconditionFailedException e) {
@ -2127,7 +2158,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_FAMILY, new StringParam("FAMILY"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull));
@ -2153,7 +2184,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_FAMILY, new StringParam("FAMILY"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, contains(patientId1));
@ -2178,7 +2209,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Constants.PARAM_TAG, new TokenParam("http://system", "code2").setModifier(TokenParamModifier.NOT));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -2195,7 +2226,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map.add(Constants.PARAM_TAG, new TokenParam("http://system", "code2").setModifier(TokenParamModifier.NOT));
map.add(Patient.SP_IDENTIFIER, new TokenParam("http://foo", "bar"));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1));
@ -2220,7 +2251,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Constants.PARAM_TAG, new TokenParam("http://system", "code2").setModifier(TokenParamModifier.NOT));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
String searchSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, true);
@ -2247,7 +2278,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Constants.PARAM_TAG, new TokenParam("http://system", "code2").setModifier(TokenParamModifier.NOT));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -2269,7 +2300,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Constants.PARAM_TAG, new TokenParam("http://system", "code"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -2292,7 +2323,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map.add(Constants.PARAM_TAG, new TokenParam("http://system", "code"));
map.setLoadSynchronous(true);
myCaptureQueriesListener.clear();
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread(0);
assertThat(ids, contains(patientId1));
@ -2320,7 +2351,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Constants.PARAM_TAG, new TokenParam("http://system", "code2").setModifier(TokenParamModifier.NOT));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientIdNull, patientId1, patientId2));
@ -2345,7 +2376,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Constants.PARAM_TAG, new TokenParam("http://system", "code2").setModifier(TokenParamModifier.NOT));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(patientId1));
@ -2367,7 +2398,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateParam("2020-01-01"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, contains(id));
@ -2390,7 +2421,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateParam("2020-01-01"));
map.setLoadSynchronous(true);
IBundleProvider results = myPatientDao.search(map);
IBundleProvider results = myPatientDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, contains(id));
@ -2406,7 +2437,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Patient.SP_BIRTHDATE, new DateParam("2020-01-01"));
map.setLoadSynchronous(true);
results = myPatientDao.search(map);
results = myPatientDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, Matchers.empty());
@ -2425,7 +2456,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Observation.SP_SUBJECT, new ReferenceParam(patientId));
map.setLoadSynchronous(true);
IBundleProvider results = myObservationDao.search(map);
IBundleProvider results = myObservationDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, contains(observationId));
@ -2443,7 +2474,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Observation.SP_SUBJECT, new ReferenceParam(patientId));
map.setLoadSynchronous(true);
results = myObservationDao.search(map);
results = myObservationDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, Matchers.empty());
@ -2463,7 +2494,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Observation.SP_SUBJECT, new ReferenceParam(patientId));
map.setLoadSynchronous(true);
IBundleProvider results = myObservationDao.search(map);
IBundleProvider results = myObservationDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
assertThat(ids, contains(observationId));
@ -2480,7 +2511,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Observation.SP_SUBJECT, new ReferenceParam(patientId));
map.setLoadSynchronous(true);
results = myObservationDao.search(map);
results = myObservationDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, Matchers.empty());
@ -2499,7 +2530,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Observation.SP_SUBJECT, new ReferenceParam(patientId));
map.setLoadSynchronous(true);
IBundleProvider results = myObservationDao.search(map);
IBundleProvider results = myObservationDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, contains(observationId));
@ -2516,7 +2547,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Observation.SP_SUBJECT, new ReferenceParam(patientId));
map.setLoadSynchronous(true);
results = myObservationDao.search(map);
results = myObservationDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, Matchers.empty());
@ -2536,7 +2567,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
SearchParameterMap map = new SearchParameterMap();
map.add(Observation.SP_SUBJECT, new ReferenceParam(patientId));
map.setLoadSynchronous(true);
IBundleProvider results = myObservationDao.search(map);
IBundleProvider results = myObservationDao.search(map, mySrd);
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
String searchSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, true);
@ -2552,7 +2583,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
map = new SearchParameterMap();
map.add(Observation.SP_SUBJECT, new ReferenceParam(patientId));
map.setLoadSynchronous(true);
results = myObservationDao.search(map);
results = myObservationDao.search(map, mySrd);
ids = toUnqualifiedVersionlessIds(results);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertThat(ids, Matchers.empty());
@ -2565,10 +2596,10 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
addReadAllPartitions();
Patient p = new Patient();
p.setId(patientId.toUnqualifiedVersionless());
p.setGender(Enumerations.AdministrativeGender.MALE);
myPatientDao.update(p);
Patient patient = new Patient();
patient.setId(patientId.toUnqualifiedVersionless());
patient.setGender(Enumerations.AdministrativeGender.MALE);
myPatientDao.update(patient, mySrd);
}
@Test
@ -2577,10 +2608,10 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
// Update the patient
addReadPartition(myPartitionId);
Patient p = new Patient();
p.setActive(false);
p.setId(id);
myPatientDao.update(p);
Patient patient = new Patient();
patient.setActive(false);
patient.setId(id);
myPatientDao.update(patient, mySrd);
addReadPartition(1);
myCaptureQueriesListener.clear();
@ -2623,7 +2654,7 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
Patient p = new Patient();
p.setActive(false);
p.setId(id);
myPatientDao.update(p);
myPatientDao.update(p, mySrd);
addReadPartition(2);
try {
@ -2640,10 +2671,10 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
// Update the patient
addReadDefaultPartition();
Patient p = new Patient();
p.setActive(false);
p.setId(id);
myPatientDao.update(p);
Patient patient = new Patient();
patient.setActive(false);
patient.setId(id);
myPatientDao.update(patient, mySrd);
addReadDefaultPartition();
myCaptureQueriesListener.clear();
@ -2681,10 +2712,10 @@ public class PartitioningSqlR4Test extends BaseJpaR4SystemTest {
// Update the patient
addReadPartition(myPartitionId);
Patient p = new Patient();
p.setActive(false);
p.setId(id);
myPatientDao.update(p);
Patient patient = new Patient();
patient.setActive(false);
patient.setId(id);
myPatientDao.update(patient, mySrd);
addReadAllPartitions();
myCaptureQueriesListener.clear();

View File

@ -67,11 +67,8 @@ public class PartitioningInterceptorR4Test extends BaseJpaR4SystemTest {
myDaoConfig.setIndexMissingFields(new DaoConfig().getIndexMissingFields());
}
@Override
@BeforeEach
public void before() throws ServletException {
super.before();
myPartitionSettings.setPartitioningEnabled(true);
myPartitionInterceptor = new MyWriteInterceptor();

View File

@ -39,7 +39,8 @@ public class JpaInterceptorBroadcaster {
retVal = theInterceptorBroadcaster.callHooks(thePointcut, theParams);
}
if (theRequestDetails != null && retVal) {
theRequestDetails.getInterceptorBroadcaster().callHooks(thePointcut, theParams);
IInterceptorBroadcaster interceptorBroadcaster = theRequestDetails.getInterceptorBroadcaster();
interceptorBroadcaster.callHooks(thePointcut, theParams);
}
return retVal;
}
@ -54,7 +55,8 @@ public class JpaInterceptorBroadcaster {
retVal = theInterceptorBroadcaster.callHooksAndReturnObject(thePointcut, theParams);
}
if (theRequestDetails != null && retVal == null) {
retVal = theRequestDetails.getInterceptorBroadcaster().callHooksAndReturnObject(thePointcut, theParams);
IInterceptorBroadcaster interceptorBroadcaster = theRequestDetails.getInterceptorBroadcaster();
retVal = interceptorBroadcaster.callHooksAndReturnObject(thePointcut, theParams);
}
return retVal;
}

View File

@ -175,7 +175,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
* Constructor
*/
public RestfulServer(FhirContext theCtx) {
this(theCtx, new InterceptorService());
this(theCtx, new InterceptorService("RestfulServer"));
}
public RestfulServer(FhirContext theCtx, IInterceptorService theInterceptorService) {