if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.URI) { continue; String nextPath = nextSpDef.getPath(); if (isBlank(nextPath)) { continue; String resourceName = nextSpDef.getName(); boolean multiType = false; if (nextPath.endsWith("[x]")) {
private IQueryParameterType toParameterType(RuntimeSearchParam theParam) { IQueryParameterType qp; switch (theParam.getParamType()) { case DATE: qp = new DateParam(); break; case COMPOSITE: List<RuntimeSearchParam> compositeOf = theParam.getCompositeOf(); if (compositeOf.size() != 2) { throw new InternalErrorException("Parameter " + theParam.getName() + " has " + compositeOf.size() + " composite parts. Don't know how handlt this."); case HAS: default: throw new InternalErrorException("Don't know how to convert param type: " + theParam.getParamType());
@Override public boolean equals(Object theO) { if (this == theO) return true; if (theO == null || getClass() != theO.getClass()) return false; RuntimeSearchParam that = (RuntimeSearchParam) theO; return new EqualsBuilder() .append(getId(), that.getId()) .append(getName(), that.getName()) .append(getPath(), that.getPath()) .append(getUri(), that.getUri()) .isEquals(); }
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); } }
if (next.getProvidesMembershipInCompartments() != null) { for (String nextCompartment : next.getProvidesMembershipInCompartments()) { if (!compartmentNameToSearchParams.containsKey(nextCompartment)) { compartmentNameToSearchParams.put(nextCompartment, new ArrayList<>()); String nextPath = massagePathForCompartmentSimilarity(next.getPath()); for (RuntimeSearchParam nextAlternate : searchParams) { String nextAlternatePath = massagePathForCompartmentSimilarity(nextAlternate.getPath()); if (nextAlternatePath.equals(nextPath)) { if (!nextAlternate.getName().equals(next.getName())) { searchParamsForCompartment.add(nextAlternate);
CapabilityStatementRestResourceSearchParamComponent confSp = nextResource.addSearchParam(); confSp.setName(runtimeSp.getName()); 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); } } }
Collection<ResourceLink> linksForCompositePart = null; Collection<String> linksForCompositePartWantPaths = null; switch (nextCompositeOf.getParamType()) { case NUMBER: paramsListForCompositePart = theParams.numberParams; linksForCompositePart = theParams.links; linksForCompositePartWantPaths = new HashSet<>(); linksForCompositePartWantPaths.addAll(nextCompositeOf.getPathsSplit()); break; case QUANTITY: partsChoices.add(nextChoicesList); String key = UrlUtil.escapeUrlParam(nextCompositeOf.getName()); if (paramsListForCompositePart != null) { for (BaseResourceIndexedSearchParam nextParam : paramsListForCompositePart) { if (nextParam.getParamName().equals(nextCompositeOf.getName())) { IQueryParameterType nextParamAsClientParam = nextParam.toQueryParameterType(); String value = nextParamAsClientParam.getValueAsQueryToken(myContext);
String nextParamName = nextParameter.getName(); String nextParamDescription = nextParameter.getDescription(); RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription(); param.getTypeElement().setValue(nextParameter.getParamType().getCode());
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); retVal = createPredicateString(leftValue, theResourceName, theParam.getName(), myBuilder, stringJoin); break; retVal = createPredicateToken(leftValue, theResourceName, theParam.getName(), myBuilder, tokenJoin); break; retVal = createPredicateDate(leftValue, theResourceName, theParam.getName(), myBuilder, dateJoin); break; retVal = createPredicateQuantity(leftValue, theResourceName, theParam.getName(), myBuilder, dateJoin); break; throw new InvalidRequestException("Don't know how to handle composite parameter with type of " + theParam.getParamType());
/** * 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); }
RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription();
for (RuntimeSearchParam nextCandidate : nextSearchParamsForResourceName) { if (nextCandidate.getId() != null) { idToRuntimeSearchParam.put(nextCandidate.getId().toUnqualifiedVersionless().getValue(), nextCandidate); if (componentTarget != null) { next.getCompositeOf().add(componentTarget); paramNames.add(componentTarget.getName()); } else { ourLog.warn("Search parameter {} refers to unknown component {}", next.getId().toUnqualifiedVersionless().getValue(), nextRef);
for (RuntimeSearchParam nextParam : nextBuiltInEntry.getValue().values()) { String nextResourceName = nextBuiltInEntry.getKey(); getSearchParamMap(searchParams, nextResourceName).put(nextParam.getName(), nextParam); String name = runtimeSp.getName(); if (myModelConfig.isDefaultSearchParamsCanBeOverridden() || !searchParamMap.containsKey(name)) { searchParamMap.put(name, runtimeSp); for (Map.Entry<String, Map<String, RuntimeSearchParam>> nextEntry : searchParams.entrySet()) { for (RuntimeSearchParam nextSp : nextEntry.getValue().values()) { String nextName = nextSp.getName(); if (nextSp.getStatus() != RuntimeSearchParam.RuntimeSearchParamStatusEnum.ACTIVE) { nextSp = null;
RuntimeSearchParam param = new RuntimeSearchParam(null, null, searchParam.name(), searchParam.description(), searchParam.path(), paramType, null, providesMembershipInCompartments, toTargetList(searchParam.target()), RuntimeSearchParamStatusEnum.ACTIVE, base); theResourceDef.addSearchParam(param); nameToParam.put(param.getName(), param); RuntimeSearchParam param = new RuntimeSearchParam(null, null, searchParam.name(), searchParam.description(), searchParam.path(), RestSearchParameterTypeEnum.COMPOSITE, compositeOf, null, toTargetList(searchParam.target()), RuntimeSearchParamStatusEnum.ACTIVE); theResourceDef.addSearchParam(param);
JoinEnum joinType; switch (param.getParamType()) { case STRING: joinAttrName = "myParamsString"; case HAS: default: throw new InvalidRequestException("This server does not support _sort specifications of type " + param.getParamType() + " - Can't serve _sort=" + theSort.getParamName()); join = theFrom.join(joinAttrName, JoinType.LEFT); if (param.getParamType() == RestSearchParameterTypeEnum.REFERENCE) { thePredicates.add(join.get("mySourcePath").as(String.class).in(param.getPathsSplit())); } else { if (myDontUseHashesForSearch) {
public List<String> getPathsSplit() { String path = getPath(); if (path.indexOf('|') == -1) { return Collections.singletonList(path); } List<String> retVal = new ArrayList<String>(); StringTokenizer tok = new StringTokenizer(path, "|"); while (tok.hasMoreElements()) { String nextPath = tok.nextToken().trim(); retVal.add(nextPath.trim()); } return retVal; }
resourceTypes = new ArrayList<>(); Set<String> targetTypes = param.getTargets(); throw new InternalErrorException("Could not find parameter " + theParamName); String paramPath = searchParamByName.getPath(); if (paramPath.endsWith(".as(Reference)")) { paramPath = paramPath.substring(0, paramPath.length() - ".as(Reference)".length()) + "Reference";
private void addPredicateComposite(String theResourceName, RuntimeSearchParam theParamDef, List<? extends IQueryParameterType> theNextAnd) { // TODO: fail if missing is set for a composite query IQueryParameterType or = theNextAnd.get(0); if (!(or instanceof CompositeParam<?, ?>)) { throw new InvalidRequestException("Invalid type for composite param (must be " + CompositeParam.class.getSimpleName() + ": " + or.getClass()); } CompositeParam<?, ?> cp = (CompositeParam<?, ?>) or; RuntimeSearchParam left = theParamDef.getCompositeOf().get(0); IQueryParameterType leftValue = cp.getLeftValue(); myPredicates.add(createCompositeParamPart(theResourceName, myResourceTableRoot, left, leftValue)); RuntimeSearchParam right = theParamDef.getCompositeOf().get(1); IQueryParameterType rightValue = cp.getRightValue(); myPredicates.add(createCompositeParamPart(theResourceName, myResourceTableRoot, right, rightValue)); }