This commit is contained in:
James Agnew 2024-11-15 16:08:18 -05:00
parent 2aadbec500
commit 983f4b6168
2 changed files with 14 additions and 9 deletions

View File

@ -1,10 +1,5 @@
package ca.uhn.fhir.jpa.mdm.interceptor; package ca.uhn.fhir.jpa.mdm.interceptor;
import ca.uhn.fhir.interceptor.api.Hook;
import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor;
import ca.uhn.fhir.interceptor.api.IPointcut;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test;
import ca.uhn.fhir.jpa.mdm.helper.MdmHelperConfig; import ca.uhn.fhir.jpa.mdm.helper.MdmHelperConfig;
import ca.uhn.fhir.jpa.mdm.helper.MdmHelperR4; import ca.uhn.fhir.jpa.mdm.helper.MdmHelperR4;
@ -12,7 +7,6 @@ import ca.uhn.fhir.jpa.mdm.helper.MdmLinkHelper;
import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMLinkResults; import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMLinkResults;
import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMState; import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMState;
import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.dao.JpaPid;
import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.mdm.interceptor.MdmReadVirtualizationInterceptor; import ca.uhn.fhir.mdm.interceptor.MdmReadVirtualizationInterceptor;
import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.api.server.IBundleProvider;
@ -34,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -166,7 +159,7 @@ public class MdmReadVirtualizationInterceptorTest extends BaseMdmR4Test {
registerVirtualizationInterceptor(); registerVirtualizationInterceptor();
// Test // Test
SearchParameterMap params = SearchParameterMap.newSynchronous(); SearchParameterMap params = new SearchParameterMap();
params.addRevInclude(IBaseResource.INCLUDE_ALL); params.addRevInclude(IBaseResource.INCLUDE_ALL);
IBundleProvider outcome = myPatientDao.search(params, mySrd); IBundleProvider outcome = myPatientDao.search(params, mySrd);

View File

@ -76,6 +76,9 @@ import java.util.Set;
*/ */
public class MdmReadVirtualizationInterceptor<P extends IResourcePersistentId<?>> { public class MdmReadVirtualizationInterceptor<P extends IResourcePersistentId<?>> {
public static final String CURRENTLY_PROCESSING_FLAG =
MdmReadVirtualizationInterceptor.class.getName() + "-CURRENTLY-PROCESSING";
@Autowired @Autowired
private FhirContext myFhirContext; private FhirContext myFhirContext;
@ -101,6 +104,9 @@ public class MdmReadVirtualizationInterceptor<P extends IResourcePersistentId<?>
@Hook(Pointcut.STORAGE_PRESHOW_RESOURCES) @Hook(Pointcut.STORAGE_PRESHOW_RESOURCES)
public void preShowResources(RequestDetails theRequestDetails, IPreResourceShowDetails theDetails) { public void preShowResources(RequestDetails theRequestDetails, IPreResourceShowDetails theDetails) {
if (theRequestDetails.getUserData().get(CURRENTLY_PROCESSING_FLAG) == Boolean.TRUE) {
return;
}
// Gather all the resource IDs we might need to remap // Gather all the resource IDs we might need to remap
ListMultimap<String, Integer> candidateResourceIds = extractRemapCandidateResources(theDetails); ListMultimap<String, Integer> candidateResourceIds = extractRemapCandidateResources(theDetails);
@ -148,8 +154,14 @@ public class MdmReadVirtualizationInterceptor<P extends IResourcePersistentId<?>
// then we'll manually add it // then we'll manually add it
IIdType targetResourceId = newIdType(targetId); IIdType targetResourceId = newIdType(targetId);
IFhirResourceDao<?> dao = myDaoRegistry.getResourceDao(targetResourceId.getResourceType()); IFhirResourceDao<?> dao = myDaoRegistry.getResourceDao(targetResourceId.getResourceType());
IBaseResource goldenResource = dao.read(targetResourceId, theRequestDetails);
theRequestDetails.getUserData().put(CURRENTLY_PROCESSING_FLAG, Boolean.TRUE);
IBaseResource goldenResource;
try {
goldenResource = dao.read(targetResourceId, theRequestDetails);
} finally {
theRequestDetails.getUserData().remove(CURRENTLY_PROCESSING_FLAG);
}
theDetails.setResource(filteredIndex, goldenResource); theDetails.setResource(filteredIndex, goldenResource);
candidateResourceIds.put(targetId, filteredIndex); candidateResourceIds.put(targetId, filteredIndex);
} }