/** * This is a utility method intended provided to help the JPA module. */ public static IQueryParameterAnd<?> parseQueryParams(FhirContext theContext, RuntimeSearchParam theParamDef, String theUnqualifiedParamName, List<QualifiedParamList> theParameters) { RestSearchParameterTypeEnum paramType = theParamDef.getParamType(); return parseQueryParams(theContext, paramType, theUnqualifiedParamName, theParameters); }
private List<String> toCompositeOfTypes(List<RuntimeSearchParam> theCompositeOf) { if (theCompositeOf == null) { return null; } ArrayList<String> retVal = new ArrayList<String>(); for (RuntimeSearchParam next : theCompositeOf) { String type = next.getParamType().getCode(); type = WordUtils.capitalize(type); retVal.add(type); } return retVal; }
private void extractResourceLinks(ResourceIndexedSearchParams theParams, ResourceTable theEntity, IBaseResource theResource, Date theUpdateTime, IResourceLinkResolver theResourceLinkResolver, String theResourceType, RuntimeSearchParam nextSpDef, boolean theFailOnInvalidReference) { if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.REFERENCE) { return; } String nextPathsUnsplit = nextSpDef.getPath(); if (isBlank(nextPathsUnsplit)) { return; } boolean multiType = false; if (nextPathsUnsplit.endsWith("[x]")) { multiType = true; } List<PathAndRef> refs = mySearchParamExtractor.extractResourceLinks(theResource, nextSpDef); for (PathAndRef nextPathAndRef : refs) { extractResourceLinks(theParams, theEntity, theUpdateTime, theResourceLinkResolver, theResourceType, nextSpDef, nextPathsUnsplit, multiType, nextPathAndRef, theFailOnInvalidReference); } }
switch (paramDef.getParamType()) { case TOKEN: resourceParams = tokenParams;
private SubscriptionMatchResult matchResourceParam(String theParamName, List<List<? extends IQueryParameterType>> theAndOrParams, ResourceIndexedSearchParams theSearchParams, String theResourceName, RuntimeSearchParam theParamDef) { if (theParamDef != null) { switch (theParamDef.getParamType()) { case QUANTITY: case TOKEN: case STRING: case NUMBER: case URI: case DATE: case REFERENCE: if (theSearchParams == null) { return SubscriptionMatchResult.successfulMatch(); } else { return SubscriptionMatchResult.fromBoolean(theAndOrParams.stream().anyMatch(nextAnd -> matchParams(theResourceName, theParamName, theParamDef, nextAnd, theSearchParams))); } case COMPOSITE: case HAS: case SPECIAL: default: return SubscriptionMatchResult.unsupportedFromParameterAndReason(theParamName, SubscriptionMatchResult.PARAM); } } else { if (Constants.PARAM_CONTENT.equals(theParamName) || Constants.PARAM_TEXT.equals(theParamName)) { return SubscriptionMatchResult.unsupportedFromParameterAndReason(theParamName, SubscriptionMatchResult.PARAM); } else { throw new InvalidRequestException("Unknown search parameter " + theParamName + " for resource type " + theResourceName); } } }
private IQueryParameterType mapReferenceChainToRawParamType(String remainingChain, RuntimeSearchParam param, String theParamName, String qualifier, Class<? extends IBaseResource> nextType, String chain, boolean isMeta, String resourceId) { IQueryParameterType chainValue; if (remainingChain != null) { if (param == null || param.getParamType() != RestSearchParameterTypeEnum.REFERENCE) { ourLog.debug("Type {} parameter {} is not a reference, can not chain {}", nextType.getSimpleName(), chain, remainingChain); return null; } chainValue = new ReferenceParam(); chainValue.setValueAsQueryToken(myContext, theParamName, qualifier, resourceId); ((ReferenceParam) chainValue).setChain(remainingChain); } else if (isMeta) { IQueryParameterType type = myMatchUrlService.newInstanceType(chain); type.setValueAsQueryToken(myContext, theParamName, qualifier, resourceId); chainValue = type; } else { chainValue = toParameterType(param, qualifier, resourceId); } return chainValue; }
@PostConstruct public void postConstruct() { RuntimeResourceDefinition def = getContext().getResourceDefinition(myResourceType); myResourceName = def.getName(); if (mySecondaryPrimaryKeyParamName != null) { RuntimeSearchParam sp = mySearchParamRegistry.getSearchParamByName(def, mySecondaryPrimaryKeyParamName); if (sp == null) { throw new ConfigurationException("Unknown search param on resource[" + myResourceName + "] for secondary key[" + mySecondaryPrimaryKeyParamName + "]"); } if (sp.getParamType() != RestSearchParameterTypeEnum.TOKEN) { throw new ConfigurationException("Search param on resource[" + myResourceName + "] for secondary key[" + mySecondaryPrimaryKeyParamName + "] is not a token type, only token is supported"); } } }
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.URI) { continue;
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.URI) { continue;
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.URI) { continue;
private IQueryParameterType toParameterType(RuntimeSearchParam theParam) { IQueryParameterType qp; switch (theParam.getParamType()) { case DATE: qp = new DateParam(); case HAS: default: throw new InternalErrorException("Don't know how to convert param type: " + theParam.getParamType());
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.QUANTITY) { continue;
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.QUANTITY) { continue;
for (Map.Entry<String, RuntimeSearchParam> nextEntry : activeSearchParams) { String nextParamName = nextEntry.getKey(); if (nextEntry.getValue().getParamType() == type) { boolean haveParam = false; for (BaseResourceIndexedSearchParam nextParam : paramCollection) {
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.QUANTITY) { continue;
private Predicate createCompositeParamPart(String theResourceName, Root<ResourceTable> theRoot, RuntimeSearchParam theParam, IQueryParameterType leftValue) { Predicate retVal = null; switch (theParam.getParamType()) { case STRING: { From<ResourceIndexedSearchParamString, ResourceIndexedSearchParamString> stringJoin = theRoot.join("myParamsString", JoinType.INNER); throw new InvalidRequestException("Don't know how to handle composite parameter with type of " + theParam.getParamType());
if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.DATE) { continue;
switch (searchParam.getParamType()) { case NUMBER: param = new NumberParam(value);
confSp.setDocumentation(runtimeSp.getDescription()); confSp.setDefinition(runtimeSp.getUri()); switch (runtimeSp.getParamType()) { case COMPOSITE: confSp.setType(SearchParamType.COMPOSITE);
public void parse() { for (String nextResourceName : myResourceNames) { RuntimeResourceDefinition def = getCtx().getResourceDefinition(nextResourceName); Resource resource = new Resource(); resource.setName(def.getName()); resource.setElementName(def.getName()); addResource(resource); for (RuntimeSearchParam nextSearchParam : def.getSearchParams()) { SearchParameter param = new SearchParameter(getVersion(), def.getName()); param.setName(nextSearchParam.getName()); param.setDescription(nextSearchParam.getDescription()); param.setCompositeOf(toCompositeOfStrings(nextSearchParam.getCompositeOf())); param.setCompositeTypes(toCompositeOfTypes(nextSearchParam.getCompositeOf())); param.setPath(nextSearchParam.getPath()); param.setType(nextSearchParam.getParamType().getCode()); resource.addSearchParameter(param); } } }