From 0ece666c88f21f13746cccedc3650ccdaeafca55 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 2 Jul 2014 18:01:29 -0400 Subject: [PATCH 1/9] FIx a bunch more unit tests --- hapi-fhir-base/src/assembly/hapi-fhir-all.xml | 2 +- .../java/ca/uhn/fhir/context/FhirContext.java | 4 -- .../java/ca/uhn/fhir/parser/XmlParser.java | 2 +- .../uhn/fhir/rest/client/GenericClient.java | 3 +- .../rest/client/IRestfulClientFactory.java | 9 +++ .../rest/client/RestfulClientFactory.java | 3 + .../uhn/fhir/rest/server/RestfulServer.java | 2 +- hapi-fhir-base/src/site/site.xml | 40 +++++------ hapi-fhir-base/src/site/xdoc/index.xml | 2 +- .../ca/uhn/fhir/parser/XmlParserTest.java | 72 ++++++++++++------- .../ca/uhn/fhir/jpa/dao/FhirResourceDao.java | 9 ++- .../uhn/fhir/jpa/dao/FhirResourceDaoTest.java | 65 +++++++++++++++++ .../org.eclipse.core.resources.prefs | 1 + hapi-fhir-jpaserver-test/src/main/java/.keep | 0 .../test/CompleteResourceProviderTest.java | 1 - .../src/test/resources/.keep | 0 hapi-fhir-jpaserver-uhnfhirtest/.classpath | 10 +-- hapi-fhir-jpaserver-uhnfhirtest/.project | 4 +- .../.settings/org.eclipse.jdt.core.prefs | 4 +- .../org.eclipse.wst.common.component | 6 +- ....eclipse.wst.common.project.facet.core.xml | 4 +- hapi-fhir-jpaserver-uhnfhirtest/pom.xml | 4 +- .../WEB-INF/templates/tmpl-home-welcome.html | 35 +++++++++ .../src/main/webapp/WEB-INF/xsd/javaee_6.xsd | 1 - .../main/webapp/WEB-INF/templates/home.html | 9 +-- .../main/webapp/WEB-INF/templates/result.html | 2 +- .../WEB-INF/templates/tmpl-home-welcome.html | 8 +++ .../src/test/resources/.keep | 0 hapi-tinder-plugin/pom.xml | 35 +++++++++ hapi-tinder-test/.classpath | 26 ++++++- .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 8 +-- 32 files changed, 283 insertions(+), 90 deletions(-) create mode 100644 hapi-fhir-jpaserver-test/src/main/java/.keep create mode 100644 hapi-fhir-jpaserver-test/src/test/resources/.keep create mode 100644 hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html create mode 100644 hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html create mode 100644 hapi-fhir-testpage-overlay/src/test/resources/.keep diff --git a/hapi-fhir-base/src/assembly/hapi-fhir-all.xml b/hapi-fhir-base/src/assembly/hapi-fhir-all.xml index 55bdb67b3c5..f47dfeb810e 100644 --- a/hapi-fhir-base/src/assembly/hapi-fhir-all.xml +++ b/hapi-fhir-base/src/assembly/hapi-fhir-all.xml @@ -1,5 +1,5 @@ - + all diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java index e55941992b1..c9524f141a5 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java @@ -241,10 +241,6 @@ public class FhirContext { myNarrativeGenerator = theNarrativeGenerator; } - public void setRestfulClientFactory(IRestfulClientFactory theRestfulClientFactory) { - myRestfulClientFactory = theRestfulClientFactory; - } - private RuntimeResourceDefinition scanResourceType(Class theResourceType) { ArrayList> resourceTypes = new ArrayList>(); resourceTypes.add(theResourceType); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java index cd98809d817..8984644dc2d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java @@ -656,7 +656,7 @@ public class XmlParser extends BaseParser implements IParser { } else { if (StringUtils.isBlank(se.getName().getPrefix())) { theEventWriter.writeStartElement(se.getName().getLocalPart()); - theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI()); +// theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI()); } else { theEventWriter.writeStartElement(se.getName().getNamespaceURI(), se.getName().getLocalPart()); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/GenericClient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/GenericClient.java index ac11679c3a9..8f0154da513 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/GenericClient.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/GenericClient.java @@ -391,7 +391,8 @@ public class GenericClient extends BaseClient implements IGenericClient { public ForInternal(Class theResourceType) { myResourceType = theResourceType; - myResourceName = myContext.getResourceDefinition(theResourceType).getName(); + RuntimeResourceDefinition definition = myContext.getResourceDefinition(theResourceType); + myResourceName = definition.getName(); } public ForInternal(String theResourceName) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IRestfulClientFactory.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IRestfulClientFactory.java index 80dfdc92716..7b970aed7d6 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IRestfulClientFactory.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IRestfulClientFactory.java @@ -66,4 +66,13 @@ public interface IRestfulClientFactory { */ IGenericClient newGenericClient(String theServerBase); + + void setSocketTimeout(int theSocketTimeout); + + + void setConnectTimeout(int theConnectTimeout); + + + void setConnectionRequestTimeout(int theConnectionRequestTimeout); + } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java index 4002d79d4ea..2c10195c8c1 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java @@ -155,11 +155,13 @@ public class RestfulClientFactory implements IRestfulClientFactory { return new GenericClient(myContext, getHttpClient(), theServerBase); } + @Override public synchronized void setConnectionRequestTimeout(int theConnectionRequestTimeout) { myConnectionRequestTimeout = theConnectionRequestTimeout; myHttpClient=null; } + @Override public synchronized void setConnectTimeout(int theConnectTimeout) { myConnectTimeout = theConnectTimeout; myHttpClient=null; @@ -177,6 +179,7 @@ public class RestfulClientFactory implements IRestfulClientFactory { myHttpClient = theHttpClient; } + @Override public synchronized void setSocketTimeout(int theSocketTimeout) { mySocketTimeout = theSocketTimeout; myHttpClient=null; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java index c117e479ce5..99a6527f2d3 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java @@ -121,7 +121,7 @@ public class RestfulServer extends HttpServlet { *

*/ public void addHeadersToResponse(HttpServletResponse theHttpResponse) { - theHttpResponse.addHeader("X-PoweredBy", "HAPI FHIR " + VersionUtil.getVersion() + " RESTful Server"); + theHttpResponse.addHeader("X-Powered-By", "HAPI FHIR " + VersionUtil.getVersion() + " RESTful Server"); } private void assertProviderIsValid(Object theNext) throws ConfigurationException { diff --git a/hapi-fhir-base/src/site/site.xml b/hapi-fhir-base/src/site/site.xml index d2a51a81dd4..50a9795740a 100644 --- a/hapi-fhir-base/src/site/site.xml +++ b/hapi-fhir-base/src/site/site.xml @@ -1,6 +1,6 @@ - - + + HAPI images/hapi_fhir_banner.png @@ -21,6 +21,23 @@ + + + + + + + + + + + + + + @@ -57,24 +74,6 @@ - - - - - - - - - - - - - - - @@ -91,3 +90,4 @@ + diff --git a/hapi-fhir-base/src/site/xdoc/index.xml b/hapi-fhir-base/src/site/xdoc/index.xml index 51643ff9f22..1f6d7b8adc0 100644 --- a/hapi-fhir-base/src/site/xdoc/index.xml +++ b/hapi-fhir-base/src/site/xdoc/index.xml @@ -33,7 +33,7 @@ to the Maven repos and the Sourceforge download system. This release corrects a large number of bugs and includes fixes which were implemented in the recent FHIR Connectathon.
-    &emdash; James Agnew + James Agnew

diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java index 54fd21ebbdb..a67f82e72ce 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java @@ -74,7 +74,7 @@ public class XmlParserTest { patient.getGender().setValueAsEnum(AdministrativeGenderCodesEnum.M); - String val = new FhirContext().newXmlParser().encodeResourceToString(patient); + String val = ourCtx.newXmlParser().encodeResourceToString(patient); ourLog.info(val); } @@ -149,7 +149,7 @@ public class XmlParserTest { parameter.setUrl("http://foo").setValue(new StringDt("bar")); - String val = new FhirContext().newXmlParser().encodeResourceToString(q); + String val = ourCtx.newXmlParser().encodeResourceToString(q); ourLog.info(val); assertEquals("", val); @@ -214,7 +214,7 @@ public class XmlParserTest { ""; //@formatter:on - String encoded = new FhirContext().newXmlParser().encodeTagListToString(tagList); + String encoded = ourCtx.newXmlParser().encodeTagListToString(tagList); assertEquals(expected,encoded); } @@ -235,13 +235,13 @@ public class XmlParserTest { ""; //@formatter:off - Bundle bundleR = new FhirContext().newXmlParser().parseBundle(bundle); + Bundle bundleR = ourCtx.newXmlParser().parseBundle(bundle); assertEquals(15, bundleR.getTotalResults().getValue().intValue()); } @Test public void testEncodeExtensionWithResourceContent() { - IParser parser = new FhirContext().newXmlParser(); + IParser parser = ourCtx.newXmlParser(); Patient patient = new Patient(); patient.addAddress().setUse(AddressUseEnum.HOME); @@ -262,7 +262,7 @@ public class XmlParserTest { @Test public void testEncodeDeclaredExtensionWithResourceContent() { - IParser parser = new FhirContext().newXmlParser(); + IParser parser = ourCtx.newXmlParser(); MyPatientWithOneDeclaredExtension patient = new MyPatientWithOneDeclaredExtension(); patient.addAddress().setUse(AddressUseEnum.HOME); @@ -281,7 +281,7 @@ public class XmlParserTest { @Test public void testEncodeDeclaredExtensionWithAddressContent() { - IParser parser = new FhirContext().newXmlParser(); + IParser parser = ourCtx.newXmlParser(); MyPatientWithOneDeclaredAddressExtension patient = new MyPatientWithOneDeclaredAddressExtension(); patient.addAddress().setUse(AddressUseEnum.HOME); @@ -300,7 +300,7 @@ public class XmlParserTest { @Test public void testEncodeUndeclaredExtensionWithAddressContent() { - IParser parser = new FhirContext().newXmlParser(); + IParser parser = ourCtx.newXmlParser(); Patient patient = new Patient(); patient.addAddress().setUse(AddressUseEnum.HOME); @@ -323,7 +323,7 @@ public class XmlParserTest { Bundle b = new Bundle(); b.getTotalResults().setValue(123); - String val = new FhirContext().newXmlParser().setPrettyPrint(true).encodeBundleToString(b); + String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeBundleToString(b); ourLog.info(val); assertThat(val, StringContains.containsString("123")); @@ -338,12 +338,12 @@ public class XmlParserTest { e.setResource(new Patient()); e.addCategory().setLabel("label").setTerm("term").setScheme("scheme"); - String val = new FhirContext().newXmlParser().setPrettyPrint(true).encodeBundleToString(b); + String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeBundleToString(b); ourLog.info(val); assertThat(val, StringContains.containsString("")); - b = new FhirContext().newXmlParser().parseBundle(val); + b = ourCtx.newXmlParser().parseBundle(val); assertEquals(1, b.getEntries().size()); assertEquals(1, b.getEntries().get(0).getCategories().size()); assertEquals("term", b.getEntries().get(0).getCategories().get(0).getTerm()); @@ -398,7 +398,7 @@ public class XmlParserTest { spm.getText().setDiv("AAA"); rpt.addSpecimen().setResource(spm); - IParser p = new FhirContext(DiagnosticReport.class).newXmlParser().setPrettyPrint(true); + IParser p = ourCtx.newXmlParser().setPrettyPrint(true); String str = p.encodeResourceToString(rpt); ourLog.info(str); @@ -418,7 +418,7 @@ public class XmlParserTest { Observation obs = new Observation(); obs.setValue(new DecimalDt(112.22)); - IParser p = new FhirContext(Observation.class).newJsonParser(); + IParser p = ourCtx.newJsonParser(); try { p.encodeResourceToString(obs); @@ -435,7 +435,7 @@ public class XmlParserTest { patient.addName().addFamily("Family").addGiven("Given"); //@formatter:off - String encoded = new FhirContext().newXmlParser().setPrettyPrint(false).encodeResourceToString(patient); + String encoded = ourCtx.newXmlParser().setPrettyPrint(false).encodeResourceToString(patient); ourLog.info(encoded); /* * Note at least one space is placed where any whitespace was, as @@ -447,7 +447,7 @@ public class XmlParserTest { + " "; assertEquals(expected, encoded); - encoded = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient); + encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient); ourLog.info(encoded); expected = "\n" + " \n" @@ -476,7 +476,7 @@ public class XmlParserTest { Patient patient = new Patient(); patient.setManagingOrganization(new ResourceReferenceDt()); - IParser p = new FhirContext().newXmlParser(); + IParser p = ourCtx.newXmlParser(); String str = p.encodeResourceToString(patient); assertThat(str, IsNot.not(StringContains.containsString("managingOrganization"))); @@ -502,7 +502,7 @@ public class XmlParserTest { patient.addName().addFamily("Smith"); - IParser p = new FhirContext().newXmlParser(); + IParser p = ourCtx.newXmlParser(); String str = p.encodeResourceToString(patient); ourLog.info(str); @@ -745,7 +745,7 @@ public class XmlParserTest { NarrativeDt nar = new NarrativeDt(xhtmlDt, NarrativeStatusEnum.GENERATED); when(gen.generateNarrative(eq("http://hl7.org/fhir/profiles/Patient"), eq(patient))).thenReturn(nar); - FhirContext context = new FhirContext(); + FhirContext context = ourCtx; context.setNarrativeGenerator(gen); IParser p = context.newXmlParser(); String str = p.encodeResourceToString(patient); @@ -946,6 +946,26 @@ public class XmlParserTest { assertEquals("_id", res.getSearchParam().get(1).getName().getValue()); } + @Test + public void testParseEncodeNarrative() { + + String input = "
Donald null DUCK
Identifier7000135
Address10 Duxon Street
VICTORIA BC Can
Date of birth01 June 1980
"; + IResource res = ourCtx.newXmlParser().parseResource(input); + + String output = ourCtx.newXmlParser().encodeResourceToString(res); + + // Should occur exactly twice (once for the resource, once for the DIV + assertThat(output, (StringContainsInOrder.stringContainsInOrder(Arrays.asList("Patient xmlns", "div xmlns")))); + assertThat(output, not(StringContainsInOrder.stringContainsInOrder(Arrays.asList("b xmlns")))); + + output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(res); + + // Should occur exactly twice (once for the resource, once for the DIV + assertThat(output, (StringContainsInOrder.stringContainsInOrder(Arrays.asList("Patient xmlns", "div xmlns")))); + assertThat(output, not(StringContainsInOrder.stringContainsInOrder(Arrays.asList("b xmlns")))); + + } + @BeforeClass public static void beforeClass() { XMLUnit.setIgnoreAttributeOrder(true); @@ -989,10 +1009,10 @@ public class XmlParserTest { parent.addUndeclaredExtension(child2); // END SNIPPET: subExtension - String output = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient); + String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient); ourLog.info(output); - String enc = new FhirContext().newXmlParser().encodeResourceToString(patient); + String enc = ourCtx.newXmlParser().encodeResourceToString(patient); assertThat(enc, containsString("")); assertThat(enc, containsString("")); assertThat(enc, containsString("")); @@ -1008,13 +1028,13 @@ public class XmlParserTest { HumanNameDt given = name.addGiven("Joe"); ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#givenext", new StringDt("Hello")); given.addUndeclaredExtension(ext2); - String output = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient); + String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient); ourLog.info(output); - String enc = new FhirContext().newXmlParser().encodeResourceToString(patient); + String enc = ourCtx.newXmlParser().encodeResourceToString(patient); assertThat(enc, containsString("")); - Patient parsed = new FhirContext().newXmlParser().parseResource(Patient.class, new StringReader(enc)); + Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, new StringReader(enc)); assertEquals(1, parsed.getNameFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").size()); ExtensionDt ext = parsed.getNameFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").get(0); assertEquals("Hello", ext.getValueAsPrimitive().getValue()); @@ -1032,13 +1052,13 @@ public class XmlParserTest { ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#givenext", new StringDt("Hello")); family.addUndeclaredExtension(ext2); - String output = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient); + String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient); ourLog.info(output); - String enc = new FhirContext().newXmlParser().encodeResourceToString(patient); + String enc = ourCtx.newXmlParser().encodeResourceToString(patient); assertThat(enc, containsString("")); - Patient parsed = new FhirContext().newXmlParser().parseResource(Patient.class, new StringReader(enc)); + Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, new StringReader(enc)); assertEquals(1, parsed.getNameFirstRep().getFamilyFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").size()); ExtensionDt ext = parsed.getNameFirstRep().getFamilyFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").get(0); assertEquals("Hello", ext.getValueAsPrimitive().getValue()); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDao.java index 636718dace8..341f92c2547 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDao.java @@ -374,7 +374,10 @@ public class FhirResourceDao extends BaseFhirDao implements throw new IllegalArgumentException("Invalid token type: " + params.getClass()); } - Predicate singleCode = builder.equal(from.get("myValueNormalized"), normalizeString(string)); + String likeExpression = normalizeString(string); + likeExpression = likeExpression.replace("%", "[%]") + "%"; + + Predicate singleCode = builder.like(from.get("myValueNormalized").as(String.class), likeExpression); if (params instanceof StringParam && ((StringParam) params).isExact()) { Predicate exactCode = builder.equal(from.get("myValueExact"), string); singleCode = builder.and(singleCode, exactCode); @@ -772,6 +775,10 @@ public class FhirResourceDao extends BaseFhirDao implements } private void loadResourcesByPid(Collection theIncludePids, List theResourceListToPopulate) { + if (theIncludePids.isEmpty()) { + return; + } + CriteriaBuilder builder = myEntityManager.getCriteriaBuilder(); CriteriaQuery cq = builder.createQuery(ResourceTable.class); Root from = cq.from(ResourceTable.class); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoTest.java index c4e7e2ceade..1781e4d0e2d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoTest.java @@ -16,6 +16,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; @@ -37,6 +38,7 @@ import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.InstantDt; import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.rest.api.MethodOutcome; +import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.QualifiedDateParam; import ca.uhn.fhir.rest.param.ReferenceParam; @@ -58,7 +60,50 @@ public class FhirResourceDaoTest { private static Date ourTestStarted; private static IFhirResourceDao ourEncounterDao; + private static FhirContext ourFhirCtx; + @Test + public void testOrganizationName() { + + //@formatter:off + String inputStr = "{\"resourceType\":\"Organization\",\n" + + " \"extension\":[\n" + + " {\n" + + " \"url\":\"http://fhir.connectinggta.ca/Profile/organization#providerIdPool\",\n" + + " \"valueUri\":\"urn:oid:2.16.840.1.113883.3.239.23.21.1\"\n" + + " }\n" + + " ],\n" + + " \"text\":{\n" + + " \"status\":\"empty\",\n" + + " \"div\":\"
No narrative template available for resource profile: http://fhir.connectinggta.ca/Profile/organization
\"\n" + + " },\n" + + " \"identifier\":[\n" + + " {\n" + + " \"use\":\"official\",\n" + + " \"label\":\"HSP 2.16.840.1.113883.3.239.23.21\",\n" + + " \"system\":\"urn:cgta:hsp_ids\",\n" + + " \"value\":\"urn:oid:2.16.840.1.113883.3.239.23.21\"\n" + + " }\n" + + " ],\n" + + " \"name\":\"Peterborough Regional Health Centre\"\n" + + " }\n" + + " }"; + //@formatter:on + + Set val = ourOrganizationDao.searchForIds("name", new StringParam("P")); + int initial = val.size(); + + Organization org = ourFhirCtx.newJsonParser().parseResource(Organization.class,inputStr); + ourOrganizationDao.create(org); + + val = ourOrganizationDao.searchForIds("name", new StringParam("P")); + assertEquals(initial+1, val.size()); + + } + + + + @Test public void testStoreUnversionedResources() { Organization o1 = new Organization(); @@ -206,6 +251,23 @@ public class FhirResourceDaoTest { } + @Test + public void testSearchWithNoResults() { + IBundleProvider value = ourObservationDao.search(new SearchParameterMap()); + + /* + * This may fail at some point, which means another test has probably added a device + * resource. This test depends on there being none, so if that happens this test + * should be refactored to use another resource type + */ + assertEquals(0, value.size()); + + List res = value.getResources(0, 0); + assertTrue(res.isEmpty()); + + } + + @Test public void testPersistSearchParamQuantity() { Observation obs = new Observation(); @@ -222,6 +284,8 @@ public class FhirResourceDaoTest { } + + @Test public void testPersistSearchParams() { Patient patient = new Patient(); @@ -878,6 +942,7 @@ public class FhirResourceDaoTest { ourOrganizationDao = ourCtx.getBean("myOrganizationDao", IFhirResourceDao.class); ourLocationDao = ourCtx.getBean("myLocationDao", IFhirResourceDao.class); ourEncounterDao = ourCtx.getBean("myEncounterDao", IFhirResourceDao.class); + ourFhirCtx = new FhirContext(); } } diff --git a/hapi-fhir-jpaserver-test/.settings/org.eclipse.core.resources.prefs b/hapi-fhir-jpaserver-test/.settings/org.eclipse.core.resources.prefs index 49da3845e5b..62804f2210d 100644 --- a/hapi-fhir-jpaserver-test/.settings/org.eclipse.core.resources.prefs +++ b/hapi-fhir-jpaserver-test/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 encoding//src/main/resources=UTF-8 encoding//src/test/java=UTF-8 encoding//src/test/java/ca/uhn/fhir/jpa/test/Upload.java=UTF-8 diff --git a/hapi-fhir-jpaserver-test/src/main/java/.keep b/hapi-fhir-jpaserver-test/src/main/java/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/hapi-fhir-jpaserver-test/src/test/java/ca/uhn/fhir/jpa/test/CompleteResourceProviderTest.java b/hapi-fhir-jpaserver-test/src/test/java/ca/uhn/fhir/jpa/test/CompleteResourceProviderTest.java index 5782a5a3d9d..af2d8eabe07 100644 --- a/hapi-fhir-jpaserver-test/src/test/java/ca/uhn/fhir/jpa/test/CompleteResourceProviderTest.java +++ b/hapi-fhir-jpaserver-test/src/test/java/ca/uhn/fhir/jpa/test/CompleteResourceProviderTest.java @@ -32,7 +32,6 @@ public class CompleteResourceProviderTest { private static ClassPathXmlApplicationContext ourAppCtx; private static FhirContext ourCtx; - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompleteResourceProviderTest.class); private static Server ourServer; private static IFhirResourceDao patientDao; diff --git a/hapi-fhir-jpaserver-test/src/test/resources/.keep b/hapi-fhir-jpaserver-test/src/test/resources/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/hapi-fhir-jpaserver-uhnfhirtest/.classpath b/hapi-fhir-jpaserver-uhnfhirtest/.classpath index 7f746073bd4..c998deb489c 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/.classpath +++ b/hapi-fhir-jpaserver-uhnfhirtest/.classpath @@ -23,16 +23,16 @@ - - - - - + + + + + diff --git a/hapi-fhir-jpaserver-uhnfhirtest/.project b/hapi-fhir-jpaserver-uhnfhirtest/.project index 2a9e8a7e783..ec591debe6f 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/.project +++ b/hapi-fhir-jpaserver-uhnfhirtest/.project @@ -21,12 +21,12 @@ - org.eclipse.m2e.core.maven2Builder + org.eclipse.wst.validation.validationbuilder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder diff --git a/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.jdt.core.prefs b/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.jdt.core.prefs index e3d8562dd6a..6b5aebc4b56 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.jdt.core.prefs +++ b/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate @@ -10,4 +10,4 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.component b/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.component index 6d0a6b16cdc..80e4d9af87c 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.component +++ b/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.component @@ -1,18 +1,18 @@ - - + + uses uses - + consumes diff --git a/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.project.facet.core.xml b/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.project.facet.core.xml index 5a887262619..45fbdef1fd7 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,7 +1,7 @@ - - + + diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml index cff878db2c7..985efbb2952 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml @@ -144,8 +144,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html new file mode 100644 index 00000000000..55cd95bf386 --- /dev/null +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html @@ -0,0 +1,35 @@ + + +
+

+ This is the home for the FHIR test server operated by + University Health Network. +

+

+ This is not a production server! + Do not store any information here that contains personal health information + or otherwise confidential information. This server will be regularly purged + and reloaded with fixed test data. +

+

+ Here are some things you might wish to try: +

+
    +
  • + View a + list of patients + on this server. +
  • +
  • + Construct a + search query + on this server. +
  • +
  • + Access a + different server + (use the Server menu at the top of the page to see a list of public FHIR servers) +
  • +
+
+ diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/xsd/javaee_6.xsd b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/xsd/javaee_6.xsd index c34f199542b..b1ee0b83831 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/xsd/javaee_6.xsd +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/xsd/javaee_6.xsd @@ -127,7 +127,6 @@ type="javaee:ejb-local-refType" minOccurs="0" maxOccurs="unbounded"/> - -
-
- This is a RESTful server tester, which can be used to send - requests to, and receive responses from the server at the - following URL: -
+
@@ -179,8 +174,6 @@ - - diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/result.html b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/result.html index 6d63d454c93..8ef154b0ab6 100644 --- a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/result.html +++ b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/result.html @@ -100,7 +100,7 @@ controls for viewing/editing/etc results -->
-
+

diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html new file mode 100644 index 00000000000..d4862ea4080 --- /dev/null +++ b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html @@ -0,0 +1,8 @@ + + +
+
+ This is a RESTful server tester, which can be used to send + requests to, and receive responses from the server. +
+ diff --git a/hapi-fhir-testpage-overlay/src/test/resources/.keep b/hapi-fhir-testpage-overlay/src/test/resources/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/hapi-tinder-plugin/pom.xml b/hapi-tinder-plugin/pom.xml index afde8f031e6..465e0f2764d 100644 --- a/hapi-tinder-plugin/pom.xml +++ b/hapi-tinder-plugin/pom.xml @@ -133,6 +133,41 @@ mojo-descriptor descriptor --> + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-plugin-plugin + + + [3.2,) + + + descriptor + + + + + + + + + + + + diff --git a/hapi-tinder-test/.classpath b/hapi-tinder-test/.classpath index 0b07f0f6d72..f6f879ee90e 100644 --- a/hapi-tinder-test/.classpath +++ b/hapi-tinder-test/.classpath @@ -1,12 +1,16 @@ - - + + + + + + + - @@ -43,5 +47,21 @@ + + + + + + + + + + + + + + + + diff --git a/hapi-tinder-test/.settings/org.eclipse.core.resources.prefs b/hapi-tinder-test/.settings/org.eclipse.core.resources.prefs index 99f26c0203a..f02244085c1 100644 --- a/hapi-tinder-test/.settings/org.eclipse.core.resources.prefs +++ b/hapi-tinder-test/.settings/org.eclipse.core.resources.prefs @@ -1,2 +1,4 @@ eclipse.preferences.version=1 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 encoding/=UTF-8 diff --git a/hapi-tinder-test/.settings/org.eclipse.jdt.core.prefs b/hapi-tinder-test/.settings/org.eclipse.jdt.core.prefs index 76192a5a178..60105c1b951 100644 --- a/hapi-tinder-test/.settings/org.eclipse.jdt.core.prefs +++ b/hapi-tinder-test/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,5 @@ -#Mon Mar 03 17:20:36 EST 2014 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.6 From ca83de38b8bc00af8629e404238ba4a7b5f17d7b Mon Sep 17 00:00:00 2001 From: James Date: Wed, 2 Jul 2014 18:10:20 -0400 Subject: [PATCH 2/9] Fix tester breakage --- .../ca/uhn/fhirtest/FhirContextFactory.java | 65 +++++++++++++++++++ .../WEB-INF/hapi-fhir-tester-config.xml | 7 +- 2 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/FhirContextFactory.java diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/FhirContextFactory.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/FhirContextFactory.java new file mode 100644 index 00000000000..760059631e1 --- /dev/null +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/FhirContextFactory.java @@ -0,0 +1,65 @@ +package ca.uhn.fhirtest; + +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; + +import ca.uhn.fhir.context.FhirContext; + +public class FhirContextFactory implements FactoryBean, InitializingBean { + + private int myConnectionRequestTimeout = 5000; + private int mySocketTimeout = 10000; + private int myConnectTimeout = 4000; + public int getConnectionRequestTimeout() { + return myConnectionRequestTimeout; + } + + public void setConnectionRequestTimeout(int theConnectionRequestTimeout) { + myConnectionRequestTimeout = theConnectionRequestTimeout; + } + + public int getSocketTimeout() { + return mySocketTimeout; + } + + public void setSocketTimeout(int theSocketTimeout) { + mySocketTimeout = theSocketTimeout; + } + + public int getConnectTimeout() { + return myConnectTimeout; + } + + public void setConnectTimeout(int theConnectTimeout) { + myConnectTimeout = theConnectTimeout; + } + + private FhirContext myCtx; + + public FhirContextFactory() { + } + + @Override + public FhirContext getObject() throws Exception { + return myCtx; + } + + @Override + public Class getObjectType() { + return FhirContext.class; + } + + @Override + public boolean isSingleton() { + return true; + } + + @Override + public void afterPropertiesSet() throws Exception { + myCtx=new FhirContext(); + myCtx.getRestfulClientFactory().setConnectTimeout(myConnectTimeout); + myCtx.getRestfulClientFactory().setSocketTimeout(mySocketTimeout); + myCtx.getRestfulClientFactory().setConnectionRequestTimeout(myConnectionRequestTimeout); + } + +} diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml index 22f468a9022..9a0d43d1ea1 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml @@ -20,12 +20,7 @@ - - - - - - + From ad344f700dab2494f3ddf878255a03ac5990cbf5 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Wed, 2 Jul 2014 18:10:50 -0400 Subject: [PATCH 3/9] Config changes --- .../webapp/WEB-INF/hapi-fhir-server-database-config.xml | 6 +++--- .../src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-server-database-config.xml b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-server-database-config.xml index 3ac78fb9816..e57d46c69c1 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-server-database-config.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-server-database-config.xml @@ -28,9 +28,9 @@ - + - + @@ -49,4 +49,4 @@ - \ No newline at end of file + diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml index 22f468a9022..1f9957cfb6b 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml @@ -11,7 +11,7 @@ - home , Localhost Server , http://localhost:8888/base + home , UHN/HAPI Server , http://fhirtest.uhn.ca/base hi , Health Intersections , http://fhir.healthintersections.com.au/open furore , Spark - Furore Reference Server , http://spark.furore.com/fhir blaze , Blaze (Orion Health) , https://his-medicomp-gateway.orionhealth.com/blaze/fhir @@ -32,4 +32,4 @@ - \ No newline at end of file + From ab9e681ed223d96d070b4d59ef01364e4fc8f3fc Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Thu, 3 Jul 2014 08:51:42 -0400 Subject: [PATCH 4/9] Start adding transaction to tester --- .../jpa/provider/JpaConformanceProvider.java | 19 +++-- .../org.eclipse.wst.common.component | 2 +- hapi-fhir-jpaserver-uhnfhirtest/pom.xml | 25 +++++++ .../ca/uhn/fhirtest/TestRestfulServer.java | 3 + .../hapi-fhir-server-database-config.xml | 2 +- .../WEB-INF/templates/tmpl-home-welcome.html | 4 +- .../src/main/webapp/WEB-INF/web.xml | 4 + .../src/main/webapp/WEB-INF/xsd/javaee_6.xsd | 2 - .../java/ca/uhn/fhirtest/UhnFhirTestApp.java | 2 +- .../org.eclipse.wst.common.component | 1 - hapi-fhir-testpage-overlay/pom.xml | 8 +- .../main/java/ca/uhn/fhir/to/Controller.java | 66 ++++++++++++++--- .../uhn/fhir/to/model/TransactionRequest.java | 18 +++++ .../WEB-INF/hapi-fhir-tester-config.xml | 7 -- .../main/webapp/WEB-INF/templates/home.html | 73 ++++++++++++++++--- .../WEB-INF/templates/tmpl-home-welcome.html | 9 ++- .../WEB-INF/templates/tmpl-navbar-left.html | 2 +- hapi-tinder-test/pom.xml | 29 ++++++++ 18 files changed, 225 insertions(+), 51 deletions(-) create mode 100644 hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/model/TransactionRequest.java diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaConformanceProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaConformanceProvider.java index 55ff548e03d..bc5bef6062f 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaConformanceProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/JpaConformanceProvider.java @@ -7,11 +7,13 @@ import ca.uhn.fhir.model.dstu.resource.Conformance; import ca.uhn.fhir.model.dstu.resource.Conformance.Rest; import ca.uhn.fhir.model.dstu.resource.Conformance.RestResource; import ca.uhn.fhir.model.primitive.DecimalDt; +import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider; public class JpaConformanceProvider extends ServerConformanceProvider { + private String myImplementationDescription; private IFhirSystemDao mySystemDao; public JpaConformanceProvider(RestfulServer theRestfulServer, IFhirSystemDao theSystemDao) { @@ -19,24 +21,29 @@ public class JpaConformanceProvider extends ServerConformanceProvider { mySystemDao = theSystemDao; super.setCache(false); } - - + @Override public Conformance getServerConformance() { - + Map counts = mySystemDao.getResourceCounts(); - + Conformance retVal = super.getServerConformance(); for (Rest nextRest : retVal.getRest()) { for (RestResource nextResource : nextRest.getResource()) { Long count = counts.get(nextResource.getType().getValueAsString()); - if (count!=null) { + if (count != null) { nextResource.addUndeclaredExtension(false, "http://hl7api.sourceforge.net/hapi-fhir/res/extdefs.html#resourceCount", new DecimalDt(count)); } } } - + + retVal.getImplementation().setDescription(myImplementationDescription); + return retVal; } + public void setImplementationDescription(String theImplDesc) { + myImplementationDescription = theImplDesc; + } + } diff --git a/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.component b/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.component index 80e4d9af87c..8afc76cec3a 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.component +++ b/hapi-fhir-jpaserver-uhnfhirtest/.settings/org.eclipse.wst.common.component @@ -12,7 +12,7 @@ uses - + consumes diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml index 985efbb2952..dc413dc9e05 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml @@ -148,6 +148,31 @@ 1.7 + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + + [0.4,) + + + + + + + + + + + + diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java index 269693e9bcd..47a4c874045 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java @@ -55,7 +55,10 @@ public class TestRestfulServer extends RestfulServer { JpaSystemProvider sp = new JpaSystemProvider(systemDao); setPlainProviders(sp); + String implDesc = getInitParameter("ImplementationDescription"); + JpaConformanceProvider confProvider = new JpaConformanceProvider(this, systemDao); + confProvider.setImplementationDescription(implDesc); setServerConformanceProvider(confProvider); setUseBrowserFriendlyContentTypes(true); diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-server-database-config.xml b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-server-database-config.xml index 3ac78fb9816..19ed430576d 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-server-database-config.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/hapi-fhir-server-database-config.xml @@ -30,7 +30,7 @@ - + diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html index 55cd95bf386..90ca83c831e 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/templates/tmpl-home-welcome.html @@ -17,12 +17,12 @@
  • View a - list of patients + list of patients on this server.
  • Construct a - search query + search query on this server.
  • diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/web.xml b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/web.xml index 40a6bc71310..adbee6f7be4 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/web.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/web.xml @@ -35,6 +35,10 @@ fhirServlet ca.uhn.fhirtest.TestRestfulServer + + ImplementationDescription + UHN Test Server + 1 diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/xsd/javaee_6.xsd b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/xsd/javaee_6.xsd index b1ee0b83831..9fb587749ce 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/xsd/javaee_6.xsd +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/webapp/WEB-INF/xsd/javaee_6.xsd @@ -75,8 +75,6 @@ - - diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/test/java/ca/uhn/fhirtest/UhnFhirTestApp.java b/hapi-fhir-jpaserver-uhnfhirtest/src/test/java/ca/uhn/fhirtest/UhnFhirTestApp.java index 32c82ed9d20..f9be1f23344 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/test/java/ca/uhn/fhirtest/UhnFhirTestApp.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/test/java/ca/uhn/fhirtest/UhnFhirTestApp.java @@ -23,7 +23,7 @@ public class UhnFhirTestApp { public static void main(String[] args) throws Exception { // new File("target/testdb").mkdirs(); - System.setProperty("fhir.db.location", "target/testdb"); + System.setProperty("fhir.db.location", "/target/testdb"); int myPort = 8888; Server server = new Server(myPort); diff --git a/hapi-fhir-testpage-overlay/.settings/org.eclipse.wst.common.component b/hapi-fhir-testpage-overlay/.settings/org.eclipse.wst.common.component index d088b0783b8..d2052e8be95 100644 --- a/hapi-fhir-testpage-overlay/.settings/org.eclipse.wst.common.component +++ b/hapi-fhir-testpage-overlay/.settings/org.eclipse.wst.common.component @@ -3,7 +3,6 @@ - uses diff --git a/hapi-fhir-testpage-overlay/pom.xml b/hapi-fhir-testpage-overlay/pom.xml index 2108c28a8de..0dfc35e73f2 100644 --- a/hapi-fhir-testpage-overlay/pom.xml +++ b/hapi-fhir-testpage-overlay/pom.xml @@ -31,10 +31,10 @@ - javax.servlet - javax.servlet-api - 3.0.1 - provided + javax.servlet + javax.servlet-api + 3.1.0 + provided diff --git a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java index 1aa2e347b69..d12d48def68 100644 --- a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java +++ b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java @@ -50,6 +50,7 @@ import ca.uhn.fhir.rest.server.Constants; import ca.uhn.fhir.rest.server.EncodingEnum; import ca.uhn.fhir.to.model.HomeRequest; import ca.uhn.fhir.to.model.ResourceRequest; +import ca.uhn.fhir.to.model.TransactionRequest; @org.springframework.stereotype.Controller() public class Controller { @@ -67,6 +68,39 @@ public class Controller { @Autowired private TemplateEngine myTemplateEngine; + @RequestMapping(value = { "/transaction" }) + public String actionTransaction(final TransactionRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) { + addCommonParams(theRequest, theModel); + + GenericClient client = theRequest.newClient(myCtx, myConfig); + + String body = preProcessMessageBody(theRequest.getTransactionBody()); + + Bundle bundle; + try { + if (body.startsWith("{")) { + bundle = myCtx.newJsonParser().parseBundle(body); + } else if (body.startsWith("<")) { + bundle = myCtx.newXmlParser().parseBundle(body); + } else { + theModel.put("errorMsg", "Message body does not appear to be a valid FHIR resource instance document. Body should start with '<' (for XML encoding) or '{' (for JSON encoding)."); + return "home"; + } + } catch (DataFormatException e) { + ourLog.warn("Failed to parse bundle", e); + theModel.put("errorMsg", "Failed to parse transaction bundle body. Error was: " + e.getMessage()); + return "home"; + } + + long start = System.currentTimeMillis(); +// client.tr + long delay = System.currentTimeMillis() - start; + + processAndAddLastClientInvocation(client, ResultType.RESOURCE, theModel, delay, "Loaded conformance"); + + return "result"; + } + @RequestMapping(value = { "/conformance" }) public String actionConformance(final HomeRequest theRequest, final BindingResult theBindingResult, final ModelMap theModel) { addCommonParams(theRequest, theModel); @@ -427,18 +461,7 @@ public class Controller { return; } - body = body.trim(); - - StringBuilder b = new StringBuilder(); - for (int i = 0; i < body.length(); i++) { - char nextChar = body.charAt(i); - int nextCharI = nextChar; - if (nextCharI == 65533) { - continue; - } - b.append(nextChar); - } - body = b.toString(); + body = preProcessMessageBody(body); IResource resource; try { @@ -485,6 +508,25 @@ public class Controller { } + private String preProcessMessageBody(String theBody) { + if(theBody==null) { + return ""; + } + String retVal = theBody.trim(); + + StringBuilder b = new StringBuilder(); + for (int i = 0; i < retVal.length(); i++) { + char nextChar = retVal.charAt(i); + int nextCharI = nextChar; + if (nextCharI == 65533) { + continue; + } + b.append(nextChar); + } + retVal = b.toString(); + return retVal; + } + private void doActionHistory(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel, String theMethod, String theMethodDescription) { addCommonParams(theRequest, theModel); diff --git a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/model/TransactionRequest.java b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/model/TransactionRequest.java new file mode 100644 index 00000000000..759297cc6a5 --- /dev/null +++ b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/model/TransactionRequest.java @@ -0,0 +1,18 @@ +package ca.uhn.fhir.to.model; + +import org.springframework.web.bind.annotation.ModelAttribute; + +public class TransactionRequest extends HomeRequest { + + private String myTransactionBody; + + @ModelAttribute("transactionBody") + public String getTransactionBody() { + return myTransactionBody; + } + + public void setTransactionBody(String theTransactionBody) { + myTransactionBody = theTransactionBody; + } + +} diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml index 5f57a04ea06..7475d779ff2 100644 --- a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml +++ b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/hapi-fhir-tester-config.xml @@ -21,12 +21,5 @@ - - - - - - - \ No newline at end of file diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/home.html b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/home.html index 03c7f73c88f..47242ad2e2a 100644 --- a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/home.html +++ b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/home.html @@ -31,22 +31,22 @@

- + + + + + - - - -
Server HAPI Restful Server
Software + - +
FHIR Base
Software - - -
@@ -67,7 +67,7 @@ Retrieve the server's conformance statement.
-
+
+ + +
+
+ Post a bundle containing multiple resources to the server and + store all resources within a single atomic transaction. +
+
+
+ +
+
+
+
+
+ Bundle + * +
+ +
+
+
+ +
+
@@ -151,7 +206,7 @@ Show all of the tags currently in use on the server
-
+