@Override String doGetValueAsQueryToken(FhirContext theContext) { StringBuilder b = new StringBuilder(); if (myLeftType != null) { b.append(myLeftType.getValueAsQueryToken(theContext)); } b.append('$'); if (myRightType != null) { b.append(myRightType.getValueAsQueryToken(theContext)); } return b.toString(); }
private static int compare(FhirContext theCtx, IQueryParameterType theO1, IQueryParameterType theO2) { int retVal; if (theO1.getMissing() == null && theO2.getMissing() == null) { retVal = 0; } else if (theO1.getMissing() == null) { retVal = -1; } else if (theO2.getMissing() == null) { retVal = 1; } else if (ObjectUtil.equals(theO1.getMissing(), theO2.getMissing())) { retVal = 0; } else { if (theO1.getMissing()) { retVal = 1; } else { retVal = -1; } } if (retVal == 0) { String q1 = theO1.getQueryParameterQualifier(); String q2 = theO2.getQueryParameterQualifier(); retVal = StringUtils.compare(q1, q2); } if (retVal == 0) { String v1 = theO1.getValueAsQueryToken(theCtx); String v2 = theO2.getValueAsQueryToken(theCtx); retVal = StringUtils.compare(v1, v2); } return retVal; }
@Override void doSetValueAsQueryToken(FhirContext theContext, String theParamName, String theQualifier, String theValue) { if (isBlank(theValue)) { myLeftType.setValueAsQueryToken(theContext, theParamName, theQualifier, ""); myRightType.setValueAsQueryToken(theContext, theParamName, theQualifier, ""); } else { List<String> parts = ParameterUtil.splitParameterString(theValue, '$', false); if (parts.size() > 2) { throw new InvalidRequestException("Invalid value for composite parameter (only one '$' is valid for this parameter, others must be escaped). Value was: " + theValue); } myLeftType.setValueAsQueryToken(theContext, theParamName, theQualifier, parts.get(0)); if (parts.size() > 1) { myRightType.setValueAsQueryToken(theContext, theParamName, theQualifier, parts.get(1)); } } }
public QualifiedParamList(IQueryParameterOr<?> theNextOr, FhirContext theContext) { for (IQueryParameterType next : theNextOr.getValuesAsQueryTokens()) { if (myQualifier == null) { myQualifier = next.getQueryParameterQualifier(); } add(next.getValueAsQueryToken(theContext)); } }
assert theParamName.contains(".") == false; if (theList.get(0).getMissing() != null) { addPredicateParamMissing(theResourceName, theParamName, theList.get(0).getMissing()); return; String nextValue = next.getValueAsQueryToken(myContext); IQueryParameterType chainValue = mapReferenceChainToRawParamType(remainingChain, param, theParamName, qualifier, nextType, chain, isMeta, nextValue); if (chainValue == null) {
private void clean(String theParamName, List<List<? extends IQueryParameterType>> theAndOrParams) { for (int andListIdx = 0; andListIdx < theAndOrParams.size(); andListIdx++) { List<? extends IQueryParameterType> nextOrList = theAndOrParams.get(andListIdx); for (int orListIdx = 0; orListIdx < nextOrList.size(); orListIdx++) { IQueryParameterType nextOr = nextOrList.get(orListIdx); boolean hasNoValue = false; if (nextOr.getMissing() != null) { continue; } if (nextOr instanceof QuantityParam) { if (isBlank(((QuantityParam) nextOr).getValueAsString())) { hasNoValue = true; } } if (hasNoValue) { ourLog.debug("Ignoring empty parameter: {}", theParamName); nextOrList.remove(orListIdx); orListIdx--; } } if (nextOrList.isEmpty()) { theAndOrParams.remove(andListIdx); andListIdx--; } } }
private boolean hasQualifiers(List<List<? extends IQueryParameterType>> theAndOrParams) { return theAndOrParams.stream().flatMap(List::stream).anyMatch(param -> param.getQueryParameterQualifier() != null); }
public QualifiedParamList(IQueryParameterOr<?> theNextOr, FhirContext theContext) { for (IQueryParameterType next : theNextOr.getValuesAsQueryTokens()) { if (myQualifier == null) { myQualifier = next.getQueryParameterQualifier(); } add(next.getValueAsQueryToken(theContext)); } }
assert theParamName.contains(".") == false; if (theList.get(0).getMissing() != null) { addPredicateParamMissing(theResourceName, theParamName, theList.get(0).getMissing()); return; String nextValue = next.getValueAsQueryToken(myContext); IQueryParameterType chainValue = mapReferenceChainToRawParamType(remainingChain, param, theParamName, qualifier, nextType, chain, isMeta, nextValue); if (chainValue == null) {
private void addPredicateString(String theResourceName, String theParamName, List<? extends IQueryParameterType> theList) { Join<ResourceTable, ResourceIndexedSearchParamString> join = createOrReuseJoin(JoinEnum.STRING, theParamName); if (theList.get(0).getMissing() != null) { addPredicateParamMissing(theResourceName, theParamName, theList.get(0).getMissing(), join); return; } List<Predicate> codePredicates = new ArrayList<>(); for (IQueryParameterType nextOr : theList) { Predicate singleCode = createPredicateString(nextOr, theResourceName, theParamName, myBuilder, join); codePredicates.add(singleCode); } myPredicates.add(myBuilder.or(toArray(codePredicates))); }
/** * This will only return true if all parameters have no modifier of any kind */ public boolean isAllParametersHaveNoModifier() { for (List<List<? extends IQueryParameterType>> nextParamName : values()) { for (List<? extends IQueryParameterType> nextAnd : nextParamName) { for (IQueryParameterType nextOr : nextAnd) { if (isNotBlank(nextOr.getQueryParameterQualifier())) { return false; } } } } return true; }
@SuppressWarnings("unchecked") @Override public QUERY where(Map<String, List<IQueryParameterType>> theCriterion) { Validate.notNull(theCriterion, "theCriterion must not be null"); for (Entry<String, List<IQueryParameterType>> nextEntry : theCriterion.entrySet()) { String nextKey = nextEntry.getKey(); List<IQueryParameterType> nextValues = nextEntry.getValue(); for (IQueryParameterType nextValue : nextValues) { addParam(myParams, nextKey, nextValue.getValueAsQueryToken(myContext)); } } return (QUERY) this; }
if (nextValueOrIn.getMissing() != null || isNotBlank(nextValueOrIn.getValueAsQueryToken(theCtx))) { nextValuesOrsOut.add(nextValueOrIn); if (firstValue.getMissing() != null) { b.append(Constants.PARAMQUALIFIER_MISSING); b.append('='); if (firstValue.getMissing()) { b.append(Constants.PARAMQUALIFIER_MISSING_TRUE); } else { if (isNotBlank(firstValue.getQueryParameterQualifier())) { b.append(firstValue.getQueryParameterQualifier()); b.append(','); String valueAsQueryToken = nextValueOr.getValueAsQueryToken(theCtx);
private void addPredicateQuantity(String theResourceName, String theParamName, List<? extends IQueryParameterType> theList) { Join<ResourceTable, ResourceIndexedSearchParamQuantity> join = createOrReuseJoin(JoinEnum.QUANTITY, theParamName); if (theList.get(0).getMissing() != null) { addPredicateParamMissing(theResourceName, theParamName, theList.get(0).getMissing(), join); return; } List<Predicate> codePredicates = new ArrayList<>(); for (IQueryParameterType nextOr : theList) { Predicate singleCode = createPredicateQuantity(nextOr, theResourceName, theParamName, myBuilder, join); codePredicates.add(singleCode); } myPredicates.add(myBuilder.or(toArray(codePredicates))); }
@Override public void setValuesAsQueryTokens(FhirContext theContext, String theParamName, QualifiedParamList theParameters) { myList.clear(); for (String next : theParameters) { PT nextParam = newInstance(); nextParam.setValueAsQueryToken(theContext, theParamName, theParameters.getQualifier(), next); myList.add(nextParam); } }
private void addParam(String theName, IQueryParameterType theValue) { IPrimitiveType<?> stringType = ParametersUtil.createString(myContext, theValue.getValueAsQueryToken(myContext)); addParam(theName, stringType); }
private void addPredicateDate(String theResourceName, String theParamName, List<? extends IQueryParameterType> theList) { Join<ResourceTable, ResourceIndexedSearchParamDate> join = createOrReuseJoin(JoinEnum.DATE, theParamName); if (theList.get(0).getMissing() != null) { Boolean missing = theList.get(0).getMissing(); addPredicateParamMissing(theResourceName, theParamName, missing, join); return; } List<Predicate> codePredicates = new ArrayList<>(); for (IQueryParameterType nextOr : theList) { Predicate p = createPredicateDate(nextOr, theResourceName, theParamName, myBuilder, join); codePredicates.add(p); } Predicate orPredicates = myBuilder.or(toArray(codePredicates)); myPredicates.add(orPredicates); }
private IQueryParameterType toParameterType(RuntimeSearchParam theParam, String theQualifier, String theValueAsQueryToken) { IQueryParameterType qp = toParameterType(theParam); qp.setValueAsQueryToken(myContext, theParam.getName(), theQualifier, theValueAsQueryToken); return qp; }
@Override public Object outgoingClient(Object theObject) { IQueryParameterType obj = (IQueryParameterType) theObject; IPrimitiveType<?> retVal = (IPrimitiveType<?>) myContext.getElementDefinition("string").newInstance(); retVal.setValueAsString(obj.getValueAsQueryToken(myContext)); return retVal; }
private void addPredicateToken(String theResourceName, String theParamName, List<? extends IQueryParameterType> theList) { if (theList.get(0).getMissing() != null) { Join<ResourceTable, ResourceIndexedSearchParamToken> join = createOrReuseJoin(JoinEnum.TOKEN, theParamName); addPredicateParamMissing(theResourceName, theParamName, theList.get(0).getMissing(), join); return; } List<Predicate> codePredicates = new ArrayList<>(); Join<ResourceTable, ResourceIndexedSearchParamToken> join = null; for (IQueryParameterType nextOr : theList) { if (nextOr instanceof TokenParam) { TokenParam id = (TokenParam) nextOr; if (id.isText()) { addPredicateString(theResourceName, theParamName, theList); break; } } if (join == null) { join = createOrReuseJoin(JoinEnum.TOKEN, theParamName); } Predicate singleCode = createPredicateToken(nextOr, theResourceName, theParamName, myBuilder, join); codePredicates.add(singleCode); } if (codePredicates.isEmpty()) { return; } Predicate spPredicate = myBuilder.or(toArray(codePredicates)); myPredicates.add(spPredicate); }