From 0ac434ea5da3c65a8f45be29ced2281e1d91001c Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Mon, 23 Mar 2020 17:53:30 -0400 Subject: [PATCH 01/10] Add chain on _type parameter --- .../java/ca/uhn/fhir/rest/api/Constants.java | 1 + .../ca/uhn/fhir/i18n/hapi-messages.properties | 3 + .../predicate/PredicateBuilderReference.java | 78 ++++++++++++++++--- .../r4/FhirResourceDaoR4SearchNoFtTest.java | 61 +++++++++++++++ 4 files changed, 134 insertions(+), 9 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/Constants.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/Constants.java index 8678d76cae8..09dfbae3d4f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/Constants.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/Constants.java @@ -260,6 +260,7 @@ public class Constants { */ public static final String EXT_META_SOURCE = "http://hapifhir.io/fhir/StructureDefinition/resource-meta-source"; public static final String PARAM_FHIRPATH = "_fhirpath"; + public static final String PARAM_TYPE = "_type"; static { CHARSET_UTF8 = StandardCharsets.UTF_8; diff --git a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties index c5b3696974e..bc15d09dc64 100644 --- a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties +++ b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties @@ -135,3 +135,6 @@ ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.cannotCreateDuplicateValueSetUrl=Can no ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl.expansionTooLarge=Expansion of ValueSet produced too many codes (maximum {0}) - Operation aborted! ca.uhn.fhir.jpa.util.jsonpatch.JsonPatchUtils.failedToApplyPatch=Failed to apply JSON patch to {0}: {1} + +ca.uhn.fhir.jpa.dao.predicate.PredicateBuilderReference.invalidTargetTypeForChain=Resource type "{0}" is not a valid target type for reference search parameter: {1} +ca.uhn.fhir.jpa.dao.predicate.PredicateBuilderReference.invalidResourceType=Invalid/unsupported resource type: "{0}" diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java index 6306487cabf..12f377485cb 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java @@ -20,14 +20,31 @@ package ca.uhn.fhir.jpa.dao.predicate; * #L% */ -import ca.uhn.fhir.context.*; +import ca.uhn.fhir.context.BaseRuntimeChildDefinition; +import ca.uhn.fhir.context.BaseRuntimeElementDefinition; +import ca.uhn.fhir.context.ConfigurationException; +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.RuntimeChildChoiceDefinition; +import ca.uhn.fhir.context.RuntimeChildResourceDefinition; +import ca.uhn.fhir.context.RuntimeResourceDefinition; +import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.interceptor.api.HookParams; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.interceptor.api.Pointcut; -import ca.uhn.fhir.jpa.dao.*; +import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao; +import ca.uhn.fhir.jpa.dao.DaoConfig; +import ca.uhn.fhir.jpa.dao.DaoRegistry; +import ca.uhn.fhir.jpa.dao.IDao; +import ca.uhn.fhir.jpa.dao.SearchBuilder; import ca.uhn.fhir.jpa.dao.index.IdHelperService; import ca.uhn.fhir.jpa.model.cross.ResourcePersistentId; -import ca.uhn.fhir.jpa.model.entity.*; +import ca.uhn.fhir.jpa.model.entity.ResourceHistoryProvenanceEntity; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantity; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString; +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamToken; +import ca.uhn.fhir.jpa.model.entity.ResourceLink; +import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage; import ca.uhn.fhir.jpa.searchparam.MatchUrlService; import ca.uhn.fhir.jpa.searchparam.ResourceMetaParams; @@ -47,22 +64,36 @@ import ca.uhn.fhir.rest.param.*; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; +import ca.uhn.fhir.util.UrlUtil; import com.google.common.collect.Lists; -import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import javax.persistence.criteria.*; -import java.util.*; +import javax.persistence.criteria.From; +import javax.persistence.criteria.Join; +import javax.persistence.criteria.JoinType; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.persistence.criteria.Subquery; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.ListIterator; +import java.util.Set; import java.util.stream.Collectors; -import static org.apache.commons.lang3.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.trim; @Component @Scope("prototype") @@ -273,20 +304,43 @@ class PredicateBuilderReference extends BasePredicateBuilder { } } else { + try { RuntimeResourceDefinition resDef = myContext.getResourceDefinition(theReferenceParam.getResourceType()); resourceTypes = new ArrayList<>(1); resourceTypes.add(resDef.getImplementingClass()); } catch (DataFormatException e) { - throw new InvalidRequestException("Invalid resource type: " + theReferenceParam.getResourceType()); + throw newInvalidResourceTypeException(theReferenceParam.getResourceType()); } + + } + + // Handle chain on _type + String chain = theReferenceParam.getChain(); + if (Constants.PARAM_TYPE.equals(chain)) { + String typeValue = theReferenceParam.getValue(); + + Class wantedType; + try { + wantedType = myContext.getResourceDefinition(typeValue).getImplementingClass(); + } catch (DataFormatException e) { + throw newInvalidResourceTypeException(typeValue); + } + if (!resourceTypes.contains(wantedType)) { + String searchParamName = theResourceName + ":" + theParamName; + String msg = myContext.getLocalizer().getMessage(PredicateBuilderReference.class, "invalidTargetTypeForChain", typeValue, searchParamName); + throw new InvalidRequestException(msg); + } + + Predicate targetTypeParameter = myCriteriaBuilder.equal(theJoin.get("myTargetResourceType"), typeValue); + myQueryRoot.addPredicate(targetTypeParameter); + return targetTypeParameter; } boolean foundChainMatch = false; List> candidateTargetTypes = new ArrayList<>(); for (Class nextType : resourceTypes) { - String chain = theReferenceParam.getChain(); String remainingChain = null; int chainDotIndex = chain.indexOf('.'); if (chainDotIndex != -1) { @@ -355,6 +409,12 @@ class PredicateBuilderReference extends BasePredicateBuilder { return predicate; } + @NotNull + private InvalidRequestException newInvalidResourceTypeException(String theResourceType) { + String msg = myContext.getLocalizer().getMessageSanitized(PredicateBuilderReference.class, "invalidResourceType", theResourceType); + throw new InvalidRequestException(msg); + } + private void warnAboutPerformanceOnUnqualifiedResources(String theParamName, RequestDetails theRequest, List> theCandidateTargetTypes) { String message = new StringBuilder() .append("This search uses an unqualified resource(a parameter in a chain without a resource type). ") diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java index e465c6d03a6..9d7d26bfada 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java @@ -316,6 +316,67 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { assertThat(ids, empty()); } + @Test + public void testChainOnType() { + + Patient sub1 = new Patient(); + sub1.setActive(true); + sub1.addIdentifier().setSystem("foo").setValue("bar"); + String sub1Id = myPatientDao.create(sub1).getId().toUnqualifiedVersionless().getValue(); + + Group sub2 = new Group(); + sub2.setActive(true); + sub2.addIdentifier().setSystem("foo").setValue("bar"); + String sub2Id = myGroupDao.create(sub2).getId().toUnqualifiedVersionless().getValue(); + + Encounter enc1 = new Encounter(); + enc1.getSubject().setReference(sub1Id); + String enc1Id = myEncounterDao.create(enc1).getId().toUnqualifiedVersionless().getValue(); + + Encounter enc2 = new Encounter(); + enc2.getSubject().setReference(sub2Id); + String enc2Id = myEncounterDao.create(enc2).getId().toUnqualifiedVersionless().getValue(); + + List ids; + SearchParameterMap map; + IBundleProvider results; + + map = new SearchParameterMap(); + map.setLoadSynchronous(true); + map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "Patient").setChain("_type")); + results = myEncounterDao.search(map); + ids = toUnqualifiedVersionlessIdValues(results); + assertThat(ids, hasItems(enc1Id)); + + map = new SearchParameterMap(); + map.setLoadSynchronous(true); + map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "Group").setChain("_type")); + results = myEncounterDao.search(map); + ids = toUnqualifiedVersionlessIdValues(results); + assertThat(ids, hasItems(enc2Id)); + + map = new SearchParameterMap(); + map.setLoadSynchronous(true); + map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "Organization").setChain("_type")); + try { + myEncounterDao.search(map); + fail(); + } catch (InvalidRequestException e) { + assertEquals("Resource type \"Organization\" is not a valid target type for reference search parameter: Encounter:subject", e.getMessage()); + } + + map = new SearchParameterMap(); + map.setLoadSynchronous(true); + map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "HelpImABug").setChain("_type")); + try { + myEncounterDao.search(map); + fail(); + } catch (InvalidRequestException e) { + assertEquals("Invalid/unsupported resource type: \"HelpImABug\"", e.getMessage()); + } + + } + /** * See #441 */ From 7706600a8c4958134a3c94c206757d2f1714728d Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Mon, 23 Mar 2020 18:05:48 -0400 Subject: [PATCH 02/10] Add changelog --- .../hapi/fhir/changelog/4_3_0/1772-allow-chain-on-type.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/4_3_0/1772-allow-chain-on-type.yaml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/4_3_0/1772-allow-chain-on-type.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/4_3_0/1772-allow-chain-on-type.yaml new file mode 100644 index 00000000000..e62150f7c46 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/4_3_0/1772-allow-chain-on-type.yaml @@ -0,0 +1,5 @@ +--- +type: add +issue: 1772 +title: "The JPA server now allows chained searches on the `_type` parameter. For example, the following + could be used to find all Encounters with a context of type Group: `Encounter?context._type=Group`." From a067a2001d3f45afd9db87a199a428a5804eacde Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Mon, 23 Mar 2020 18:53:16 -0400 Subject: [PATCH 03/10] Test fix --- .../org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java index a8357f361a8..df5b855c627 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java @@ -679,7 +679,7 @@ public class FhirInstanceValidatorR5Test { ValidationResult output = myVal.validateWithResult(input); assertEquals(output.toString(), 1, output.getMessages().size()); - assertEquals("This \"Patient2 cannot be parsed as a FHIR object (no namespace)", output.getMessages().get(0).getMessage()); + assertEquals("This \"Patient\" cannot be parsed as a FHIR object (no namespace)", output.getMessages().get(0).getMessage()); ourLog.info(output.getMessages().get(0).getLocationString()); } From 13f0e5384b0a3a91d9c4ab7a53a8010b7cb228b8 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Tue, 24 Mar 2020 06:02:55 -0400 Subject: [PATCH 04/10] Address review comments --- azure-pipelines.yml | 2 +- .../4_3_0/1772-allow-chain-on-type.yaml | 2 +- .../predicate/PredicateBuilderReference.java | 26 ++++++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fb818edbbe8..d3222478c07 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,7 +29,7 @@ jobs: env: JAVA_HOME_11_X64: /usr/local/openjdk-11 inputs: - goals: 'clean install' + goals: 'dependency:resolve clean install' # These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy options: '-P ALLMODULES,JACOCO,CI,ERRORPRONE -nsu -e -B -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' # These are JVM options (and don't show up in the build logs) diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/4_3_0/1772-allow-chain-on-type.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/4_3_0/1772-allow-chain-on-type.yaml index e62150f7c46..61454172e40 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/4_3_0/1772-allow-chain-on-type.yaml +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/4_3_0/1772-allow-chain-on-type.yaml @@ -2,4 +2,4 @@ type: add issue: 1772 title: "The JPA server now allows chained searches on the `_type` parameter. For example, the following - could be used to find all Encounters with a context of type Group: `Encounter?context._type=Group`." + could be used to find all Encounters with a context of type Group: `Encounter?subject._type=Group`." diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java index 12f377485cb..b891b12879f 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java @@ -64,7 +64,6 @@ import ca.uhn.fhir.rest.param.*; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; -import ca.uhn.fhir.util.UrlUtil; import com.google.common.collect.Lists; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -327,9 +326,8 @@ class PredicateBuilderReference extends BasePredicateBuilder { throw newInvalidResourceTypeException(typeValue); } if (!resourceTypes.contains(wantedType)) { - String searchParamName = theResourceName + ":" + theParamName; - String msg = myContext.getLocalizer().getMessage(PredicateBuilderReference.class, "invalidTargetTypeForChain", typeValue, searchParamName); - throw new InvalidRequestException(msg); + InvalidRequestException invalidRequestException = newInvalidTargetTypeForChainException(theResourceName, theParamName, typeValue); + throw invalidRequestException; } Predicate targetTypeParameter = myCriteriaBuilder.equal(theJoin.get("myTargetResourceType"), typeValue); @@ -409,12 +407,6 @@ class PredicateBuilderReference extends BasePredicateBuilder { return predicate; } - @NotNull - private InvalidRequestException newInvalidResourceTypeException(String theResourceType) { - String msg = myContext.getLocalizer().getMessageSanitized(PredicateBuilderReference.class, "invalidResourceType", theResourceType); - throw new InvalidRequestException(msg); - } - private void warnAboutPerformanceOnUnqualifiedResources(String theParamName, RequestDetails theRequest, List> theCandidateTargetTypes) { String message = new StringBuilder() .append("This search uses an unqualified resource(a parameter in a chain without a resource type). ") @@ -996,4 +988,18 @@ class PredicateBuilderReference extends BasePredicateBuilder { return retVal; } + + @NotNull + private InvalidRequestException newInvalidTargetTypeForChainException(String theResourceName, String theParamName, String theTypeValue) { + String searchParamName = theResourceName + ":" + theParamName; + String msg = myContext.getLocalizer().getMessage(PredicateBuilderReference.class, "invalidTargetTypeForChain", theTypeValue, searchParamName); + return new InvalidRequestException(msg); + } + + @NotNull + private InvalidRequestException newInvalidResourceTypeException(String theResourceType) { + String msg = myContext.getLocalizer().getMessageSanitized(PredicateBuilderReference.class, "invalidResourceType", theResourceType); + throw new InvalidRequestException(msg); + } + } From 31893be836648b56fd34756d611d2e2148c17276 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Tue, 24 Mar 2020 06:04:21 -0400 Subject: [PATCH 05/10] Fix azure yaml --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d3222478c07..64356a39b75 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,7 +29,7 @@ jobs: env: JAVA_HOME_11_X64: /usr/local/openjdk-11 inputs: - goals: 'dependency:resolve clean install' + goals: 'dependency:resolve clean install' # These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy options: '-P ALLMODULES,JACOCO,CI,ERRORPRONE -nsu -e -B -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' # These are JVM options (and don't show up in the build logs) From 22e0c7a596dd65dd2ddceff6bd8a7032950c0b31 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Tue, 24 Mar 2020 06:09:03 -0400 Subject: [PATCH 06/10] Correct HTTPs in pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18b28372908..744e85c8a9d 100644 --- a/pom.xml +++ b/pom.xml @@ -1524,7 +1524,7 @@ maven2 Maven2 - http://central.maven.org/maven2/ + https://central.maven.org/maven2/ true From bb4cbb6af5145eea449c7b05523c29148935fd69 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Tue, 24 Mar 2020 06:10:29 -0400 Subject: [PATCH 07/10] One more pom tweak --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 744e85c8a9d..2ced92eb308 100644 --- a/pom.xml +++ b/pom.xml @@ -1512,6 +1512,7 @@ + From 718c248c694cff446ce37f2ee5280ad151a1f81f Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Tue, 24 Mar 2020 07:55:25 -0400 Subject: [PATCH 08/10] Test fix --- .../fhir/jpa/dao/predicate/PredicateBuilderReference.java | 7 +++---- .../fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java | 2 +- .../uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java index b891b12879f..1a71242f249 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderReference.java @@ -315,8 +315,7 @@ class PredicateBuilderReference extends BasePredicateBuilder { } // Handle chain on _type - String chain = theReferenceParam.getChain(); - if (Constants.PARAM_TYPE.equals(chain)) { + if (Constants.PARAM_TYPE.equals(theReferenceParam.getChain())) { String typeValue = theReferenceParam.getValue(); Class wantedType; @@ -326,8 +325,7 @@ class PredicateBuilderReference extends BasePredicateBuilder { throw newInvalidResourceTypeException(typeValue); } if (!resourceTypes.contains(wantedType)) { - InvalidRequestException invalidRequestException = newInvalidTargetTypeForChainException(theResourceName, theParamName, typeValue); - throw invalidRequestException; + throw newInvalidTargetTypeForChainException(theResourceName, theParamName, typeValue); } Predicate targetTypeParameter = myCriteriaBuilder.equal(theJoin.get("myTargetResourceType"), typeValue); @@ -338,6 +336,7 @@ class PredicateBuilderReference extends BasePredicateBuilder { boolean foundChainMatch = false; List> candidateTargetTypes = new ArrayList<>(); for (Class nextType : resourceTypes) { + String chain = theReferenceParam.getChain(); String remainingChain = null; int chainDotIndex = chain.indexOf('.'); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java index f03f54eefee..acaeccee165 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java @@ -346,7 +346,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { .returnBundle(Bundle.class) .execute(); } catch (InvalidRequestException e) { - assertEquals("HTTP 400 Bad Request: Invalid resource type: FOO", e.getMessage()); + assertEquals("HTTP 400 Bad Request: Invalid/unsupported resource type: \"FOO\"", e.getMessage()); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java index 56c98b94cfd..9fe504d4752 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java @@ -405,15 +405,15 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { assertThat(idValues, contains(pid)); // Search param on extension - myCaptureQueriesListener.clear(); idValues = searchAndReturnUnqualifiedIdValues(ourServerBase + "/Patient?extpatorg=" + orgId.getValue()); - myCaptureQueriesListener.logSelectQueries(); assertThat(idValues, contains(pid)); idValues = searchAndReturnUnqualifiedIdValues(ourServerBase + "/Patient?extpatorg.name=ORGANIZATION"); assertThat(idValues, contains(pid)); + myCaptureQueriesListener.clear(); idValues = searchAndReturnUnqualifiedIdValues(ourServerBase + "/Patient?extpatorg.extorgorg.name=PARENT"); + myCaptureQueriesListener.logSelectQueries(); assertThat(idValues, contains(pid)); idValues = searchAndReturnUnqualifiedIdValues(ourServerBase + "/Patient?extpatorg.extorgorg.extorgorg.name=GRANDPARENT"); From 274a6cb7a10a8c4dde65ad47b29ba0b799c46024 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Tue, 24 Mar 2020 08:52:32 -0400 Subject: [PATCH 09/10] Try azure again --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 64356a39b75..5b99ec7dace 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,7 +29,7 @@ jobs: env: JAVA_HOME_11_X64: /usr/local/openjdk-11 inputs: - goals: 'dependency:resolve clean install' + goals: 'dependency:go-offline clean install' # These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy options: '-P ALLMODULES,JACOCO,CI,ERRORPRONE -nsu -e -B -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' # These are JVM options (and don't show up in the build logs) From 1271d5cf4df63476a2e537e56ae55705b5a6b2a5 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Tue, 24 Mar 2020 09:44:33 -0400 Subject: [PATCH 10/10] One more azure tweak --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5b99ec7dace..fb818edbbe8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,7 +29,7 @@ jobs: env: JAVA_HOME_11_X64: /usr/local/openjdk-11 inputs: - goals: 'dependency:go-offline clean install' + goals: 'clean install' # These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy options: '-P ALLMODULES,JACOCO,CI,ERRORPRONE -nsu -e -B -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' # These are JVM options (and don't show up in the build logs)