moved to search internal

This commit is contained in:
Melih Aydogdu 2024-05-27 16:06:23 +02:00
parent f9a522e158
commit 38b5b12322
2 changed files with 19 additions and 15 deletions

View File

@ -25,6 +25,7 @@ import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.api.PatchTypeEnum; import ca.uhn.fhir.rest.api.PatchTypeEnum;
@ -588,6 +589,16 @@ public class BundleUtil {
return retVal; return retVal;
} }
public static void setSearchModeMetadata(FhirContext theContext, IBaseBundle theBundle) {
List<SearchBundleEntryParts> searchBundleEntryParts = getSearchBundleEntryParts(theContext, theBundle);
searchBundleEntryParts.forEach(searchBundleEntryPart -> {
IBaseResource resource = searchBundleEntryPart.getResource();
if (resource != null) {
ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put(resource, searchBundleEntryPart.getSearchMode());
}
});
}
private static SearchBundleEntryParts getSearchBundleEntryParts( private static SearchBundleEntryParts getSearchBundleEntryParts(
BaseRuntimeChildDefinition fullUrlChildDef, BaseRuntimeChildDefinition fullUrlChildDef,
BaseRuntimeChildDefinition resourceChildDef, BaseRuntimeChildDefinition resourceChildDef,

View File

@ -132,7 +132,6 @@ import ca.uhn.fhir.util.BundleUtil;
import ca.uhn.fhir.util.ICallable; import ca.uhn.fhir.util.ICallable;
import ca.uhn.fhir.util.ParametersUtil; import ca.uhn.fhir.util.ParametersUtil;
import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.UrlUtil;
import ca.uhn.fhir.util.bundle.SearchBundleEntryParts;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -584,7 +583,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
myLastRequest = theInvocation.asHttpRequest(getServerBase(), theParams, getEncoding(), myPrettyPrint); myLastRequest = theInvocation.asHttpRequest(getServerBase(), theParams, getEncoding(), myPrettyPrint);
} }
Z resp = invokeClient( return invokeClient(
myContext, myContext,
theHandler, theHandler,
theInvocation, theInvocation,
@ -596,18 +595,6 @@ public class GenericClient extends BaseClient implements IGenericClient {
myCacheControlDirective, myCacheControlDirective,
myCustomAcceptHeaderValue, myCustomAcceptHeaderValue,
myCustomHeaderValues); myCustomHeaderValues);
if (resp instanceof IBaseBundle) {
List<SearchBundleEntryParts> searchBundleEntryParts =
BundleUtil.getSearchBundleEntryParts(getFhirContext(), (IBaseBundle) resp);
searchBundleEntryParts.forEach(searchBundleEntryPart -> {
IBaseResource resource = searchBundleEntryPart.getResource();
if (resource != null) {
ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put(resource, searchBundleEntryPart.getSearchMode());
}
});
}
return resp;
} }
protected IBaseResource parseResourceBody(String theResourceBody) { protected IBaseResource parseResourceBody(String theResourceBody) {
@ -2211,7 +2198,13 @@ public class GenericClient extends BaseClient implements IGenericClient {
myContext, myResourceName, params, resourceId, myCompartmentName, mySearchStyle); myContext, myResourceName, params, resourceId, myCompartmentName, mySearchStyle);
} }
return (OUTPUT) invoke(params, binding, invocation); OUTPUT invoke = (OUTPUT) invoke(params, binding, invocation);
if (invoke instanceof IBaseBundle) {
BundleUtil.setSearchModeMetadata(myContext, (IBaseBundle) invoke);
}
return invoke;
} }
@Override @Override