Add example for terminology uiploading

This commit is contained in:
James Agnew 2016-07-13 09:40:50 -04:00
parent 0b69367b11
commit f6601cc347
3 changed files with 45 additions and 15 deletions

View File

@ -301,7 +301,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
return theServletPath.length() + delta; return theServletPath.length() + delta;
} }
private void findResourceMethods(Object theProvider) throws Exception { private void findResourceMethods(Object theProvider) {
ourLog.info("Scanning type for RESTful methods: {}", theProvider.getClass()); ourLog.info("Scanning type for RESTful methods: {}", theProvider.getClass());
int count = 0; int count = 0;
@ -1017,11 +1017,8 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
/** /**
* Register a single provider. This could be a Resource Provider or a "plain" provider not associated with any * Register a single provider. This could be a Resource Provider or a "plain" provider not associated with any
* resource. * resource.
*
* @param provider
* @throws Exception
*/ */
public void registerProvider(Object provider) throws Exception { public void registerProvider(Object provider) {
if (provider != null) { if (provider != null) {
Collection<Object> providerList = new ArrayList<Object>(1); Collection<Object> providerList = new ArrayList<Object>(1);
providerList.add(provider); providerList.add(provider);
@ -1034,9 +1031,8 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
* *
* @param providers * @param providers
* a {@code Collection} of providers. The parameter could be null or an empty {@code Collection} * a {@code Collection} of providers. The parameter could be null or an empty {@code Collection}
* @throws Exception
*/ */
public void registerProviders(Collection<? extends Object> providers) throws Exception { public void registerProviders(Collection<? extends Object> providers) {
myProviderRegistrationMutex.lock(); myProviderRegistrationMutex.lock();
try { try {
if (!myStarted) { if (!myStarted) {
@ -1059,7 +1055,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
/* /*
* Inner method to actually register providers * Inner method to actually register providers
*/ */
protected void registerProviders(Collection<? extends Object> providers, boolean inInit) throws Exception { protected void registerProviders(Collection<? extends Object> providers, boolean inInit) {
List<IResourceProvider> newResourceProviders = new ArrayList<IResourceProvider>(); List<IResourceProvider> newResourceProviders = new ArrayList<IResourceProvider>();
List<Object> newPlainProviders = new ArrayList<Object>(); List<Object> newPlainProviders = new ArrayList<Object>();
ProvidedResourceScanner providedResourceScanner = new ProvidedResourceScanner(getFhirContext()); ProvidedResourceScanner providedResourceScanner = new ProvidedResourceScanner(getFhirContext());
@ -1074,7 +1070,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
} }
String resourceName = getFhirContext().getResourceDefinition(resourceType).getName(); String resourceName = getFhirContext().getResourceDefinition(resourceType).getName();
if (myTypeToProvider.containsKey(resourceName)) { if (myTypeToProvider.containsKey(resourceName)) {
throw new ServletException("Multiple resource providers return resource type[" + resourceName + "]: First[" + myTypeToProvider.get(resourceName).getClass().getCanonicalName() + "] and Second[" + rsrcProvider.getClass().getCanonicalName() + "]"); throw new ConfigurationException("Multiple resource providers return resource type[" + resourceName + "]: First[" + myTypeToProvider.get(resourceName).getClass().getCanonicalName() + "] and Second[" + rsrcProvider.getClass().getCanonicalName() + "]");
} }
if (!inInit) { if (!inInit) {
myResourceProviders.add(rsrcProvider); myResourceProviders.add(rsrcProvider);

View File

@ -19,6 +19,7 @@ import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1;
import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2; import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3;
import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3;
import ca.uhn.fhir.jpa.provider.dstu3.TerminologyUploaderProviderDstu3;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu2.composite.MetaDt; import ca.uhn.fhir.model.dstu2.composite.MetaDt;
@ -93,8 +94,7 @@ public class JpaServerDemo extends RestfulServer {
* is a nice addition. * is a nice addition.
*/ */
if (fhirVersion == FhirVersionEnum.DSTU1) { if (fhirVersion == FhirVersionEnum.DSTU1) {
IFhirSystemDao<List<IResource>, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu1", IFhirSystemDao<List<IResource>, MetaDt> systemDao = myAppCtx.getBean("mySystemDaoDstu1", IFhirSystemDao.class);
IFhirSystemDao.class);
JpaConformanceProviderDstu1 confProvider = new JpaConformanceProviderDstu1(this, systemDao); JpaConformanceProviderDstu1 confProvider = new JpaConformanceProviderDstu1(this, systemDao);
confProvider.setImplementationDescription("Example Server"); confProvider.setImplementationDescription("Example Server");
setServerConformanceProvider(confProvider); setServerConformanceProvider(confProvider);
@ -105,8 +105,7 @@ public class JpaServerDemo extends RestfulServer {
confProvider.setImplementationDescription("Example Server"); confProvider.setImplementationDescription("Example Server");
setServerConformanceProvider(confProvider); setServerConformanceProvider(confProvider);
} else if (fhirVersion == FhirVersionEnum.DSTU3) { } else if (fhirVersion == FhirVersionEnum.DSTU3) {
IFhirSystemDao<org.hl7.fhir.dstu3.model.Bundle, Meta> systemDao = myAppCtx IFhirSystemDao<org.hl7.fhir.dstu3.model.Bundle, Meta> systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao,
myAppCtx.getBean(DaoConfig.class)); myAppCtx.getBean(DaoConfig.class));
confProvider.setImplementationDescription("Example Server"); confProvider.setImplementationDescription("Example Server");
@ -135,7 +134,9 @@ public class JpaServerDemo extends RestfulServer {
/* /*
* -- New in HAPI FHIR 1.5 -- * -- New in HAPI FHIR 1.5 --
* This configures the server to page search results to and from * This configures the server to page search results to and from
* the database * the database, instead of only paging them to memory. This may mean
* a performance hit when performing searches that return lots of results,
* but makes the server much more scalable.
*/ */
setPagingProvider(myAppCtx.getBean(DatabaseBackedPagingProvider.class)); setPagingProvider(myAppCtx.getBean(DatabaseBackedPagingProvider.class));
@ -155,6 +156,16 @@ public class JpaServerDemo extends RestfulServer {
*/ */
//setServerAddressStrategy(new HardcodedServerAddressStrategy("http://mydomain.com/fhir/baseDstu2")); //setServerAddressStrategy(new HardcodedServerAddressStrategy("http://mydomain.com/fhir/baseDstu2"));
/*
* If you are using DSTU3+, you may want to add a terminology uploader, which allows
* uploading of external terminologies such as Snomed CT. Note that this uploader
* does not have any security attached (any anonymous user may use it by default)
* so it is a potential security vulnerability. Consider using an AuthorizationInterceptor
* with this feature.
*/
if (fhirVersion == FhirVersionEnum.DSTU3) {
registerProvider(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class));
}
} }
} }

View File

@ -7,6 +7,29 @@
</properties> </properties>
<body> <body>
<release version="2.0" date="TBD"> <release version="2.0" date="TBD">
<action type="fix">
JSON parsing in HAPI FHIR has been switched from using JSR353 (javax.json) to
using Google Gson. For this reason we are bumping the major release number to
2.0. Theoretically this should not affect projects in any major way, but Gson
does have subtle differences. Two differences which popped up a fair bit in
our own testing:
<![CDATA[
<ul>
<ul>
A space is placed after the : in keys, e.g. what was previously
encoded as <code>"resourceType":"Patient"</code> is now encoded
as <code>"resourceType": "Patient"</code> (this broke a number of
our unit tests with hardcoded resource definitions)
</ul>
<ul>
Trailing content after a valid json resource is rejected by
Gson (it was ignored by the Glassfish parser we were previously
using even though it was invalid)
</ul>
</ul>
]]>
</action>
<action type="fix"> <action type="fix">
Fix issue in DSTU1 Bundle parsing where unexpected elements in the bundle resulted in a failure Fix issue in DSTU1 Bundle parsing where unexpected elements in the bundle resulted in a failure
to parse. to parse.