Work on seed bundles
This commit is contained in:
parent
ed2e62752e
commit
7cde945281
|
@ -9,6 +9,7 @@ import ca.uhn.fhir.model.api.IQueryParameterType;
|
|||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.IntegerDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.rest.param.binder.QueryParameterAndBinder;
|
||||
|
@ -386,4 +387,10 @@ public class ParameterUtil {
|
|||
return b.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the value is :iterate or :recurse (the former name of :iterate) for an _include parameter
|
||||
*/
|
||||
public static boolean isIncludeIterate(String theQualifier) {
|
||||
return Constants.PARAM_INCLUDE_QUALIFIER_RECURSE.equals(theQualifier) || Constants.PARAM_INCLUDE_QUALIFIER_ITERATE.equals(theQualifier);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1018,6 +1018,7 @@ public class RestHookTestR4Test extends BaseSubscriptionsR4Test {
|
|||
{
|
||||
Subscription subscription = newSubscription("Observation?", "application/json");
|
||||
subscription.addExtension(JpaConstants.EXT_SUBSCRIPTION_PAYLOAD_SEARCH_RESULT, new StringType("Observation?_id=${matched_resource_id}&_include=*"));
|
||||
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(subscription));
|
||||
MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();
|
||||
mySubscriptionIds.add(methodOutcome.getId());
|
||||
waitForActivatedSubscriptionCount(1);
|
||||
|
|
|
@ -26,6 +26,7 @@ import ca.uhn.fhir.context.RuntimeSearchParam;
|
|||
import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
|
@ -50,7 +51,7 @@ public class MatchUrlService {
|
|||
@Autowired
|
||||
private ISearchParamRegistry mySearchParamRegistry;
|
||||
|
||||
public SearchParameterMap translateMatchUrl(String theMatchUrl, RuntimeResourceDefinition theResourceDefinition) {
|
||||
public SearchParameterMap translateMatchUrl(String theMatchUrl, RuntimeResourceDefinition theResourceDefinition, Flag... theFlags) {
|
||||
SearchParameterMap paramMap = new SearchParameterMap();
|
||||
List<NameValuePair> parameters = translateMatchUrl(theMatchUrl);
|
||||
|
||||
|
@ -79,6 +80,13 @@ public class MatchUrlService {
|
|||
|
||||
for (String nextParamName : nameToParamLists.keySet()) {
|
||||
List<QualifiedParamList> paramList = nameToParamLists.get(nextParamName);
|
||||
|
||||
if (theFlags != null && theFlags.length > 0) {
|
||||
for (Flag next : theFlags) {
|
||||
next.process(nextParamName, paramList, paramMap);
|
||||
}
|
||||
}
|
||||
|
||||
if (Constants.PARAM_LASTUPDATED.equals(nextParamName)) {
|
||||
if (paramList != null && paramList.size() > 0) {
|
||||
if (paramList.size() > 2) {
|
||||
|
@ -131,8 +139,8 @@ public class MatchUrlService {
|
|||
return UrlUtil.translateMatchUrl(theMatchUrl);
|
||||
}
|
||||
|
||||
private IQueryParameterAnd newInstanceAnd(String theParamType) {
|
||||
Class<? extends IQueryParameterAnd> clazz = ResourceMetaParams.RESOURCE_META_AND_PARAMS.get(theParamType);
|
||||
private IQueryParameterAnd<?> newInstanceAnd(String theParamType) {
|
||||
Class<? extends IQueryParameterAnd<?>> clazz = ResourceMetaParams.RESOURCE_META_AND_PARAMS.get(theParamType);
|
||||
return ReflectionUtil.newInstance(clazz);
|
||||
}
|
||||
|
||||
|
@ -140,4 +148,44 @@ public class MatchUrlService {
|
|||
Class<? extends IQueryParameterType> clazz = ResourceMetaParams.RESOURCE_META_PARAMS.get(theParamType);
|
||||
return ReflectionUtil.newInstance(clazz);
|
||||
}
|
||||
|
||||
public abstract static class Flag {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Flag() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
abstract void process(String theParamName, List<QualifiedParamList> theValues, SearchParameterMap theMapToPopulate);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that the parser should process _include and _revinclude (by default these are not handled)
|
||||
*/
|
||||
public static Flag processIncludes() {
|
||||
return new Flag() {
|
||||
|
||||
@Override
|
||||
void process(String theParamName, List<QualifiedParamList> theValues, SearchParameterMap theMapToPopulate) {
|
||||
if (Constants.PARAM_INCLUDE.equals(theParamName)) {
|
||||
for (QualifiedParamList nextQualifiedList : theValues) {
|
||||
for (String nextValue : nextQualifiedList) {
|
||||
theMapToPopulate.addInclude(new Include(nextValue, ParameterUtil.isIncludeIterate(nextQualifiedList.getQualifier())));
|
||||
}
|
||||
}
|
||||
} else if (Constants.PARAM_REVINCLUDE.equals(theParamName)) {
|
||||
for (QualifiedParamList nextQualifiedList : theValues) {
|
||||
for (String nextValue : nextQualifiedList) {
|
||||
theMapToPopulate.addInclude(new Include(nextValue, ParameterUtil.isIncludeIterate(nextQualifiedList.getQualifier())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public class SubscriptionDeliveringRestHookSubscriber extends BaseSubscriptionDe
|
|||
Map<String, String> valueMap = new HashMap<>(1);
|
||||
valueMap.put("matched_resource_id", thePayloadResource.getIdElement().toUnqualifiedVersionless().getValue());
|
||||
payloadUrl = new StringSubstitutor(valueMap).replace(payloadUrl);
|
||||
SearchParameterMap payloadSearchMap = myMatchUrlService.translateMatchUrl(payloadUrl, resourceDefinition);
|
||||
SearchParameterMap payloadSearchMap = myMatchUrlService.translateMatchUrl(payloadUrl, resourceDefinition, MatchUrlService.processIncludes());
|
||||
payloadSearchMap.setLoadSynchronous(true);
|
||||
|
||||
IBundleProvider searchResults = dao.search(payloadSearchMap);
|
||||
|
|
|
@ -20,14 +20,6 @@ package ca.uhn.fhir.rest.server.method;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
|
@ -35,9 +27,18 @@ import ca.uhn.fhir.rest.annotation.IncludeParam;
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.rest.param.ParameterUtil;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
class IncludeParameter extends BaseQueryParameter {
|
||||
|
||||
private Set<String> myAllow;
|
||||
|
@ -142,7 +143,7 @@ class IncludeParameter extends BaseQueryParameter {
|
|||
}
|
||||
|
||||
String qualifier = nextParamList.getQualifier();
|
||||
boolean recurse = Constants.PARAM_INCLUDE_QUALIFIER_RECURSE.equals(qualifier) || Constants.PARAM_INCLUDE_QUALIFIER_ITERATE.equals(qualifier);
|
||||
boolean iterate = ParameterUtil.isIncludeIterate(qualifier);
|
||||
|
||||
String value = nextParamList.get(0);
|
||||
if (myAllow != null && !myAllow.isEmpty()) {
|
||||
|
@ -157,10 +158,10 @@ class IncludeParameter extends BaseQueryParameter {
|
|||
if (mySpecType == String.class) {
|
||||
return value;
|
||||
}
|
||||
return new Include(value, recurse);
|
||||
return new Include(value, iterate);
|
||||
}
|
||||
|
||||
retValCollection.add(new Include(value, recurse));
|
||||
retValCollection.add(new Include(value, iterate));
|
||||
}
|
||||
|
||||
return retValCollection;
|
||||
|
|
Loading…
Reference in New Issue