From d9e21a7192b6a6fc90e85fb2dc8fa6447048b0eb Mon Sep 17 00:00:00 2001 From: "b.debeaubien" Date: Wed, 29 Oct 2014 15:50:43 -0400 Subject: [PATCH 1/5] Fix for https://github.com/jamesagnew/hapi-fhir/issues/42 --- .../java/ca/uhn/fhir/context/RuntimeResourceDefinition.java | 6 ++++++ .../ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java index 557feae8a52..25479bbdba0 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java @@ -32,6 +32,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import ca.uhn.fhir.model.api.ICompositeDatatype; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; @@ -364,6 +365,11 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini if (nextChild.getChildType() != null && IPrimitiveDatatype.class.isAssignableFrom(nextChild.getChildType())) { RuntimePrimitiveDatatypeDefinition pdef = (RuntimePrimitiveDatatypeDefinition) nextChild.getSingleChildOrThrow(); defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName())); + } + else if (nextChild.getChildType() != null && ICompositeDatatype.class.isAssignableFrom(nextChild.getChildType())) { + RuntimeCompositeDatatypeDefinition pdef = (RuntimeCompositeDatatypeDefinition) nextChild.getSingleChildOrThrow(); + defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName())); + } else { RuntimeResourceBlockDefinition pdef = (RuntimeResourceBlockDefinition) nextChild.getSingleChildOrThrow(); scanForExtensions(theProfile, pdef); diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java index cac7df5fcca..dbedb9a5c0e 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java @@ -79,7 +79,8 @@ public class RuntimeResourceDefinitionTest { assertEquals("ResourceWithExtensionsA.extension", element.get(2).getPath().getValue()); assertEquals("ResourceWithExtensionsA.extension", element.get(3).getPath().getValue()); assertEquals("ResourceWithExtensionsA.extension", element.get(4).getPath().getValue()); - assertEquals("ResourceWithExtensionsA.modifierExtension", element.get(5).getPath().getValue()); + assertEquals("ResourceWithExtensionsA.extension", element.get(5).getPath().getValue()); + assertEquals("ResourceWithExtensionsA.modifierExtension", element.get(6).getPath().getValue()); assertEquals(DataTypeEnum.EXTENSION, element.get(1).getDefinition().getType().get(0).getCode().getValueAsEnum()); assertEquals("url", element.get(1).getSlicing().getDiscriminator().getValue()); @@ -87,7 +88,7 @@ public class RuntimeResourceDefinitionTest { assertEquals(DataTypeEnum.EXTENSION, element.get(2).getDefinition().getType().get(0).getCode().getValueAsEnum()); assertEquals("#f1", element.get(2).getDefinition().getType().get(0).getProfile().getValueAsString()); - assertEquals("ResourceWithExtensionsA.identifier", element.get(12).getPath().getValue()); + assertEquals("ResourceWithExtensionsA.identifier", element.get(13).getPath().getValue()); } From 7c0ebd6e98eb77346f17516c1bd545d2d79efe4a Mon Sep 17 00:00:00 2001 From: "b.debeaubien" Date: Wed, 29 Oct 2014 16:00:54 -0400 Subject: [PATCH 2/5] https://github.com/jamesagnew/hapi-fhir/issues/39 AddProfileTagEnum is now public, so that one can actually call setAddProfileTag. --- .../main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java index 9ae13ff20cf..b4f13afba99 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java @@ -25,7 +25,7 @@ package ca.uhn.fhir.rest.server; * * @see RestfulServer#setAddProfileTag(AddProfileTagEnum) */ -enum AddProfileTagEnum { +public enum AddProfileTagEnum { /** * Do not add profile tags automatically */ From edc8614ba894f32e8cb15cee01e61f57a65c0029 Mon Sep 17 00:00:00 2001 From: "b.debeaubien" Date: Thu, 30 Oct 2014 10:06:42 -0400 Subject: [PATCH 3/5] Merging master --- .../ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java index 597c750a5b3..01981d9b0e5 100644 --- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java +++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/RuntimeResourceDefinitionTest.java @@ -79,7 +79,8 @@ public class RuntimeResourceDefinitionTest { assertEquals("ResourceWithExtensionsA.extension", element.get(2).getPath().getValue()); assertEquals("ResourceWithExtensionsA.extension", element.get(3).getPath().getValue()); assertEquals("ResourceWithExtensionsA.extension", element.get(4).getPath().getValue()); - assertEquals("ResourceWithExtensionsA.modifierExtension", element.get(5).getPath().getValue()); + assertEquals("ResourceWithExtensionsA.extension", element.get(5).getPath().getValue()); + assertEquals("ResourceWithExtensionsA.modifierExtension", element.get(6).getPath().getValue()); assertEquals(DataTypeEnum.EXTENSION, element.get(1).getDefinition().getType().get(0).getCode().getValueAsEnum()); assertEquals("url", element.get(1).getSlicing().getDiscriminator().getValue()); @@ -87,7 +88,7 @@ public class RuntimeResourceDefinitionTest { assertEquals(DataTypeEnum.EXTENSION, element.get(2).getDefinition().getType().get(0).getCode().getValueAsEnum()); assertEquals("#f1", element.get(2).getDefinition().getType().get(0).getProfile().getValueAsString()); - assertEquals("ResourceWithExtensionsA.identifier", element.get(12).getPath().getValue()); + assertEquals("ResourceWithExtensionsA.identifier", element.get(13).getPath().getValue()); } From b733b1a1dd3c1a1b337ea86917ccc901ff334c4c Mon Sep 17 00:00:00 2001 From: "b.debeaubien" Date: Wed, 29 Oct 2014 16:00:54 -0400 Subject: [PATCH 4/5] https://github.com/jamesagnew/hapi-fhir/issues/39 AddProfileTagEnum is now public, so that one can actually call setAddProfileTag. --- .../main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java index 9ae13ff20cf..b4f13afba99 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/AddProfileTagEnum.java @@ -25,7 +25,7 @@ package ca.uhn.fhir.rest.server; * * @see RestfulServer#setAddProfileTag(AddProfileTagEnum) */ -enum AddProfileTagEnum { +public enum AddProfileTagEnum { /** * Do not add profile tags automatically */ From 374da3f3a09ccaf9713731a3033b207092340ca7 Mon Sep 17 00:00:00 2001 From: "b.debeaubien" Date: Thu, 30 Oct 2014 11:41:48 -0400 Subject: [PATCH 5/5] Fix for https://github.com/jamesagnew/hapi-fhir/issues/42 A few more eclipse exclusions for .gitignore --- .gitignore | 4 ++++ .../ca/uhn/fhir/model/dstu/FhirDstu1.java | 24 +++++-------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 232298d69bd..491a273dcfe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,12 @@ /bin /target +target/ .idea/ .project/ .settings/ +.metadata/ +RemoteSystemsTempFiles/ +Servers/ *.iml *.log *.log* diff --git a/hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/model/dstu/FhirDstu1.java b/hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/model/dstu/FhirDstu1.java index c1fba6f2312..07765b9beaa 100644 --- a/hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/model/dstu/FhirDstu1.java +++ b/hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/model/dstu/FhirDstu1.java @@ -31,27 +31,12 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import ca.uhn.fhir.context.*; +import ca.uhn.fhir.model.api.ICompositeDatatype; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; -import ca.uhn.fhir.context.BaseRuntimeChildDefinition; -import ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition; -import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition; -import ca.uhn.fhir.context.BaseRuntimeElementDefinition; import ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum; -import ca.uhn.fhir.context.ConfigurationException; -import ca.uhn.fhir.context.RuntimeChildChoiceDefinition; -import ca.uhn.fhir.context.RuntimeChildCompositeDatatypeDefinition; -import ca.uhn.fhir.context.RuntimeChildContainedResources; -import ca.uhn.fhir.context.RuntimeChildDeclaredExtensionDefinition; -import ca.uhn.fhir.context.RuntimeChildPrimitiveDatatypeDefinition; -import ca.uhn.fhir.context.RuntimeChildResourceBlockDefinition; -import ca.uhn.fhir.context.RuntimeChildResourceDefinition; -import ca.uhn.fhir.context.RuntimeChildUndeclaredExtensionDefinition; -import ca.uhn.fhir.context.RuntimePrimitiveDatatypeDefinition; -import ca.uhn.fhir.context.RuntimeResourceBlockDefinition; -import ca.uhn.fhir.context.RuntimeResourceDefinition; -import ca.uhn.fhir.context.RuntimeResourceReferenceDefinition; import ca.uhn.fhir.model.api.IFhirVersion; import ca.uhn.fhir.model.api.IPrimitiveDatatype; import ca.uhn.fhir.model.api.IResource; @@ -79,7 +64,7 @@ public class FhirDstu1 implements IFhirVersion { public Object createServerConformanceProvider(RestfulServer theServer) { return new ServerConformanceProvider(theServer); } - + private void fillBasics(StructureElement theElement, BaseRuntimeElementDefinition def, LinkedList path, BaseRuntimeDeclaredChildDefinition theChild) { if (path.isEmpty()) { path.add(def.getName()); @@ -311,6 +296,9 @@ public class FhirDstu1 implements IFhirVersion { if (nextChild.getChildType() != null && IPrimitiveDatatype.class.isAssignableFrom(nextChild.getChildType())) { RuntimePrimitiveDatatypeDefinition pdef = (RuntimePrimitiveDatatypeDefinition) nextChild.getSingleChildOrThrow(); defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName())); + } else if (nextChild.getChildType() != null && ICompositeDatatype.class.isAssignableFrom(nextChild.getChildType())) { + RuntimeCompositeDatatypeDefinition pdef = (RuntimeCompositeDatatypeDefinition) nextChild.getSingleChildOrThrow(); + defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName())); } else { RuntimeResourceBlockDefinition pdef = (RuntimeResourceBlockDefinition) nextChild.getSingleChildOrThrow(); scanForExtensions(theProfile, pdef);