From 97d6d096639bb2256255905d18d96afad1dc5a68 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Mon, 14 Dec 2015 08:17:33 -0500 Subject: [PATCH] Work on #240 - Not yet working in JPA --- .../java/ca/uhn/fhir/model/api/Include.java | 67 ++++- .../ca/uhn/fhir/jpa/dao/SearchBuilder.java | 6 +- .../FhirResourceDaoDstu2SearchFtTest.java | 7 +- .../FhirResourceDaoDstu2SearchNoFtTest.java | 33 ++- .../ca/uhn/fhir/rest/server/IncludeTest.java | 276 ++++++++++-------- pom.xml | 30 +- src/changes/changes.xml | 10 + 7 files changed, 278 insertions(+), 151 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Include.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Include.java index 3da5dd95043..6fbb2d505f8 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Include.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Include.java @@ -2,6 +2,8 @@ package ca.uhn.fhir.model.api; import org.apache.commons.lang3.builder.ToStringBuilder; +import ch.qos.logback.core.db.dialect.MySQLDialect; + /* * #%L * HAPI FHIR - Core Library @@ -34,7 +36,7 @@ public class Include { private boolean myRecurse; private String myValue; - private boolean myImmutable; + private final boolean myImmutable; /** * Constructor for non-recursive include @@ -44,10 +46,11 @@ public class Include { */ public Include(String theValue) { myValue = theValue; + myImmutable = false; } /** - * Constructor for non-recursive include + * Constructor for an include * * @param theValue * The _include value, e.g. "Patient:name" @@ -57,6 +60,21 @@ public class Include { public Include(String theValue, boolean theRecurse) { myValue = theValue; myRecurse = theRecurse; + myImmutable = false; + } + + /** + * Constructor for an include + * + * @param theValue + * The _include value, e.g. "Patient:name" + * @param theRecurse + * Should the include recurse + */ + public Include(String theValue, boolean theRecurse, boolean theImmutable) { + myValue = theValue; + myRecurse = theRecurse; + myImmutable = theImmutable; } /** @@ -132,9 +150,18 @@ public class Include { myValue = theValue; } + /** + * Is this object {@link #toLocked() locked}? + */ + public boolean isLocked() { + return myImmutable; + } + + /** + * Return a new + */ public Include toLocked() { - Include retVal = new Include(myValue, myRecurse); - retVal.myImmutable = true; + Include retVal = new Include(myValue, myRecurse, true); return retVal; } @@ -145,4 +172,36 @@ public class Include { builder.append("recurse", myRecurse); return builder.toString(); } + + /** + * Creates and returns a new copy of this Include with the given type. The + * following table shows what will be returned: + * + * + * + * + * + *
Initial ContentstheResourceTypeOutput
Patient:careProviderOrganizationPatient:careProvider:Organization
Patient:careProvider:PractitionerOrganizationPatient:careProvider:Organization
Patient(any){@link IllegalStateException}
+ * + * @param theResourceType The resource type (e.g. "Organization") + * @return A new copy of the include. Note that if this include is {@link #toLocked() locked}, the returned include will be too + */ + public Include withType(String theResourceType) { + StringBuilder b = new StringBuilder(); + b.append(myValue); + int firstColon = myValue.indexOf(':'); + if (firstColon == -1 || firstColon == b.length() - 1) { + throw new IllegalStateException("This include does not contain a value in the format [ResourceType]:[paramName]"); + } + int secondColon = myValue.indexOf(':', firstColon + 1); + if (secondColon != -1) { + b.delete(secondColon, b.length()); + } + + b.append(":"); + b.append(theResourceType); + Include retVal = new Include(b.toString(), myRecurse, myImmutable); + return retVal; + } + } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java index baacd661955..83b375b1507 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java @@ -1322,7 +1322,7 @@ public class SearchBuilder { * * @param theLastUpdated */ - private HashSet loadReverseIncludes(Collection theMatches, Set theRevIncludes, boolean theReverseMode, EverythingModeEnum theEverythingModeEnum, DateRangeParam theLastUpdated) { + private HashSet loadReverseIncludes(Collection theMatches, Set theRevIncludes, boolean theReverseMode, DateRangeParam theLastUpdated) { if (theMatches.size() == 0) { return new HashSet(); } @@ -1595,7 +1595,7 @@ public class SearchBuilder { final Set revIncludedPids; if (theParams.getEverythingMode() == null) { if (theParams.getRevIncludes() != null && theParams.getRevIncludes().isEmpty() == false) { - revIncludedPids = loadReverseIncludes(pids, theParams.getRevIncludes(), true, null, lu); + revIncludedPids = loadReverseIncludes(pids, theParams.getRevIncludes(), true, lu); } else { revIncludedPids = new HashSet(); } @@ -1623,7 +1623,7 @@ public class SearchBuilder { // Load includes pidsSubList = new ArrayList(pidsSubList); - revIncludedPids.addAll(loadReverseIncludes(pidsSubList, theParams.getIncludes(), false, null, theParams.getLastUpdated())); + revIncludedPids.addAll(loadReverseIncludes(pidsSubList, theParams.getIncludes(), false, theParams.getLastUpdated())); // Execute the query and make sure we return distinct results List resources = new ArrayList(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchFtTest.java index 79b09e9ddc8..3217a6c9ce8 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchFtTest.java @@ -4,7 +4,9 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import java.util.List; @@ -14,9 +16,8 @@ import javax.servlet.http.HttpServletRequest; import org.hl7.fhir.instance.model.api.IIdType; import org.junit.Test; -import ca.uhn.fhir.jpa.dao.FhirSearchDao; -import ca.uhn.fhir.jpa.dao.SearchParameterMap; import ca.uhn.fhir.jpa.dao.FhirSearchDao.Suggestion; +import ca.uhn.fhir.jpa.dao.SearchParameterMap; import ca.uhn.fhir.model.dstu2.resource.Device; import ca.uhn.fhir.model.dstu2.resource.Media; import ca.uhn.fhir.model.dstu2.resource.Observation; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java index 0d5dab1ba81..e1010cd45eb 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java @@ -1430,25 +1430,36 @@ public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test { { Organization org = new Organization(); org.getNameElement().setValue(methodName + "_O1Parent"); - parentOrgId = myOrganizationDao.create(org).getId(); + parentOrgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless(); } + IIdType orgId; + IIdType patientId; { Organization org = new Organization(); org.getNameElement().setValue(methodName + "_O1"); org.setPartOf(new ResourceReferenceDt(parentOrgId)); - IIdType orgId = myOrganizationDao.create(org).getId(); + orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless(); Patient patient = new Patient(); patient.addIdentifier().setSystem("urn:system").setValue("001"); patient.addName().addFamily("Tester_" + methodName + "_P1").addGiven("Joe"); patient.getManagingOrganization().setReference(orgId); - myPatientDao.create(patient); + patient.addCareProvider().setReference(orgId); + patientId = myPatientDao.create(patient).getId().toUnqualifiedVersionless(); } + IIdType practId2; + { + Practitioner pract = new Practitioner(); + pract.getName().addFamily(methodName + "_PRACT1"); + practId2 = myPractitionerDao.create(pract).getId().toUnqualifiedVersionless(); + } + IIdType patientId2; { Patient patient = new Patient(); patient.addIdentifier().setSystem("urn:system").setValue("002"); patient.addName().addFamily("Tester_" + methodName + "_P2").addGiven("John"); - myPatientDao.create(patient); + patient.addCareProvider().setReference(practId2); + patientId2 = myPatientDao.create(patient).getId().toUnqualifiedVersionless(); } { @@ -1527,6 +1538,20 @@ public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test { assertEquals(1, patients.size()); assertEquals(Patient.class, patients.get(0).getClass()); } + { + // Untyped include + SearchParameterMap params = new SearchParameterMap(); + params.addInclude(Patient.INCLUDE_CAREPROVIDER); + List ids = toUnqualifiedVersionlessIds(myPatientDao.search(params)); + assertThat(ids, containsInAnyOrder(orgId, patientId, patientId2, practId2)); + } + { +// // Typed include +// SearchParameterMap params = new SearchParameterMap(); +// params.addInclude(Patient.INCLUDE_CAREPROVIDER.withType("Practitioner")); +// List ids = toUnqualifiedVersionlessIds(myPatientDao.search(params)); +// assertThat(ids, containsInAnyOrder(patientId, patientId2, practId2)); + } } @SuppressWarnings("unused") diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java index a05fa753f46..8bc9e169ed6 100644 --- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java +++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java @@ -1,7 +1,10 @@ package ca.uhn.fhir.rest.server; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.Arrays; @@ -51,56 +54,21 @@ import ca.uhn.fhir.util.PortUtil; public class IncludeTest { private static CloseableHttpClient ourClient; + private static FhirContext ourCtx; private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(IncludeTest.class); private static int ourPort; private static Server ourServer; - private static FhirContext ourCtx; @Test - public void testNoIncludes() throws Exception { - HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello"); - HttpResponse status = ourClient.execute(httpGet); - String responseContent = IOUtils.toString(status.getEntity().getContent()); - IOUtils.closeQuietly(status.getEntity().getContent()); - - assertEquals(200, status.getStatusLine().getStatusCode()); - Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent); - assertEquals(1, bundle.size()); - - Patient p = bundle.getResources(Patient.class).get(0); - assertEquals(0, p.getName().size()); - assertEquals("Hello", p.getId().getIdPart()); - } - - @Test - public void testOneInclude() throws Exception { - HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo"); - HttpResponse status = ourClient.execute(httpGet); - String responseContent = IOUtils.toString(status.getEntity().getContent()); - IOUtils.closeQuietly(status.getEntity().getContent()); - - assertEquals(200, status.getStatusLine().getStatusCode()); - Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent); - assertEquals(1, bundle.size()); - - Patient p = bundle.getResources(Patient.class).get(0); - assertEquals(1, p.getName().size()); - assertEquals("Hello", p.getId().getIdPart()); - assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue()); - } - - // @Test - public void testMixedContainedAndNonContained() throws Exception { - HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true"); + public void testBadInclude() throws Exception { + HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=baz"); HttpResponse status = ourClient.execute(httpGet); + assertEquals(400, status.getStatusLine().getStatusCode()); String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent()); ourLog.info(responseContent); - - assertEquals(200, status.getStatusLine().getStatusCode()); - Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent); - assertEquals(4, bundle.size()); + assertThat(responseContent, containsString("Invalid _include parameter value")); } @Test @@ -128,6 +96,32 @@ public class IncludeTest { } + @Test + public void testIIncludedResourcesNonContainedInDeclaredExtension() throws Exception { + HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=declaredExtInclude&_pretty=true"); + HttpResponse status = ourClient.execute(httpGet); + String responseContent = IOUtils.toString(status.getEntity().getContent()); + IOUtils.closeQuietly(status.getEntity().getContent()); + + assertEquals(200, status.getStatusLine().getStatusCode()); + Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent); + + ourLog.info(responseContent); + + assertEquals(4, bundle.size()); + assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless()); + assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless()); + assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless()); + assertEquals(new IdDt("Organization/o2"), bundle.toListOfResources().get(3).getId().toUnqualifiedVersionless()); + + Patient p1 = (Patient) bundle.toListOfResources().get(0); + assertEquals(0, p1.getContained().getContainedResources().size()); + + Patient p2 = (Patient) bundle.toListOfResources().get(1); + assertEquals(0, p2.getContained().getContainedResources().size()); + + } + @Test public void testIIncludedResourcesNonContainedInExtension() throws Exception { HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true"); @@ -179,29 +173,79 @@ public class IncludeTest { } @Test - public void testIIncludedResourcesNonContainedInDeclaredExtension() throws Exception { - HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=declaredExtInclude&_pretty=true"); + public void testIncludeWithType() { + assertEquals("Patient:careProvider:Practitioner", new Include("Patient:careProvider", true).withType("Practitioner").getValue()); + assertEquals(true, new Include("Patient:careProvider", true).withType("Practitioner").isRecurse()); + assertEquals(false, new Include("Patient:careProvider:Organization", true).withType("Practitioner").isLocked()); + + assertEquals("Patient:careProvider:Practitioner", new Include("Patient:careProvider:Organization", true).withType("Practitioner").getValue()); + assertEquals(true, new Include("Patient:careProvider:Organization", true).toLocked().withType("Practitioner").isLocked()); + + try { + new Include("").withType("Patient"); + fail(); + } catch (IllegalStateException e) { + // good + } + try { + new Include("Patient").withType("Patient"); + fail(); + } catch (IllegalStateException e) { + // good + } + try { + new Include("Patient:").withType("Patient"); + fail(); + } catch (IllegalStateException e) { + // good + } + } + + // @Test + public void testMixedContainedAndNonContained() throws Exception { + HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true"); + HttpResponse status = ourClient.execute(httpGet); + String responseContent = IOUtils.toString(status.getEntity().getContent()); + IOUtils.closeQuietly(status.getEntity().getContent()); + + ourLog.info(responseContent); + + assertEquals(200, status.getStatusLine().getStatusCode()); + Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent); + assertEquals(4, bundle.size()); + } + + @Test + public void testNoIncludes() throws Exception { + HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello"); HttpResponse status = ourClient.execute(httpGet); String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent()); assertEquals(200, status.getStatusLine().getStatusCode()); Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent); + assertEquals(1, bundle.size()); - ourLog.info(responseContent); + Patient p = bundle.getResources(Patient.class).get(0); + assertEquals(0, p.getName().size()); + assertEquals("Hello", p.getId().getIdPart()); + } - assertEquals(4, bundle.size()); - assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless()); - assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless()); - assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless()); - assertEquals(new IdDt("Organization/o2"), bundle.toListOfResources().get(3).getId().toUnqualifiedVersionless()); + @Test + public void testOneInclude() throws Exception { + HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo"); + HttpResponse status = ourClient.execute(httpGet); + String responseContent = IOUtils.toString(status.getEntity().getContent()); + IOUtils.closeQuietly(status.getEntity().getContent()); - Patient p1 = (Patient) bundle.toListOfResources().get(0); - assertEquals(0, p1.getContained().getContainedResources().size()); - - Patient p2 = (Patient) bundle.toListOfResources().get(1); - assertEquals(0, p2.getContained().getContainedResources().size()); + assertEquals(200, status.getStatusLine().getStatusCode()); + Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent); + assertEquals(1, bundle.size()); + Patient p = bundle.getResources(Patient.class).get(0); + assertEquals(1, p.getName().size()); + assertEquals("Hello", p.getId().getIdPart()); + assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue()); } @Test @@ -226,18 +270,6 @@ public class IncludeTest { } - @Test - public void testBadInclude() throws Exception { - HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=baz"); - HttpResponse status = ourClient.execute(httpGet); - assertEquals(400, status.getStatusLine().getStatusCode()); - String responseContent = IOUtils.toString(status.getEntity().getContent()); - IOUtils.closeQuietly(status.getEntity().getContent()); - - ourLog.info(responseContent); - assertThat(responseContent, containsString("Invalid _include parameter value")); - } - @AfterClass public static void afterClass() throws Exception { ourServer.stop(); @@ -268,27 +300,20 @@ public class IncludeTest { } - @ResourceDef(name = "Patient") - public static class ExtPatient extends Patient { - @Child(name = "secondOrg") - @Extension(url = "http://foo#secondOrg", definedLocally = false, isModifier = false) - private ResourceReferenceDt mySecondOrg; + public static void main(String[] args) { - @Override - public boolean isEmpty() { - return super.isEmpty() && ElementUtil.isEmpty(mySecondOrg); - } + Organization org = new Organization(); + org.setId("Organization/65546"); + org.getName().setValue("Contained Test Organization"); - public ResourceReferenceDt getSecondOrg() { - if (mySecondOrg == null) { - mySecondOrg = new ResourceReferenceDt(); - } - return mySecondOrg; - } + Patient patient = new Patient(); + patient.setId("Patient/1333"); + patient.addIdentifier("urn:mrns", "253345"); + patient.getManagingOrganization().setResource(patient); - public void setSecondOrg(ResourceReferenceDt theSecondOrg) { - mySecondOrg = theSecondOrg; - } + System.out.println(FhirContext.forDstu1().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient)); + + patient.getManagingOrganization().getReference(); } @@ -345,11 +370,10 @@ public class IncludeTest { */ public static class DummyPatientResourceProvider implements IResourceProvider { - @Search(queryName = "normalInclude") - public List normalInclude() { + @Search(queryName = "containedInclude") + public List containedInclude() { Organization o1 = new Organization(); o1.getName().setValue("o1"); - o1.setId("o1"); Patient p1 = new Patient(); p1.setId("p1"); @@ -364,25 +388,6 @@ public class IncludeTest { return Arrays.asList(p1, p2); } - @Search(queryName = "extInclude") - public List extInclude() { - Organization o1 = new Organization(); - o1.getName().setValue("o1"); - o1.setId("o1"); - - Patient p1 = new Patient(); - p1.setId("p1"); - p1.addIdentifier().setLabel("p1"); - p1.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1)); - - Patient p2 = new Patient(); - p2.setId("p2"); - p2.addIdentifier().setLabel("p2"); - p2.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1)); - - return Arrays.asList(p1, p2); - } - @Search(queryName = "declaredExtInclude") public List declaredExtInclude() { Organization o1 = new Organization(); @@ -407,20 +412,21 @@ public class IncludeTest { return Arrays.asList(p1, p2); } - @Search(queryName = "containedInclude") - public List containedInclude() { + @Search(queryName = "extInclude") + public List extInclude() { Organization o1 = new Organization(); o1.getName().setValue("o1"); + o1.setId("o1"); Patient p1 = new Patient(); p1.setId("p1"); p1.addIdentifier().setLabel("p1"); - p1.getManagingOrganization().setResource(o1); + p1.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1)); Patient p2 = new Patient(); p2.setId("p2"); p2.addIdentifier().setLabel("p2"); - p2.getManagingOrganization().setResource(o1); + p2.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1)); return Arrays.asList(p1, p2); } @@ -449,22 +455,48 @@ public class IncludeTest { return Patient.class; } + @Search(queryName = "normalInclude") + public List normalInclude() { + Organization o1 = new Organization(); + o1.getName().setValue("o1"); + o1.setId("o1"); + + Patient p1 = new Patient(); + p1.setId("p1"); + p1.addIdentifier().setLabel("p1"); + p1.getManagingOrganization().setResource(o1); + + Patient p2 = new Patient(); + p2.setId("p2"); + p2.addIdentifier().setLabel("p2"); + p2.getManagingOrganization().setResource(o1); + + return Arrays.asList(p1, p2); + } + } - public static void main(String[] args) { + @ResourceDef(name = "Patient") + public static class ExtPatient extends Patient { + @Child(name = "secondOrg") + @Extension(url = "http://foo#secondOrg", definedLocally = false, isModifier = false) + private ResourceReferenceDt mySecondOrg; - Organization org = new Organization(); - org.setId("Organization/65546"); - org.getName().setValue("Contained Test Organization"); + public ResourceReferenceDt getSecondOrg() { + if (mySecondOrg == null) { + mySecondOrg = new ResourceReferenceDt(); + } + return mySecondOrg; + } - Patient patient = new Patient(); - patient.setId("Patient/1333"); - patient.addIdentifier("urn:mrns", "253345"); - patient.getManagingOrganization().setResource(patient); + @Override + public boolean isEmpty() { + return super.isEmpty() && ElementUtil.isEmpty(mySecondOrg); + } - System.out.println(FhirContext.forDstu1().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient)); - - patient.getManagingOrganization().getReference(); + public void setSecondOrg(ResourceReferenceDt theSecondOrg) { + mySecondOrg = theSecondOrg; + } } diff --git a/pom.xml b/pom.xml index ad590bd4675..004e9ec2661 100644 --- a/pom.xml +++ b/pom.xml @@ -240,7 +240,7 @@ 9.2.14.v20151106 - 5.0.3.Final + 5.0.5.Final 5.2.2.Final 2.5.3 2.18.1 @@ -251,7 +251,7 @@ 1.1.8 2.7.1 4.3.6 - 4.2.2.RELEASE + 4.2.3.RELEASE 2.1.4.RELEASE 1.0.1 1.6 @@ -277,7 +277,7 @@ com.google.guava guava - 18.0 + 19.0 com.phloc @@ -392,12 +392,12 @@ org.apache.lucene lucene-highlighter - 5.3.0 + 5.3.1 org.apache.lucene lucene-analyzers-phonetic - 5.3.0 + 5.3.1 org.apache.maven.doxia @@ -407,17 +407,17 @@ org.apache.maven.scm maven-scm-api - 1.9 + 1.9.4 org.apache.maven.scm maven-scm-manager-plexus - 1.9 + 1.9.4 org.apache.maven.scm maven-scm-provider-gitexe - 1.9 + 1.9.4 org.apache.maven.wagon @@ -552,7 +552,7 @@ org.hibernate hibernate-search-orm - 5.5.0.Final + 5.5.1.Final org.javassist @@ -562,17 +562,17 @@ org.slf4j slf4j-android - 1.7.12 + 1.7.13 org.slf4j slf4j-api - 1.7.12 + 1.7.13 org.slf4j jcl-over-slf4j - 1.7.12 + 1.7.13 org.springframework @@ -663,7 +663,7 @@ org.apache.felix maven-bundle-plugin - 3.0.0 + 3.0.1 org.apache.maven.plugins @@ -931,12 +931,12 @@ org.apache.maven.plugins maven-checkstyle-plugin - 2.15 + 2.17 com.puppycrawl.tools checkstyle - 6.11.2 + 6.13 diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7d1d44d95bb..c10efad57cb 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -7,6 +7,16 @@ + + Bump the version of a few dependencies to the + latest versions (dependent HAPI modules listed in brackets): + +
  • Hibernate (JPA, Web Tester): 5.0.3 -> 5.0.5
  • +
  • Springframework (JPA, Web Tester): 4.2.2 -> 4.2.3
  • + + ]]> +
    Remove a dependency on a Java 1.7 class (ReflectiveOperationException) in several spots in the