From a195eebdecc1a97c85242e3ace179eef64eedbdc Mon Sep 17 00:00:00 2001 From: Diederik Muylwyk Date: Fri, 5 Mar 2021 12:09:17 -0500 Subject: [PATCH] Placeholder extension moved to resource body from meta; tests passing. --- .../main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java | 4 ++-- .../uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java | 9 +++------ .../dao/r4/FhirResourceDaoCreatePlaceholdersR4Test.java | 3 +-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java b/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java index c791f38fde5..def5d13846f 100644 --- a/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java +++ b/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java @@ -1071,7 +1071,7 @@ public class DaoConfig { * as they are never allowed to be client supplied in HAPI FHIR JPA. * * All placeholder resources created in this way have a meta extension - * with the URL {@link HapiExtensions#EXT_RESOURCE_META_PLACEHOLDER} and the value "true". + * with the URL {@link HapiExtensions#EXT_RESOURCE_PLACEHOLDER} and the value "true". *

*/ public boolean isAutoCreatePlaceholderReferenceTargets() { @@ -1095,7 +1095,7 @@ public class DaoConfig { * as they are never allowed to be client supplied in HAPI FHIR JPA. * * All placeholder resources created in this way have a meta extension - * with the URL {@link HapiExtensions#EXT_RESOURCE_META_PLACEHOLDER} and the value "true". + * with the URL {@link HapiExtensions#EXT_RESOURCE_PLACEHOLDER} and the value "true". *

*/ public void setAutoCreatePlaceholderReferenceTargets(boolean theAutoCreatePlaceholderReferenceTargets) { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java index 0faaa9eb160..2c0d06dfebc 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java @@ -41,7 +41,6 @@ import ca.uhn.fhir.util.HapiExtensions; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseExtension; import org.hl7.fhir.instance.model.api.IBaseHasExtensions; -import org.hl7.fhir.instance.model.api.IBaseMetaType; import org.hl7.fhir.instance.model.api.IBaseReference; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; @@ -123,11 +122,9 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver { @SuppressWarnings("unchecked") T newResource = (T) missingResourceDef.newInstance(); - // FIXME: DM 2021-03-04 - This is where the placeholder extension is added; should be in resource body instead of meta? - IBaseMetaType meta = newResource.getMeta(); - if (meta instanceof IBaseHasExtensions) { - IBaseExtension extension = ((IBaseHasExtensions) meta).addExtension(); - extension.setUrl(HapiExtensions.EXT_RESOURCE_META_PLACEHOLDER); + if (newResource instanceof IBaseHasExtensions) { + IBaseExtension extension = ((IBaseHasExtensions) newResource).addExtension(); + extension.setUrl(HapiExtensions.EXT_RESOURCE_PLACEHOLDER); extension.setValue(myContext.getPrimitiveBoolean(true)); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCreatePlaceholdersR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCreatePlaceholdersR4Test.java index a81f245578a..badb1502a49 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCreatePlaceholdersR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCreatePlaceholdersR4Test.java @@ -177,7 +177,6 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { assertEquals("Patient/999999999999999", outcome.getResources(0,1).get(0).getIdElement().toUnqualifiedVersionless().getValue()); } - // FIXME: DM 2021-03-04 - This test fails; extension isn't being created correctly. @Test public void testCreatePlaceholderExtension_WithUpdateToTarget() { myDaoConfig.setAutoCreatePlaceholderReferenceTargets(true); @@ -201,7 +200,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test { ourLog.info("\nPlaceholder Patient created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); assertEquals(0, placeholderPat.getIdentifier().size()); Extension extension = placeholderPat.getExtensionByUrl(HapiExtensions.EXT_RESOURCE_PLACEHOLDER); - assertNotNull(extension); // FIXME: DM 2021-03-04 - This assertion fails for now. + assertNotNull(extension); assertTrue(extension.hasValue()); assertTrue(((BooleanType) extension.getValue()).booleanValue());