From cb9716f885185b01c27b503ca248f528ec053fa3 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Fri, 1 May 2015 11:44:06 -0400 Subject: [PATCH] More work to get build working --- .../fhir/context/RuntimeChildChoiceDefinition.java | 6 ++++-- .../RuntimeChildUndeclaredExtensionDefinition.java | 12 ++++++++++-- .../java/ca/uhn/fhir/rest/server/SearchTest.java | 6 ++++-- .../src/test/resources/logback-test.xml | 5 ++++- hapi-fhir-structures-dstu2/.gitignore | 1 + .../src/test/resources/logback-test.xml | 3 +++ 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildChoiceDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildChoiceDefinition.java index d9c574f2675..a7da12f7512 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildChoiceDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildChoiceDefinition.java @@ -82,6 +82,8 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini myDatatypeToElementName = new HashMap, String>(); myDatatypeToElementDefinition = new HashMap, BaseRuntimeElementDefinition>(); + String referenceChildName = theContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU1) ? "Resource" : "Reference"; + for (Class next : myChoiceTypes) { String elementName; @@ -89,7 +91,7 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini BaseRuntimeElementDefinition nextDef; if (IBaseResource.class.isAssignableFrom(next)) { elementName = getElementName() + StringUtils.capitalize(next.getSimpleName()); - alternateElementName = getElementName() + "Reference"; + alternateElementName = getElementName() + referenceChildName; List> types = new ArrayList>(); types.add((Class) next); nextDef = new RuntimeResourceReferenceDefinition(elementName, types); @@ -107,7 +109,7 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini if (IBaseResource.class.isAssignableFrom(next)) { Class refType = theContext.getVersion().getResourceReferenceType(); myDatatypeToElementDefinition.put(refType, nextDef); - alternateElementName = getElementName() + "Reference"; + alternateElementName = getElementName() + referenceChildName; myDatatypeToElementName.put(refType, alternateElementName); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java index 191bebbf9ca..f168562852f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java @@ -143,14 +143,22 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD /* * Resource reference - The correct name is 'valueReference', but - * we allow for valueResource because some incorrect parsers may use this + * we allow for valueResource because some incorrect parsers may use this. + * valueResource was the correct name in DSTU1. We put the correct name + * second so that it gets stored as the appropriate name for the + * reference datatype. */ addReferenceBinding(theContext, theClassToElementDefinitions, "valueResource"); addReferenceBinding(theContext, theClassToElementDefinitions, "valueReference"); } private void addReferenceBinding(FhirContext theContext, Map, BaseRuntimeElementDefinition> theClassToElementDefinitions, String value) { - myDatatypeToAttributeName.put(theContext.getVersion().getResourceReferenceType(), value); + if (theContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU1) && "valueReference".equals(value)) { + // This changed between DSTU1 and DSTU2 so don't store the DSTU2 name here + } else { + myDatatypeToAttributeName.put(theContext.getVersion().getResourceReferenceType(), value); + } + List> types = new ArrayList>(); types.add(IBaseResource.class); RuntimeResourceReferenceDefinition def = new RuntimeResourceReferenceDefinition(value, types); diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java index 631139e28ed..3835db092a3 100644 --- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java +++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java @@ -286,7 +286,7 @@ public class SearchTest { IOUtils.closeQuietly(status.getEntity().getContent()); ourLog.info(responseContent); assertEquals(400, status.getStatusLine().getStatusCode()); - assertThat(responseContent, containsString("
")); + assertThat(responseContent, containsString("
")); } /** @@ -473,7 +473,9 @@ public class SearchTest { patient.addIdentifier("system", "identifier123"); if (theParam != null) { patient.addName().addFamily("id" + theParam.getValue()); - patient.addName().addFamily("name" + theName.getValue()); + if (theName != null) { + patient.addName().addFamily("name" + theName.getValue()); + } } retVal.add(patient); return retVal; diff --git a/hapi-fhir-structures-dstu/src/test/resources/logback-test.xml b/hapi-fhir-structures-dstu/src/test/resources/logback-test.xml index 68c49977418..996190aeccf 100644 --- a/hapi-fhir-structures-dstu/src/test/resources/logback-test.xml +++ b/hapi-fhir-structures-dstu/src/test/resources/logback-test.xml @@ -10,7 +10,10 @@ - + + + + diff --git a/hapi-fhir-structures-dstu2/.gitignore b/hapi-fhir-structures-dstu2/.gitignore index 603d9d44e91..6754db1921b 100644 --- a/hapi-fhir-structures-dstu2/.gitignore +++ b/hapi-fhir-structures-dstu2/.gitignore @@ -137,3 +137,4 @@ local.properties # TeXlipse plugin .texlipse +/target/ diff --git a/hapi-fhir-structures-dstu2/src/test/resources/logback-test.xml b/hapi-fhir-structures-dstu2/src/test/resources/logback-test.xml index e0cd60554bf..996190aeccf 100644 --- a/hapi-fhir-structures-dstu2/src/test/resources/logback-test.xml +++ b/hapi-fhir-structures-dstu2/src/test/resources/logback-test.xml @@ -13,6 +13,9 @@ + + +