Bump spring version and refactor examples

This commit is contained in:
James 2017-01-29 22:55:22 -05:00
parent d3ef52d49d
commit ce80007f8d
16 changed files with 54 additions and 35 deletions

View File

@ -5,6 +5,7 @@
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.3-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
<packaging>jar</packaging>
@ -41,6 +42,7 @@
<dependency>
<groupId>org.ebaysf.web</groupId>
<artifactId>cors-filter</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>

View File

@ -4,7 +4,8 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.1-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
<artifactId>hapi-fhir-standalone-overlay-example</artifactId>
<build>
@ -36,14 +37,14 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.1-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.1-SNAPSHOT</version>
<version>2.3-SNAPSHOT</version>
<classifier>classes</classifier>
<scope>provided</scope>
</dependency>
@ -73,6 +74,7 @@
<dependency>
<groupId>org.ebaysf.web</groupId>
<artifactId>cors-filter</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>

View File

@ -28,10 +28,7 @@ import java.io.Reader;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.GZIPInputStream;
import javax.servlet.http.HttpServletRequest;
@ -41,7 +38,6 @@ import org.apache.commons.io.IOUtils;
import org.apache.http.entity.ContentType;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.method.BaseMethodBinding;
import ca.uhn.fhir.rest.method.BaseMethodBinding.IRequestReader;
import ca.uhn.fhir.rest.method.RequestDetails;
@ -168,17 +164,6 @@ public class ServletRequestDetails extends RequestDetails {
this.myServletResponse = myServletResponse;
}
public static RequestDetails withResourceAndParams(String theResourceName, RequestTypeEnum theRequestType, Set<String> theParamNames) {
RequestDetails retVal = new ServletRequestDetails();
retVal.setResourceName(theResourceName);
retVal.setRequestType(theRequestType);
Map<String, String[]> paramNames = new HashMap<String, String[]>();
for (String next : theParamNames) {
paramNames.put(next, new String[0]);
}
retVal.setParameters(paramNames);
return retVal;
}
@Override
public Charset getCharset() {

View File

@ -419,6 +419,7 @@
<configuration>
<runOrder>alphabetical</runOrder>
<argLine>${argLine} -Dfile.encoding=UTF-8 -Xmx1024m</argLine>
<forkCount>0.6C</forkCount>
</configuration>
</plugin>
<plugin>

View File

@ -2,12 +2,17 @@ package ca.uhn.fhir.rest.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
@ -54,7 +59,7 @@ public class ResourceMethodTest {
inputParams.add("lastName");
inputParams.add("mrn");
RequestDetails params = ServletRequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams);
RequestDetails params = withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams);
boolean actual = rm.incomingServerRequestMatchesMethod(params);
assertTrue( actual); // True
}
@ -75,7 +80,7 @@ public class ResourceMethodTest {
inputParams.add("mrn");
inputParams.add("foo");
assertEquals(false, rm.incomingServerRequestMatchesMethod(ServletRequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // False
assertEquals(false, rm.incomingServerRequestMatchesMethod(withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // False
}
@Test
@ -92,7 +97,7 @@ public class ResourceMethodTest {
inputParams.add("firstName");
inputParams.add("mrn");
assertEquals(true, rm.incomingServerRequestMatchesMethod(ServletRequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // True
assertEquals(true, rm.incomingServerRequestMatchesMethod(withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // True
}
@Test
@ -109,7 +114,7 @@ public class ResourceMethodTest {
inputParams.add("firstName");
inputParams.add("lastName");
assertEquals(false, rm.incomingServerRequestMatchesMethod(ServletRequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // False
assertEquals(false, rm.incomingServerRequestMatchesMethod(withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // False
}
@Test
@ -124,7 +129,7 @@ public class ResourceMethodTest {
Set<String> inputParams = new HashSet<String>();
inputParams.add("mrn");
assertEquals(true, rm.incomingServerRequestMatchesMethod(ServletRequestDetails.withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // True
assertEquals(true, rm.incomingServerRequestMatchesMethod(withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams))); // True
}
@Test(expected=IllegalStateException.class)
@ -142,4 +147,18 @@ public class ResourceMethodTest {
TestUtil.clearAllStaticFieldsForUnitTest();
}
public static RequestDetails withResourceAndParams(String theResourceName, RequestTypeEnum theRequestType, Set<String> theParamNames) {
ServletRequestDetails retVal = new ServletRequestDetails();
retVal.setResourceName(theResourceName);
retVal.setRequestType(theRequestType);
Map<String, String[]> paramNames = new HashMap<String, String[]>();
for (String next : theParamNames) {
paramNames.put(next, new String[0]);
}
retVal.setParameters(paramNames);
retVal.setServletRequest(mock(HttpServletRequest.class));
return retVal;
}
}

View File

@ -21,9 +21,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.dao.*;
@Configuration
public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jpa.config${package_suffix}.Base${versionCapitalized}Config {
@ -49,12 +47,23 @@ public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jp
#foreach ( $res in $resources )
@Bean(name="my${res.name}Dao${versionCapitalized}", autowire=Autowire.BY_NAME)
@Lazy
public IFhirResourceDao<${resourcePackage}.${res.declaringClassNameComplete}> dao${res.declaringClassNameComplete}${versionCapitalized}() {
ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${versionCapitalized}<${resourcePackage}.${res.declaringClassNameComplete}> retVal;
#if ( ${versionCapitalized} != 'Dstu1' && ( ${res.name} == 'Bundle' || ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'ValueSet' || ${res.name} == 'QuestionnaireResponse' || ${res.name} == 'SearchParameter' || ${res.name} == 'CodeSystem'))
retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized}();
public
#if ( ${versionCapitalized} == 'Dstu2' && ${res.name} == 'ValueSet' )
IFhirResourceDaoValueSet<ca.uhn.fhir.model.dstu2.resource.ValueSet, ca.uhn.fhir.model.dstu2.composite.CodingDt, ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt>
#elseif ( ${versionCapitalized} == 'Dstu3' && ${res.name} == 'ValueSet' )
IFhirResourceDaoValueSet<org.hl7.fhir.dstu3.model.ValueSet, org.hl7.fhir.dstu3.model.Coding, org.hl7.fhir.dstu3.model.CodeableConcept>
#elseif ( ${versionCapitalized} == 'Dstu3' && ${res.name} == 'CodeSystem' )
IFhirResourceDaoCodeSystem<org.hl7.fhir.dstu3.model.CodeSystem, org.hl7.fhir.dstu3.model.Coding, org.hl7.fhir.dstu3.model.CodeableConcept>
#elseif ( ${versionCapitalized} != 'Dstu1' && ( ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'SearchParameter'))
IFhirResourceDao${res.name}<${resourcePackage}.${res.declaringClassNameComplete}>
#else
retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${versionCapitalized}<${resourcePackage}.${res.declaringClassNameComplete}>();
IFhirResourceDao<${resourcePackage}.${res.declaringClassNameComplete}>
#end
dao${res.declaringClassNameComplete}${versionCapitalized}() {
#if ( ${versionCapitalized} != 'Dstu1' && ( ${res.name} == 'Bundle' || ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'ValueSet' || ${res.name} == 'QuestionnaireResponse' || ${res.name} == 'SearchParameter' || ${res.name} == 'CodeSystem'))
ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized} retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized}();
#else
ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${versionCapitalized}<${resourcePackage}.${res.declaringClassNameComplete}> retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${versionCapitalized}<${resourcePackage}.${res.declaringClassNameComplete}>();
#end
retVal.setResourceType(${resourcePackage}.${res.declaringClassNameComplete}.class);
retVal.setContext(fhirContext${versionCapitalized}());

View File

@ -325,7 +325,7 @@
<maven_source_plugin_version>2.4</maven_source_plugin_version>
<phloc_schematron_version>2.7.1</phloc_schematron_version>
<phloc_commons_version>4.4.6</phloc_commons_version>
<spring_version>4.3.1.RELEASE</spring_version>
<spring_version>4.3.4.RELEASE</spring_version>
<thymeleaf-version>3.0.1.RELEASE</thymeleaf-version>
<xmlunit_version>1.6</xmlunit_version>
@ -1642,7 +1642,8 @@
<module>hapi-fhir-cli</module>
<module>hapi-fhir-dist</module>
<module>examples</module>
<module>hapi-fhir-base-example-embedded-ws</module>
<module>example-projects/hapi-fhir-base-example-embedded-ws</module>
<module>example-projects/hapi-fhir-standalone-overlay-example</module>
<module>hapi-fhir-jacoco</module>
</modules>
</profile>

View File

@ -12,7 +12,7 @@
latest versions (dependent HAPI modules listed in brackets):
<![CDATA[
<ul>
<!--<li>spring (JPA): 4.3.1 -&gt; 4.3.4</li>-->
<li>spring (JPA): 4.3.1 -&gt; 4.3.4</li>
<li>Derby (CLI): 10.12.1.1 -&gt; 10.13.1.1</li>
<li>Jetty (CLI): 9.3.10.v20160621 -&gt; 9.3.14.v20161028</li>
<li>JAnsi (CLI): 1.13 -&gt; 1.14</li>