WIP
This commit is contained in:
parent
983f4b6168
commit
e43df9f996
|
@ -9,6 +9,7 @@ import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMState;
|
|||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.mdm.interceptor.MdmReadVirtualizationInterceptor;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||
import ca.uhn.fhir.rest.param.TokenOrListParam;
|
||||
|
@ -34,6 +35,7 @@ import java.util.UUID;
|
|||
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ContextConfiguration(classes = {MdmHelperConfig.class})
|
||||
public class MdmReadVirtualizationInterceptorTest extends BaseMdmR4Test {
|
||||
|
@ -62,6 +64,7 @@ public class MdmReadVirtualizationInterceptorTest extends BaseMdmR4Test {
|
|||
@BeforeEach
|
||||
public void before() throws Exception {
|
||||
super.before();
|
||||
when(mySrd.getRestOperationType()).thenReturn(RestOperationTypeEnum.SEARCH_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -102,11 +102,20 @@ public class MdmReadVirtualizationInterceptor<P extends IResourcePersistentId<?>
|
|||
myMdmSearchExpansionSvc.expandSearch(theRequestDetails, theSearchParameterMap, t -> true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("EnumSwitchStatementWhichMissesCases")
|
||||
@Hook(Pointcut.STORAGE_PRESHOW_RESOURCES)
|
||||
public void preShowResources(RequestDetails theRequestDetails, IPreResourceShowDetails theDetails) {
|
||||
if (theRequestDetails.getUserData().get(CURRENTLY_PROCESSING_FLAG) == Boolean.TRUE) {
|
||||
return;
|
||||
}
|
||||
switch (theRequestDetails.getRestOperationType()) {
|
||||
case SEARCH_TYPE:
|
||||
case SEARCH_SYSTEM:
|
||||
case GET_PAGE:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// Gather all the resource IDs we might need to remap
|
||||
ListMultimap<String, Integer> candidateResourceIds = extractRemapCandidateResources(theDetails);
|
||||
|
|
|
@ -28,6 +28,7 @@ import ca.uhn.fhir.model.api.Include;
|
|||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
@ -72,20 +73,29 @@ public class HapiFhirRepository implements Repository {
|
|||
@Override
|
||||
public <T extends IBaseResource, I extends IIdType> T read(
|
||||
Class<T> theResourceType, I theId, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails).addHeaders(theHeaders).create();
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.READ)
|
||||
.addHeaders(theHeaders)
|
||||
.create();
|
||||
return myDaoRegistry.getResourceDao(theResourceType).read(theId, details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IBaseResource> MethodOutcome create(T theResource, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails).addHeaders(theHeaders).create();
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.CREATE)
|
||||
.addHeaders(theHeaders)
|
||||
.create();
|
||||
return myDaoRegistry.getResourceDao(theResource).create(theResource, details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <I extends IIdType, P extends IBaseParameters> MethodOutcome patch(
|
||||
I theId, P thePatchParameters, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails).addHeaders(theHeaders).create();
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.PATCH)
|
||||
.addHeaders(theHeaders)
|
||||
.create();
|
||||
// TODO update FHIR patchType once FHIRPATCH bug has been fixed
|
||||
return myDaoRegistry
|
||||
.getResourceDao(theId.getResourceType())
|
||||
|
@ -94,7 +104,10 @@ public class HapiFhirRepository implements Repository {
|
|||
|
||||
@Override
|
||||
public <T extends IBaseResource> MethodOutcome update(T theResource, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails).addHeaders(theHeaders).create();
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.UPDATE)
|
||||
.addHeaders(theHeaders)
|
||||
.create();
|
||||
|
||||
return myDaoRegistry.getResourceDao(theResource).update(theResource, details);
|
||||
}
|
||||
|
@ -102,7 +115,10 @@ public class HapiFhirRepository implements Repository {
|
|||
@Override
|
||||
public <T extends IBaseResource, I extends IIdType> MethodOutcome delete(
|
||||
Class<T> theResourceType, I theId, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails).addHeaders(theHeaders).create();
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.DELETE)
|
||||
.addHeaders(theHeaders)
|
||||
.create();
|
||||
|
||||
return myDaoRegistry.getResourceDao(theResourceType).delete(theId, details);
|
||||
}
|
||||
|
@ -113,7 +129,10 @@ public class HapiFhirRepository implements Repository {
|
|||
Class<T> theResourceType,
|
||||
Map<String, List<IQueryParameterType>> theSearchParameters,
|
||||
Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails).addHeaders(theHeaders).create();
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.SEARCH_TYPE)
|
||||
.addHeaders(theHeaders)
|
||||
.create();
|
||||
SearchConverter converter = new SearchConverter();
|
||||
converter.convertParameters(theSearchParameters, fhirContext());
|
||||
details.setParameters(converter.resultParameters);
|
||||
|
@ -183,7 +202,10 @@ public class HapiFhirRepository implements Repository {
|
|||
// repository action"?
|
||||
@Override
|
||||
public <B extends IBaseBundle> B link(Class<B> theBundleType, String theUrl, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails).addHeaders(theHeaders).create();
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.GET_PAGE)
|
||||
.addHeaders(theHeaders)
|
||||
.create();
|
||||
var urlParts = UrlUtil.parseUrl(theUrl);
|
||||
details.setCompleteUrl(theUrl);
|
||||
details.setParameters(UrlUtil.parseQueryStrings(urlParts.getParams()));
|
||||
|
@ -234,13 +256,19 @@ public class HapiFhirRepository implements Repository {
|
|||
if (method == null) {
|
||||
return null;
|
||||
}
|
||||
var details = startWith(myRequestDetails).addHeaders(theHeaders).create();
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.METADATA)
|
||||
.addHeaders(theHeaders)
|
||||
.create();
|
||||
return (C) method.provideCapabilityStatement(myRestfulServer, details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends IBaseBundle> B transaction(B theBundle, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails).addHeaders(theHeaders).create();
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.TRANSACTION)
|
||||
.addHeaders(theHeaders)
|
||||
.create();
|
||||
return (B) myDaoRegistry.getSystemDao().transaction(details, theBundle);
|
||||
}
|
||||
|
||||
|
@ -248,6 +276,7 @@ public class HapiFhirRepository implements Repository {
|
|||
public <R extends IBaseResource, P extends IBaseParameters> R invoke(
|
||||
String theName, P theParameters, Class<R> theReturnType, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.EXTENDED_OPERATION_SERVER)
|
||||
.addHeaders(theHeaders)
|
||||
.setOperation(theName)
|
||||
.setParameters(theParameters)
|
||||
|
@ -260,6 +289,7 @@ public class HapiFhirRepository implements Repository {
|
|||
public <P extends IBaseParameters> MethodOutcome invoke(
|
||||
String theName, P theParameters, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.EXTENDED_OPERATION_SERVER)
|
||||
.addHeaders(theHeaders)
|
||||
.setOperation(theName)
|
||||
.setParameters(theParameters)
|
||||
|
@ -276,6 +306,7 @@ public class HapiFhirRepository implements Repository {
|
|||
Class<R> theReturnType,
|
||||
Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.EXTENDED_OPERATION_SERVER)
|
||||
.addHeaders(theHeaders)
|
||||
.setOperation(theName)
|
||||
.setResourceType(theResourceType.getSimpleName())
|
||||
|
@ -289,6 +320,7 @@ public class HapiFhirRepository implements Repository {
|
|||
public <P extends IBaseParameters, T extends IBaseResource> MethodOutcome invoke(
|
||||
Class<T> theResourceType, String theName, P theParameters, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.EXTENDED_OPERATION_SERVER)
|
||||
.addHeaders(theHeaders)
|
||||
.setOperation(theName)
|
||||
.setResourceType(theResourceType.getSimpleName())
|
||||
|
@ -302,6 +334,7 @@ public class HapiFhirRepository implements Repository {
|
|||
public <R extends IBaseResource, P extends IBaseParameters, I extends IIdType> R invoke(
|
||||
I theId, String theName, P theParameters, Class<R> theReturnType, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.EXTENDED_OPERATION_SERVER)
|
||||
.addHeaders(theHeaders)
|
||||
.setOperation(theName)
|
||||
.setResourceType(theId.getResourceType())
|
||||
|
@ -316,6 +349,7 @@ public class HapiFhirRepository implements Repository {
|
|||
public <P extends IBaseParameters, I extends IIdType> MethodOutcome invoke(
|
||||
I theId, String theName, P theParameters, Map<String, String> theHeaders) {
|
||||
var details = startWith(myRequestDetails)
|
||||
.setAction(RestOperationTypeEnum.EXTENDED_OPERATION_SERVER)
|
||||
.addHeaders(theHeaders)
|
||||
.setOperation(theName)
|
||||
.setResourceType(theId.getResourceType())
|
||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.cr.repo;
|
|||
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
|
||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||
|
@ -56,6 +57,11 @@ class RequestDetailsCloner {
|
|||
myDetails = theDetails;
|
||||
}
|
||||
|
||||
DetailsBuilder setAction(RestOperationTypeEnum theRestOperationType) {
|
||||
myDetails.setRestOperationType(theRestOperationType);
|
||||
return this;
|
||||
}
|
||||
|
||||
DetailsBuilder addHeaders(Map<String, String> theHeaders) {
|
||||
if (theHeaders != null) {
|
||||
for (var entry : theHeaders.entrySet()) {
|
||||
|
|
Loading…
Reference in New Issue