mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-27 16:56:07 +00:00
Merge branch 'master' into 963_jpa_performance
This commit is contained in:
commit
127efd55b0
@ -4,10 +4,11 @@
|
||||
|
||||
# Use VM based build environment
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
- oraclejdk9
|
||||
env:
|
||||
global:
|
||||
- MAVEN_OPTS="-Xmx1024m"
|
||||
@ -25,5 +26,4 @@ before_script:
|
||||
script:
|
||||
# - mvn -e -B clean install && cd hapi-fhir-ra && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report
|
||||
# - mvn -Dci=true -e -B -P ALLMODULES,NOPARALLEL,ERRORPRONE clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
|
||||
- mvn -Dci=true -e -B -P ALLMODULES,REDUCED_JPA_TESTS,ERRORPRONE_JDK8,JACOCO clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
|
||||
|
||||
- mvn -Dci=true -e -B -P ALLMODULES,REDUCED_JPA_TESTS,ERRORPRONE,JACOCO clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
|
||||
|
@ -1,21 +1,19 @@
|
||||
hapi-fhir
|
||||
HAPI FHIR
|
||||
=========
|
||||
|
||||
HAPI FHIR - Java API for HL7 FHIR Clients and Servers
|
||||
|
||||
[](https://coveralls.io/github/jamesagnew/hapi-fhir?branch=master)
|
||||
[](http://search.maven.org/#search|ga|1|ca.uhn.hapi.fhir)
|
||||
[](https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e)
|
||||
[](http://jamesagnew.github.io/hapi-fhir/license.html)
|
||||
|
||||
* Linux Build: [](https://travis-ci.org/jamesagnew/hapi-fhir)
|
||||
* Windows Build: <a href="https://ci.appveyor.com/project/jamesagnew/hapi-fhir"><img src="https://ci.appveyor.com/api/projects/status/github/jamesagnew/hapi-fhir?branch=master&svg=true"></a>
|
||||
|
||||
|
||||
Complete project documentation is available here:
|
||||
http://jamesagnew.github.io/hapi-fhir/
|
||||
|
||||
A demonstration of this project is available here:
|
||||
http://fhirtest.uhn.ca/
|
||||
http://hapi.fhir.org/
|
||||
|
||||
This project is Open Source, licensed under the Apache Software License 2.0.
|
||||
|
@ -4,4 +4,6 @@ cache:
|
||||
- C:\maven\
|
||||
- C:\Users\appveyor\.m2\repository
|
||||
build_script:
|
||||
- cmd: mvn -P MINPARALLEL,ALLMODULES clean install
|
||||
- SET JAVA_HOME=C:\Program Files\Java\jdk10
|
||||
- SET PATH=C:\Program Files\Java\jdk10\bin;%PATH%
|
||||
- cmd: mvn -P MINPARALLEL,ALLMODULES,REDUCED_JPA_TESTS clean install
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -14,6 +14,7 @@ import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
@ -188,7 +189,8 @@ public class CdsExampleTests {
|
||||
Assert.assertTrue(procedureRequest.getDoNotPerform());
|
||||
}
|
||||
|
||||
//@Test
|
||||
@Test
|
||||
@Ignore
|
||||
public void CdsHooksPatientViewTest() throws IOException {
|
||||
putResource("cds-bcs-library.json", "patient-view");
|
||||
putResource("cds-bcs-patient.json", "Patient-6532");
|
||||
|
@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -26,28 +26,28 @@
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- This dependency includes the JPA server itself, which is packaged separately from the rest of HAPI FHIR -->
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-jpaserver-base</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- This dependency is used for the "FHIR Tester" web app overlay -->
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-testpage-overlay</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>${project.version}</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>${project.version}</version>
|
||||
<classifier>classes</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
@ -1,6 +1,8 @@
|
||||
Running hapi-fhir-jpaserver-example in Tomcat from IntelliJ
|
||||
|
||||
Install Tomcat.
|
||||
Install mvn
|
||||
run `mvn clean install`
|
||||
|
||||
Make sure you have Tomcat set up in IntelliJ.
|
||||
File->Settings->Build, Execution, Deployment->Application Servers
|
||||
@ -26,6 +28,6 @@ Select your server, and click the green triangle (or the bug if you want to debu
|
||||
Wait for the console output to stop
|
||||
|
||||
Point your browser (or fiddler, or what have you) to
|
||||
http://localhost:8080/hapi/base/Patient
|
||||
http://localhost:8080/hapi/baseDstu3/Patient
|
||||
|
||||
You should get an empty bundle back.
|
@ -21,6 +21,7 @@ import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu3
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
|
||||
|
||||
/**
|
||||
* This class isn't used by default by the example, but
|
||||
@ -84,7 +85,7 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
||||
extraProperties.put("hibernate.cache.use_second_level_cache", "false");
|
||||
extraProperties.put("hibernate.cache.use_structured_entries", "false");
|
||||
extraProperties.put("hibernate.cache.use_minimal_puts", "false");
|
||||
extraProperties.put("hibernate.search.model_mapping", SearchMappingFactory.class.getName());
|
||||
extraProperties.put("hibernate.search.model_mapping", LuceneSearchMappingFactory.class.getName());
|
||||
extraProperties.put("hibernate.search.default.directory_provider", "filesystem");
|
||||
extraProperties.put("hibernate.search.default.indexBase", "target/lucenefiles");
|
||||
extraProperties.put("hibernate.search.lucene_version", "LUCENE_CURRENT");
|
@ -18,7 +18,7 @@ import ca.uhn.fhir.jpa.provider.dstu3.TerminologyUploaderProviderDstu3;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||
import ca.uhn.fhir.rest.server.ETagSupportEnum;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>hapi-fhir-standalone-overlay-example</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -96,6 +96,7 @@
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j_version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -72,6 +72,7 @@ public class BuiltJarDstu2IT {
|
||||
* android uses) and see if this passes
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testClient() {
|
||||
FhirContext ctx = FhirContext.forDstu2();
|
||||
try {
|
||||
|
@ -190,7 +190,7 @@ public class GenericClientDstu3IT {
|
||||
@Test
|
||||
public void testClientFailures() throws Exception {
|
||||
ResponseBody body = mock(ResponseBody.class);
|
||||
when(body.source()).thenThrow(IllegalStateException.class, RuntimeException.class, Exception.class);
|
||||
when(body.source()).thenThrow(IllegalStateException.class, RuntimeException.class);
|
||||
|
||||
myHttpResponse = new Response.Builder()
|
||||
.request(myRequest)
|
||||
@ -216,12 +216,6 @@ public class GenericClientDstu3IT {
|
||||
assertEquals("java.lang.RuntimeException", e.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
client.read().resource(Patient.class).withId("1").execute();
|
||||
fail();
|
||||
} catch (FhirClientConnectionException e) {
|
||||
assertEquals("java.lang.Exception", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -185,14 +185,29 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
||||
});
|
||||
mySearchParams = Collections.unmodifiableList(searchParams);
|
||||
|
||||
Map<String, List<RuntimeSearchParam>> compartmentNameToSearchParams = new HashMap<String, List<RuntimeSearchParam>>();
|
||||
Map<String, List<RuntimeSearchParam>> compartmentNameToSearchParams = new HashMap<>();
|
||||
for (RuntimeSearchParam next : searchParams) {
|
||||
if (next.getProvidesMembershipInCompartments() != null) {
|
||||
for (String nextCompartment : next.getProvidesMembershipInCompartments()) {
|
||||
if (!compartmentNameToSearchParams.containsKey(nextCompartment)) {
|
||||
compartmentNameToSearchParams.put(nextCompartment, new ArrayList<RuntimeSearchParam>());
|
||||
compartmentNameToSearchParams.put(nextCompartment, new ArrayList<>());
|
||||
}
|
||||
List<RuntimeSearchParam> searchParamsForCompartment = compartmentNameToSearchParams.get(nextCompartment);
|
||||
searchParamsForCompartment.add(next);
|
||||
|
||||
/*
|
||||
* If one search parameter marks an SP as making a resource
|
||||
* a part of a compartment, let's also denote all other
|
||||
* SPs with the same path the same way. This behaviour is
|
||||
* used by AuthorizationInterceptor
|
||||
*/
|
||||
for (RuntimeSearchParam nextAlternate : searchParams) {
|
||||
if (nextAlternate.getPath().equals(next.getPath())) {
|
||||
if (!nextAlternate.getName().equals(next.getName())) {
|
||||
searchParamsForCompartment.add(nextAlternate);
|
||||
}
|
||||
}
|
||||
}
|
||||
compartmentNameToSearchParams.get(nextCompartment).add(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,10 @@ import static org.apache.commons.lang3.StringUtils.trim;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
@ -38,6 +42,18 @@ public class RuntimeSearchParam {
|
||||
private final RestSearchParameterTypeEnum myParamType;
|
||||
private final String myPath;
|
||||
private final Set<String> myTargets;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||
.append("base", myBase)
|
||||
.append("name", myName)
|
||||
.append("path", myPath)
|
||||
.append("id", myId)
|
||||
.append("uri", myUri)
|
||||
.toString();
|
||||
}
|
||||
|
||||
private final Set<String> myProvidesMembershipInCompartments;
|
||||
private final RuntimeSearchParamStatusEnum myStatus;
|
||||
private final String myUri;
|
||||
@ -55,9 +71,36 @@ public class RuntimeSearchParam {
|
||||
this(theId, theUri, theName, theDescription, thePath, theParamType, theCompositeOf, theProvidesMembershipInCompartments, theTargets, theStatus, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object theO) {
|
||||
if (this == theO) return true;
|
||||
|
||||
if (theO == null || getClass() != theO.getClass()) return false;
|
||||
|
||||
RuntimeSearchParam that = (RuntimeSearchParam) theO;
|
||||
|
||||
return new EqualsBuilder()
|
||||
.append(getId(), that.getId())
|
||||
.append(getName(), that.getName())
|
||||
.append(getPath(), that.getPath())
|
||||
.append(getUri(), that.getUri())
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(getId())
|
||||
.append(getName())
|
||||
.append(getPath())
|
||||
.append(getUri())
|
||||
.toHashCode();
|
||||
}
|
||||
|
||||
public RuntimeSearchParam(IIdType theId, String theUri, String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, List<RuntimeSearchParam> theCompositeOf,
|
||||
Set<String> theProvidesMembershipInCompartments, Set<String> theTargets, RuntimeSearchParamStatusEnum theStatus, Collection<String> theBase) {
|
||||
Set<String> theProvidesMembershipInCompartments, Set<String> theTargets, RuntimeSearchParamStatusEnum theStatus, Collection<String> theBase) {
|
||||
super();
|
||||
|
||||
myId = theId;
|
||||
myUri = theUri;
|
||||
myName = theName;
|
||||
|
@ -274,6 +274,7 @@ public class Constants {
|
||||
corsAllowedHeaders.add("Content-Type");
|
||||
corsAllowedHeaders.add("Origin");
|
||||
corsAllowedHeaders.add("Prefer");
|
||||
corsAllowedHeaders.add("X-FHIR-Starter");
|
||||
corsAllowedHeaders.add("X-Requested-With");
|
||||
CORS_ALLOWED_HEADERS = Collections.unmodifiableSet(corsAllowedHeaders);
|
||||
|
||||
|
@ -1757,8 +1757,8 @@ public class XmlUtil {
|
||||
|
||||
private static void throwUnitTestExceptionIfConfiguredToDoSo() throws FactoryConfigurationError, XMLStreamException {
|
||||
if (ourNextException != null) {
|
||||
if (ourNextException instanceof FactoryConfigurationError) {
|
||||
throw ((FactoryConfigurationError)ourNextException);
|
||||
if (ourNextException instanceof javax.xml.stream.FactoryConfigurationError) {
|
||||
throw ((javax.xml.stream.FactoryConfigurationError)ourNextException);
|
||||
}
|
||||
throw (XMLStreamException)ourNextException;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -166,13 +166,22 @@
|
||||
<artifactId>thymeleaf-spring4</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Dependencies for Schematron -->
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-schematron</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>Saxon-HE</artifactId>
|
||||
<groupId>net.sf.saxon</groupId>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.istack</groupId>
|
||||
<artifactId>istack-commons-runtime</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
@ -180,18 +189,17 @@
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-commons</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
These have been added as explicit dependencies
|
||||
as JDK9 no longer includes them by default
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
@ -23,23 +23,23 @@ package ca.uhn.fhir.cli;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVPrinter;
|
||||
import org.apache.commons.csv.QuoteMode;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.convertors.VersionConvertor_30_40;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
||||
@ -72,11 +72,11 @@ public class ExportConceptMapToCsvCommand extends AbstractImportExportCsvConcept
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process() throws ParseException {
|
||||
protected void process() throws ExecutionException {
|
||||
searchForConceptMapByUrl();
|
||||
}
|
||||
|
||||
private void searchForConceptMapByUrl() {
|
||||
private void searchForConceptMapByUrl() throws ExecutionException {
|
||||
ourLog.info("Searching for ConceptMap with specified URL (i.e. ConceptMap.url): {}", conceptMapUrl);
|
||||
if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
org.hl7.fhir.dstu3.model.Bundle response = client
|
||||
@ -111,61 +111,26 @@ public class ExportConceptMapToCsvCommand extends AbstractImportExportCsvConcept
|
||||
}
|
||||
}
|
||||
|
||||
private void convertConceptMapToCsv(org.hl7.fhir.dstu3.model.ConceptMap theConceptMap) {
|
||||
ourLog.info("Exporting ConceptMap to CSV...");
|
||||
BufferedWriter bufferedWriter = null;
|
||||
CSVPrinter csvPrinter = null;
|
||||
private void convertConceptMapToCsv(org.hl7.fhir.dstu3.model.ConceptMap theConceptMap) throws ExecutionException {
|
||||
try {
|
||||
bufferedWriter = Files.newBufferedWriter(Paths.get(file));
|
||||
csvPrinter = new CSVPrinter(
|
||||
bufferedWriter,
|
||||
CSVFormat
|
||||
.DEFAULT
|
||||
.withRecordSeparator("\n")
|
||||
.withHeader(Header.class));
|
||||
|
||||
for (org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent group : theConceptMap.getGroup()) {
|
||||
for (org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent element : group.getElement()) {
|
||||
for (org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent target : element.getTarget()) {
|
||||
|
||||
List<String> columns = new ArrayList<>();
|
||||
columns.add(defaultString(group.getSource()));
|
||||
columns.add(defaultString(group.getSourceVersion()));
|
||||
columns.add(defaultString(group.getTarget()));
|
||||
columns.add(defaultString(group.getTargetVersion()));
|
||||
columns.add(defaultString(element.getCode()));
|
||||
columns.add(defaultString(element.getDisplay()));
|
||||
columns.add(defaultString(target.getCode()));
|
||||
columns.add(defaultString(target.getDisplay()));
|
||||
columns.add(defaultString(target.getEquivalence().toCode()));
|
||||
columns.add(defaultString(target.getComment()));
|
||||
|
||||
csvPrinter.print(columns);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
throw new InternalErrorException(ioe);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(csvPrinter);
|
||||
IOUtils.closeQuietly(bufferedWriter);
|
||||
convertConceptMapToCsv(VersionConvertor_30_40.convertConceptMap(theConceptMap));
|
||||
} catch (FHIRException fe) {
|
||||
throw new ExecutionException(fe);
|
||||
}
|
||||
ourLog.info("Finished exporting to {}", file);
|
||||
}
|
||||
|
||||
private void convertConceptMapToCsv(ConceptMap theConceptMap) {
|
||||
ourLog.info("Exporting ConceptMap to CSV...");
|
||||
Writer writer = null;
|
||||
CSVPrinter csvPrinter = null;
|
||||
try {
|
||||
writer = Files.newBufferedWriter(Paths.get(file));
|
||||
csvPrinter = new CSVPrinter(
|
||||
try (
|
||||
Writer writer = Files.newBufferedWriter(Paths.get(file));
|
||||
CSVPrinter csvPrinter = new CSVPrinter(
|
||||
writer,
|
||||
CSVFormat
|
||||
.DEFAULT
|
||||
.withRecordSeparator("\n")
|
||||
.withHeader(Header.class).withQuoteMode(QuoteMode.ALL));
|
||||
|
||||
.withHeader(Header.class)
|
||||
.withQuoteMode(QuoteMode.ALL));
|
||||
) {
|
||||
for (ConceptMapGroupComponent group : theConceptMap.getGroup()) {
|
||||
for (SourceElementComponent element : group.getElement()) {
|
||||
for (ConceptMap.TargetElementComponent target : element.getTarget()) {
|
||||
@ -188,10 +153,8 @@ public class ExportConceptMapToCsvCommand extends AbstractImportExportCsvConcept
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
throw new InternalErrorException(ioe);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(csvPrinter);
|
||||
IOUtils.closeQuietly(writer);
|
||||
}
|
||||
|
||||
ourLog.info("Finished exporting to {}", file);
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,9 @@ import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVParser;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.convertors.VersionConvertor_30_40;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
@ -43,7 +41,10 @@ import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
@ -96,7 +97,7 @@ public class ImportCsvToConceptMapCommand extends AbstractImportExportCsvConcept
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseAdditionalParameters(CommandLine theCommandLine) throws ParseException {
|
||||
protected void parseAdditionalParameters(CommandLine theCommandLine) {
|
||||
sourceValueSet = theCommandLine.getOptionValue(SOURCE_VALUE_SET_PARAM);
|
||||
if (isBlank(sourceValueSet)) {
|
||||
ourLog.info("Source value set is not specified (i.e. ConceptMap.sourceUri).");
|
||||
@ -113,11 +114,11 @@ public class ImportCsvToConceptMapCommand extends AbstractImportExportCsvConcept
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process() throws ParseException, ExecutionException {
|
||||
protected void process() throws ExecutionException {
|
||||
searchForConceptMapByUrl();
|
||||
}
|
||||
|
||||
private void searchForConceptMapByUrl() throws ParseException, ExecutionException {
|
||||
private void searchForConceptMapByUrl() throws ExecutionException {
|
||||
if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
org.hl7.fhir.dstu3.model.ConceptMap conceptMap = convertCsvToConceptMapDstu3();
|
||||
|
||||
@ -153,7 +154,7 @@ public class ImportCsvToConceptMapCommand extends AbstractImportExportCsvConcept
|
||||
}
|
||||
}
|
||||
|
||||
private org.hl7.fhir.dstu3.model.ConceptMap convertCsvToConceptMapDstu3() throws ParseException, ExecutionException {
|
||||
private org.hl7.fhir.dstu3.model.ConceptMap convertCsvToConceptMapDstu3() throws ExecutionException {
|
||||
try {
|
||||
return VersionConvertor_30_40.convertConceptMap(convertCsvToConceptMapR4());
|
||||
} catch (FHIRException fe) {
|
||||
@ -161,14 +162,12 @@ public class ImportCsvToConceptMapCommand extends AbstractImportExportCsvConcept
|
||||
}
|
||||
}
|
||||
|
||||
private ConceptMap convertCsvToConceptMapR4() throws ParseException, ExecutionException {
|
||||
private ConceptMap convertCsvToConceptMapR4() throws ExecutionException {
|
||||
ourLog.info("Converting CSV to ConceptMap...");
|
||||
ConceptMap retVal = new ConceptMap();
|
||||
Reader reader = null;
|
||||
CSVParser csvParser = null;
|
||||
try {
|
||||
reader = Files.newBufferedReader(Paths.get(file));
|
||||
csvParser = new CSVParser(
|
||||
try (
|
||||
Reader reader = Files.newBufferedReader(Paths.get(file));
|
||||
CSVParser csvParser = new CSVParser(
|
||||
reader,
|
||||
CSVFormat
|
||||
.DEFAULT
|
||||
@ -178,7 +177,7 @@ public class ImportCsvToConceptMapCommand extends AbstractImportExportCsvConcept
|
||||
.withIgnoreHeaderCase()
|
||||
.withIgnoreEmptyLines()
|
||||
.withTrim());
|
||||
|
||||
) {
|
||||
retVal.setUrl(conceptMapUrl);
|
||||
|
||||
if (isNotBlank(sourceValueSet)) {
|
||||
@ -278,9 +277,6 @@ public class ImportCsvToConceptMapCommand extends AbstractImportExportCsvConcept
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new InternalErrorException(e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(csvParser);
|
||||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
|
||||
ourLog.info("Finished converting CSV to ConceptMap.");
|
||||
|
@ -0,0 +1,283 @@
|
||||
package ca.uhn.fhir.cli;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.interceptor.VerboseLoggingInterceptor;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
||||
import org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence;
|
||||
import org.hl7.fhir.dstu3.model.UriType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ExportConceptMapToCsvCommandDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExportConceptMapToCsvCommandDstu3Test.class);
|
||||
private static final String CM_URL = "http://example.com/conceptmap";
|
||||
private static final String VS_URL_1 = "http://example.com/valueset/1";
|
||||
private static final String VS_URL_2 = "http://example.com/valueset/2";
|
||||
private static final String CS_URL_1 = "http://example.com/codesystem/1";
|
||||
private static final String CS_URL_2 = "http://example.com/codesystem/2";
|
||||
private static final String CS_URL_3 = "http://example.com/codesystem/3";
|
||||
private static final String FILE = "./target/output.csv";
|
||||
|
||||
private static String ourBase;
|
||||
private static IGenericClient ourClient;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu3();
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static String ourVersion = "dstu3";
|
||||
|
||||
static {
|
||||
System.setProperty("test", "true");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
ourPort = PortUtil.findFreePort();
|
||||
ourServer = new Server(ourPort);
|
||||
|
||||
ServletHandler servletHandler = new ServletHandler();
|
||||
|
||||
RestfulServer restfulServer = new RestfulServer(ourCtx);
|
||||
restfulServer.registerInterceptor(new VerboseLoggingInterceptor());
|
||||
restfulServer.setResourceProviders(new HashMapResourceProviderConceptMapDstu3(ourCtx));
|
||||
|
||||
ServletHolder servletHolder = new ServletHolder(restfulServer);
|
||||
servletHandler.addServletWithMapping(servletHolder, "/*");
|
||||
ourServer.setHandler(servletHandler);
|
||||
|
||||
ourServer.start();
|
||||
|
||||
ourBase = "http://localhost:" + ourPort;
|
||||
|
||||
ourClient = ourCtx.newRestfulGenericClient(ourBase);
|
||||
|
||||
ourClient.create().resource(createConceptMap()).execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExportConceptMapToCsvCommand() throws IOException {
|
||||
ourLog.info("ConceptMap:\n" + ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createConceptMap()));
|
||||
|
||||
App.main(new String[] {"export-conceptmap-to-csv",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
"-f", FILE,
|
||||
"-l"});
|
||||
|
||||
String expected = "\"SOURCE_CODE_SYSTEM\",\"SOURCE_CODE_SYSTEM_VERSION\",\"TARGET_CODE_SYSTEM\",\"TARGET_CODE_SYSTEM_VERSION\",\"SOURCE_CODE\",\"SOURCE_DISPLAY\",\"TARGET_CODE\",\"TARGET_DISPLAY\",\"EQUIVALENCE\",\"COMMENT\"\n" +
|
||||
"\"http://example.com/codesystem/1\",\"Version 1s\",\"http://example.com/codesystem/2\",\"Version 2t\",\"Code 1a\",\"Display 1a\",\"Code 2a\",\"Display 2a\",\"equal\",\"2a This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/1\",\"Version 1s\",\"http://example.com/codesystem/2\",\"Version 2t\",\"Code 1b\",\"Display 1b\",\"Code 2b\",\"Display 2b\",\"equal\",\"2b This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/1\",\"Version 1s\",\"http://example.com/codesystem/2\",\"Version 2t\",\"Code 1c\",\"Display 1c\",\"Code 2c\",\"Display 2c\",\"equal\",\"2c This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/1\",\"Version 1s\",\"http://example.com/codesystem/2\",\"Version 2t\",\"Code 1d\",\"Display 1d\",\"Code 2d\",\"Display 2d\",\"equal\",\"2d This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/1\",\"Version 1s\",\"http://example.com/codesystem/3\",\"Version 3t\",\"Code 1a\",\"Display 1a\",\"Code 3a\",\"Display 3a\",\"equal\",\"3a This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/1\",\"Version 1s\",\"http://example.com/codesystem/3\",\"Version 3t\",\"Code 1b\",\"Display 1b\",\"Code 3b\",\"Display 3b\",\"equal\",\"3b This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/1\",\"Version 1s\",\"http://example.com/codesystem/3\",\"Version 3t\",\"Code 1c\",\"Display 1c\",\"Code 3c\",\"Display 3c\",\"equal\",\"3c This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/1\",\"Version 1s\",\"http://example.com/codesystem/3\",\"Version 3t\",\"Code 1d\",\"Display 1d\",\"Code 3d\",\"Display 3d\",\"equal\",\"3d This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/2\",\"Version 2s\",\"http://example.com/codesystem/3\",\"Version 3t\",\"Code 2a\",\"Display 2a\",\"Code 3a\",\"Display 3a\",\"equal\",\"3a This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/2\",\"Version 2s\",\"http://example.com/codesystem/3\",\"Version 3t\",\"Code 2b\",\"Display 2b\",\"Code 3b\",\"Display 3b\",\"equal\",\"3b This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/2\",\"Version 2s\",\"http://example.com/codesystem/3\",\"Version 3t\",\"Code 2c\",\"Display 2c\",\"Code 3c\",\"Display 3c\",\"equal\",\"3c This is a comment.\"\n" +
|
||||
"\"http://example.com/codesystem/2\",\"Version 2s\",\"http://example.com/codesystem/3\",\"Version 3t\",\"Code 2d\",\"Display 2d\",\"Code 3d\",\"Display 3d\",\"equal\",\"3d This is a comment.\"\n";
|
||||
String result = IOUtils.toString(new FileInputStream(FILE), Charsets.UTF_8);
|
||||
assertEquals(expected, result);
|
||||
|
||||
FileUtils.deleteQuietly(new File(FILE));
|
||||
}
|
||||
|
||||
static ConceptMap createConceptMap() {
|
||||
ConceptMap conceptMap = new ConceptMap();
|
||||
conceptMap
|
||||
.setUrl(CM_URL)
|
||||
.setSource(new UriType(VS_URL_1))
|
||||
.setTarget(new UriType(VS_URL_2));
|
||||
|
||||
ConceptMap.ConceptMapGroupComponent group = conceptMap.addGroup();
|
||||
group
|
||||
.setSource(CS_URL_1)
|
||||
.setSourceVersion("Version 1s")
|
||||
.setTarget(CS_URL_2)
|
||||
.setTargetVersion("Version 2t");
|
||||
|
||||
ConceptMap.SourceElementComponent element = group.addElement();
|
||||
element
|
||||
.setCode("Code 1a")
|
||||
.setDisplay("Display 1a");
|
||||
|
||||
ConceptMap.TargetElementComponent target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 2a")
|
||||
.setDisplay("Display 2a")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("2a This is a comment.");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 1b")
|
||||
.setDisplay("Display 1b");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 2b")
|
||||
.setDisplay("Display 2b")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("2b This is a comment.");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 1c")
|
||||
.setDisplay("Display 1c");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 2c")
|
||||
.setDisplay("Display 2c")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("2c This is a comment.");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 1d")
|
||||
.setDisplay("Display 1d");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 2d")
|
||||
.setDisplay("Display 2d")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("2d This is a comment.");
|
||||
|
||||
group = conceptMap.addGroup();
|
||||
group
|
||||
.setSource(CS_URL_1)
|
||||
.setSourceVersion("Version 1s")
|
||||
.setTarget(CS_URL_3)
|
||||
.setTargetVersion("Version 3t");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 1a")
|
||||
.setDisplay("Display 1a");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 3a")
|
||||
.setDisplay("Display 3a")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("3a This is a comment.");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 1b")
|
||||
.setDisplay("Display 1b");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 3b")
|
||||
.setDisplay("Display 3b")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("3b This is a comment.");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 1c")
|
||||
.setDisplay("Display 1c");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 3c")
|
||||
.setDisplay("Display 3c")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("3c This is a comment.");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 1d")
|
||||
.setDisplay("Display 1d");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 3d")
|
||||
.setDisplay("Display 3d")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("3d This is a comment.");
|
||||
|
||||
group = conceptMap.addGroup();
|
||||
group
|
||||
.setSource(CS_URL_2)
|
||||
.setSourceVersion("Version 2s")
|
||||
.setTarget(CS_URL_3)
|
||||
.setTargetVersion("Version 3t");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 2a")
|
||||
.setDisplay("Display 2a");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 3a")
|
||||
.setDisplay("Display 3a")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("3a This is a comment.");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 2b")
|
||||
.setDisplay("Display 2b");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 3b")
|
||||
.setDisplay("Display 3b")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("3b This is a comment.");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 2c")
|
||||
.setDisplay("Display 2c");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 3c")
|
||||
.setDisplay("Display 3c")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("3c This is a comment.");
|
||||
|
||||
element = group.addElement();
|
||||
element
|
||||
.setCode("Code 2d")
|
||||
.setDisplay("Display 2d");
|
||||
|
||||
target = element.addTarget();
|
||||
target
|
||||
.setCode("Code 3d")
|
||||
.setDisplay("Display 3d")
|
||||
.setEquivalence(ConceptMapEquivalence.EQUAL)
|
||||
.setComment("3d This is a comment.");
|
||||
|
||||
return conceptMap;
|
||||
}
|
||||
}
|
@ -25,8 +25,8 @@ import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ExportConceptMapToCsvCommandTest {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExportConceptMapToCsvCommandTest.class);
|
||||
public class ExportConceptMapToCsvCommandR4Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExportConceptMapToCsvCommandR4Test.class);
|
||||
private static final String CM_URL = "http://example.com/conceptmap";
|
||||
private static final String VS_URL_1 = "http://example.com/valueset/1";
|
||||
private static final String VS_URL_2 = "http://example.com/valueset/2";
|
||||
@ -40,6 +40,7 @@ public class ExportConceptMapToCsvCommandTest {
|
||||
private static FhirContext ourCtx = FhirContext.forR4();
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static String ourVersion = "r4";
|
||||
|
||||
static {
|
||||
System.setProperty("test", "true");
|
||||
@ -80,7 +81,7 @@ public class ExportConceptMapToCsvCommandTest {
|
||||
ourLog.info("ConceptMap:\n" + ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createConceptMap()));
|
||||
|
||||
App.main(new String[] {"export-conceptmap-to-csv",
|
||||
"-v", "r4",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
"-f", FILE,
|
@ -0,0 +1,127 @@
|
||||
package ca.uhn.fhir.cli;
|
||||
|
||||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR - Server Framework
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2018 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.provider.AbstractHashMapResourceProvider;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
||||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
/**
|
||||
* This is a subclass to implement FHIR operations specific to DSTU3 ConceptMap
|
||||
* resources. Its superclass, {@link AbstractHashMapResourceProvider}, is a simple
|
||||
* implementation of the resource provider interface that uses a HashMap to
|
||||
* store all resources in memory.
|
||||
* <p>
|
||||
* This subclass currently supports the following FHIR operations:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Search for DSTU3 ConceptMap resources by ConceptMap.url</li>
|
||||
* <li>Conditional update for DSTU3 ConceptMap resources by ConceptMap.url</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class HashMapResourceProviderConceptMapDstu3 extends AbstractHashMapResourceProvider<ConceptMap> {
|
||||
@SuppressWarnings("unchecked")
|
||||
public HashMapResourceProviderConceptMapDstu3(FhirContext theFhirContext) {
|
||||
super(theFhirContext, ConceptMap.class);
|
||||
|
||||
FhirVersionEnum fhirVersion = theFhirContext.getVersion().getVersion();
|
||||
if (fhirVersion != FhirVersionEnum.DSTU3) {
|
||||
throw new IllegalStateException("Requires FHIR version DSTU3. Unsupported FHIR version provided: " + fhirVersion);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Search
|
||||
public List<ConceptMap> searchByUrl(
|
||||
@RequiredParam(name=ConceptMap.SP_URL) String theConceptMapUrl) {
|
||||
|
||||
List<ConceptMap> retVal = new ArrayList<>();
|
||||
|
||||
for (TreeMap<Long, ConceptMap> next : myIdToVersionToResourceMap.values()) {
|
||||
if (!next.isEmpty()) {
|
||||
ConceptMap conceptMap = next.lastEntry().getValue();
|
||||
if (theConceptMapUrl.equals(conceptMap.getUrl()))
|
||||
retVal.add(conceptMap);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Update
|
||||
public MethodOutcome updateConceptMapConditional(
|
||||
@ResourceParam ConceptMap theConceptMap,
|
||||
@IdParam IdType theId,
|
||||
@ConditionalUrlParam String theConditional) {
|
||||
|
||||
MethodOutcome methodOutcome = new MethodOutcome();
|
||||
|
||||
if (theConditional != null) {
|
||||
|
||||
String url = null;
|
||||
|
||||
try {
|
||||
List<NameValuePair> params = URLEncodedUtils.parse(new URI(theConditional), Charsets.UTF_8);
|
||||
for (NameValuePair param : params) {
|
||||
if (param.getName().equalsIgnoreCase("url")) {
|
||||
url = param.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (URISyntaxException urise) {
|
||||
throw new InvalidRequestException(urise);
|
||||
}
|
||||
|
||||
if (isNotBlank(url)) {
|
||||
List<ConceptMap> conceptMaps = searchByUrl(url);
|
||||
|
||||
if (!conceptMaps.isEmpty()) {
|
||||
methodOutcome = update(conceptMaps.get(0));
|
||||
} else {
|
||||
methodOutcome = create(theConceptMap);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
methodOutcome = update(theConceptMap);
|
||||
}
|
||||
|
||||
return methodOutcome;
|
||||
}
|
||||
}
|
@ -0,0 +1,367 @@
|
||||
package ca.uhn.fhir.cli;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.interceptor.VerboseLoggingInterceptor;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent;
|
||||
import org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ImportCsvToConceptMapCommandDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ImportCsvToConceptMapCommandDstu3Test.class);
|
||||
private static final String CM_URL = "http://example.com/conceptmap";
|
||||
private static final String VS_URL_1 = "http://example.com/valueset/1";
|
||||
private static final String VS_URL_2 = "http://example.com/valueset/2";
|
||||
private static final String CS_URL_1 = "http://example.com/codesystem/1";
|
||||
private static final String CS_URL_2 = "http://example.com/codesystem/2";
|
||||
private static final String CS_URL_3 = "http://example.com/codesystem/3";
|
||||
private static final String FILENAME = "import-csv-to-conceptmap-command-test-input.csv";
|
||||
|
||||
private static String file;
|
||||
private static String ourBase;
|
||||
private static IGenericClient ourClient;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu3();
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static String ourVersion = "dstu3";
|
||||
|
||||
private static RestfulServer restfulServer;
|
||||
|
||||
private static HashMapResourceProviderConceptMapDstu3 hashMapResourceProviderConceptMapDstu3;
|
||||
|
||||
static {
|
||||
System.setProperty("test", "true");
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterClearResourceProvider() {
|
||||
HashMapResourceProviderConceptMapDstu3 resourceProvider = (HashMapResourceProviderConceptMapDstu3) restfulServer.getResourceProviders().iterator().next();
|
||||
resourceProvider.clear();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
ourPort = PortUtil.findFreePort();
|
||||
ourServer = new Server(ourPort);
|
||||
|
||||
ServletHandler servletHandler = new ServletHandler();
|
||||
|
||||
restfulServer = new RestfulServer(ourCtx);
|
||||
restfulServer.registerInterceptor(new VerboseLoggingInterceptor());
|
||||
restfulServer.setResourceProviders(new HashMapResourceProviderConceptMapDstu3(ourCtx));
|
||||
|
||||
ServletHolder servletHolder = new ServletHolder(restfulServer);
|
||||
servletHandler.addServletWithMapping(servletHolder, "/*");
|
||||
ourServer.setHandler(servletHandler);
|
||||
|
||||
ourServer.start();
|
||||
|
||||
ourBase = "http://localhost:" + ourPort;
|
||||
|
||||
ourClient = ourCtx.newRestfulGenericClient(ourBase);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalUpdateResultsInCreate() {
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandDstu3Test.createConceptMap();
|
||||
String conceptMapUrl = conceptMap.getUrl();
|
||||
|
||||
ourLog.info("Searching for existing ConceptMap with specified URL (i.e. ConceptMap.url): {}", conceptMapUrl);
|
||||
MethodOutcome methodOutcome = ourClient
|
||||
.update()
|
||||
.resource(conceptMap)
|
||||
.conditional()
|
||||
.where(ConceptMap.URL.matches().value(conceptMapUrl))
|
||||
.execute();
|
||||
|
||||
assertEquals(Boolean.TRUE, methodOutcome.getCreated());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalUpdateResultsInUpdate() {
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandDstu3Test.createConceptMap();
|
||||
ourClient.create().resource(conceptMap).execute();
|
||||
String conceptMapUrl = conceptMap.getUrl();
|
||||
|
||||
ourLog.info("Searching for existing ConceptMap with specified URL (i.e. ConceptMap.url): {}", conceptMapUrl);
|
||||
MethodOutcome methodOutcome = ourClient
|
||||
.update()
|
||||
.resource(conceptMap)
|
||||
.conditional()
|
||||
.where(ConceptMap.URL.matches().value(conceptMapUrl))
|
||||
.execute();
|
||||
|
||||
assertNull(methodOutcome.getCreated());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonConditionalUpdate() {
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandDstu3Test.createConceptMap();
|
||||
ourClient.create().resource(conceptMap).execute();
|
||||
|
||||
Bundle response = ourClient
|
||||
.search()
|
||||
.forResource(ConceptMap.class)
|
||||
.where(ConceptMap.URL.matches().value(CM_URL))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
ConceptMap resultConceptMap = (ConceptMap) response.getEntryFirstRep().getResource();
|
||||
|
||||
MethodOutcome methodOutcome = ourClient
|
||||
.update()
|
||||
.resource(resultConceptMap)
|
||||
.withId(resultConceptMap.getIdElement())
|
||||
.execute();
|
||||
|
||||
assertNull(methodOutcome.getCreated());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportCsvToConceptMapCommand() throws FHIRException {
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
File fileToImport = new File(classLoader.getResource(FILENAME).getFile());
|
||||
ImportCsvToConceptMapCommandDstu3Test.file = fileToImport.getAbsolutePath();
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
"-i", VS_URL_1,
|
||||
"-o", VS_URL_2,
|
||||
"-f", file,
|
||||
"-l"});
|
||||
|
||||
Bundle response = ourClient
|
||||
.search()
|
||||
.forResource(ConceptMap.class)
|
||||
.where(ConceptMap.URL.matches().value(CM_URL))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
ConceptMap conceptMap = (ConceptMap) response.getEntryFirstRep().getResource();
|
||||
|
||||
ourLog.info(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/ConceptMap/1/_history/1", conceptMap.getId());
|
||||
|
||||
assertEquals(CM_URL, conceptMap.getUrl());
|
||||
assertEquals(VS_URL_1, conceptMap.getSourceUriType().getValueAsString());
|
||||
assertEquals(VS_URL_2, conceptMap.getTargetUriType().getValueAsString());
|
||||
|
||||
assertEquals(3, conceptMap.getGroup().size());
|
||||
|
||||
ConceptMapGroupComponent group = conceptMap.getGroup().get(0);
|
||||
assertEquals(CS_URL_1, group.getSource());
|
||||
assertEquals("Version 1s", group.getSourceVersion());
|
||||
assertEquals(CS_URL_2, group.getTarget());
|
||||
assertEquals("Version 2t", group.getTargetVersion());
|
||||
|
||||
assertEquals(4, group.getElement().size());
|
||||
|
||||
SourceElementComponent source = group.getElement().get(0);
|
||||
assertEquals("Code 1a", source.getCode());
|
||||
assertEquals("Display 1a", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
TargetElementComponent target = source.getTarget().get(0);
|
||||
assertEquals("Code 2a", target.getCode());
|
||||
assertEquals("Display 2a", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("2a This is a comment.", target.getComment());
|
||||
|
||||
source = group.getElement().get(1);
|
||||
assertEquals("Code 1b", source.getCode());
|
||||
assertEquals("Display 1b", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 2b", target.getCode());
|
||||
assertEquals("Display 2b", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("2b This is a comment.", target.getComment());
|
||||
|
||||
source = group.getElement().get(2);
|
||||
assertEquals("Code 1c", source.getCode());
|
||||
assertEquals("Display 1c", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 2c", target.getCode());
|
||||
assertEquals("Display 2c", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("2c This is a comment.", target.getComment());
|
||||
|
||||
source = group.getElement().get(3);
|
||||
assertEquals("Code 1d", source.getCode());
|
||||
assertEquals("Display 1d", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 2d", target.getCode());
|
||||
assertEquals("Display 2d", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("2d This is a comment.", target.getComment());
|
||||
|
||||
group = conceptMap.getGroup().get(1);
|
||||
assertEquals(CS_URL_1, group.getSource());
|
||||
assertEquals("Version 1s", group.getSourceVersion());
|
||||
assertEquals(CS_URL_3, group.getTarget());
|
||||
assertEquals("Version 3t", group.getTargetVersion());
|
||||
|
||||
assertEquals(4, group.getElement().size());
|
||||
|
||||
source = group.getElement().get(0);
|
||||
assertEquals("Code 1a", source.getCode());
|
||||
assertEquals("Display 1a", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 3a", target.getCode());
|
||||
assertEquals("Display 3a", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3a This is a comment.", target.getComment());
|
||||
|
||||
source = group.getElement().get(1);
|
||||
assertEquals("Code 1b", source.getCode());
|
||||
assertEquals("Display 1b", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 3b", target.getCode());
|
||||
assertEquals("Display 3b", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3b This is a comment.", target.getComment());
|
||||
|
||||
source = group.getElement().get(2);
|
||||
assertEquals("Code 1c", source.getCode());
|
||||
assertEquals("Display 1c", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 3c", target.getCode());
|
||||
assertEquals("Display 3c", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3c This is a comment.", target.getComment());
|
||||
|
||||
source = group.getElement().get(3);
|
||||
assertEquals("Code 1d", source.getCode());
|
||||
assertEquals("Display 1d", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 3d", target.getCode());
|
||||
assertEquals("Display 3d", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3d This is a comment.", target.getComment());
|
||||
|
||||
group = conceptMap.getGroup().get(2);
|
||||
assertEquals(CS_URL_2, group.getSource());
|
||||
assertEquals("Version 2s", group.getSourceVersion());
|
||||
assertEquals(CS_URL_3, group.getTarget());
|
||||
assertEquals("Version 3t", group.getTargetVersion());
|
||||
|
||||
assertEquals(4, group.getElement().size());
|
||||
|
||||
source = group.getElement().get(0);
|
||||
assertEquals("Code 2a", source.getCode());
|
||||
assertEquals("Display 2a", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 3a", target.getCode());
|
||||
assertEquals("Display 3a", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3a This is a comment.", target.getComment());
|
||||
|
||||
source = group.getElement().get(1);
|
||||
assertEquals("Code 2b", source.getCode());
|
||||
assertEquals("Display 2b", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 3b", target.getCode());
|
||||
assertEquals("Display 3b", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3b This is a comment.", target.getComment());
|
||||
|
||||
source = group.getElement().get(2);
|
||||
assertEquals("Code 2c", source.getCode());
|
||||
assertEquals("Display 2c", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 3c", target.getCode());
|
||||
assertEquals("Display 3c", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3c This is a comment.", target.getComment());
|
||||
|
||||
source = group.getElement().get(3);
|
||||
assertEquals("Code 2d", source.getCode());
|
||||
assertEquals("Display 2d", source.getDisplay());
|
||||
|
||||
assertEquals(1, source.getTarget().size());
|
||||
|
||||
target = source.getTarget().get(0);
|
||||
assertEquals("Code 3d", target.getCode());
|
||||
assertEquals("Display 3d", target.getDisplay());
|
||||
assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
|
||||
assertEquals("3d This is a comment.", target.getComment());
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
"-i", VS_URL_1,
|
||||
"-o", VS_URL_2,
|
||||
"-f", file,
|
||||
"-l"});
|
||||
|
||||
response = ourClient
|
||||
.search()
|
||||
.forResource(ConceptMap.class)
|
||||
.where(ConceptMap.URL.matches().value(CM_URL))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
conceptMap = (ConceptMap) response.getEntryFirstRep().getResource();
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/ConceptMap/1/_history/2", conceptMap.getId());
|
||||
}
|
||||
}
|
@ -10,13 +10,13 @@ import ca.uhn.fhir.util.TestUtil;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent;
|
||||
import org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent;
|
||||
import org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
@ -26,8 +26,8 @@ import java.io.File;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ImportCsvToConceptMapCommandTest {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ImportCsvToConceptMapCommandTest.class);
|
||||
public class ImportCsvToConceptMapCommandR4Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ImportCsvToConceptMapCommandR4Test.class);
|
||||
private static final String CM_URL = "http://example.com/conceptmap";
|
||||
private static final String VS_URL_1 = "http://example.com/valueset/1";
|
||||
private static final String VS_URL_2 = "http://example.com/valueset/2";
|
||||
@ -42,6 +42,7 @@ public class ImportCsvToConceptMapCommandTest {
|
||||
private static FhirContext ourCtx = FhirContext.forR4();
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static String ourVersion = "r4";
|
||||
|
||||
private static RestfulServer restfulServer;
|
||||
|
||||
@ -87,7 +88,7 @@ public class ImportCsvToConceptMapCommandTest {
|
||||
|
||||
@Test
|
||||
public void testConditionalUpdateResultsInCreate() {
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandTest.createConceptMap();
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandR4Test.createConceptMap();
|
||||
String conceptMapUrl = conceptMap.getUrl();
|
||||
|
||||
ourLog.info("Searching for existing ConceptMap with specified URL (i.e. ConceptMap.url): {}", conceptMapUrl);
|
||||
@ -104,7 +105,7 @@ public class ImportCsvToConceptMapCommandTest {
|
||||
|
||||
@Test
|
||||
public void testConditionalUpdateResultsInUpdate() {
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandTest.createConceptMap();
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandR4Test.createConceptMap();
|
||||
ourClient.create().resource(conceptMap).execute();
|
||||
String conceptMapUrl = conceptMap.getUrl();
|
||||
|
||||
@ -122,7 +123,7 @@ public class ImportCsvToConceptMapCommandTest {
|
||||
|
||||
@Test
|
||||
public void testNonConditionalUpdate() {
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandTest.createConceptMap();
|
||||
ConceptMap conceptMap = ExportConceptMapToCsvCommandR4Test.createConceptMap();
|
||||
ourClient.create().resource(conceptMap).execute();
|
||||
|
||||
Bundle response = ourClient
|
||||
@ -150,10 +151,10 @@ public class ImportCsvToConceptMapCommandTest {
|
||||
public void testImportCsvToConceptMapCommand() throws FHIRException {
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
File fileToImport = new File(classLoader.getResource(FILENAME).getFile());
|
||||
ImportCsvToConceptMapCommandTest.file = fileToImport.getAbsolutePath();
|
||||
ImportCsvToConceptMapCommandR4Test.file = fileToImport.getAbsolutePath();
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
"-v", "r4",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
"-i", VS_URL_1,
|
||||
@ -349,7 +350,7 @@ public class ImportCsvToConceptMapCommandTest {
|
||||
assertEquals("3d This is a comment.", target.getComment());
|
||||
|
||||
App.main(new String[] {"import-csv-to-conceptmap",
|
||||
"-v", "r4",
|
||||
"-v", ourVersion,
|
||||
"-t", ourBase,
|
||||
"-u", CM_URL,
|
||||
"-i", VS_URL_1,
|
@ -1,13 +1,13 @@
|
||||
SOURCE_CODE_SYSTEM,SOURCE_CODE_SYSTEM_VERSION,TARGET_CODE_SYSTEM,TARGET_CODE_SYSTEM_VERSION,SOURCE_CODE,SOURCE_DISPLAY,TARGET_CODE,TARGET_DISPLAY,EQUIVALENCE,COMMENT
|
||||
http://example.com/codesystem/1,Version 1s,http://example.com/codesystem/2,Version 2t,Code 1a,Display 1a,Code 2a,Display 2a,equal,2a This is a comment.
|
||||
http://example.com/codesystem/1,Version 1s,http://example.com/codesystem/2,Version 2t,Code 1b,Display 1b,Code 2b,Display 2b,equal,2b This is a comment.
|
||||
http://example.com/codesystem/1,Version 1s,http://example.com/codesystem/2,Version 2t,Code 1c,Display 1c,Code 2c,Display 2c,equal,2c This is a comment.
|
||||
http://example.com/codesystem/1,Version 1s,http://example.com/codesystem/2,Version 2t,Code 1d,Display 1d,Code 2d,Display 2d,equal,2d This is a comment.
|
||||
http://example.com/codesystem/1,Version 1s,http://example.com/codesystem/3,Version 3t,Code 1a,Display 1a,Code 3a,Display 3a,equal,3a This is a comment.
|
||||
http://example.com/codesystem/1,Version 1s,http://example.com/codesystem/3,Version 3t,Code 1b,Display 1b,Code 3b,Display 3b,equal,3b This is a comment.
|
||||
http://example.com/codesystem/1,Version 1s,http://example.com/codesystem/3,Version 3t,Code 1c,Display 1c,Code 3c,Display 3c,equal,3c This is a comment.
|
||||
http://example.com/codesystem/1,Version 1s,http://example.com/codesystem/3,Version 3t,Code 1d,Display 1d,Code 3d,Display 3d,equal,3d This is a comment.
|
||||
http://example.com/codesystem/2,Version 2s,http://example.com/codesystem/3,Version 3t,Code 2a,Display 2a,Code 3a,Display 3a,equal,3a This is a comment.
|
||||
http://example.com/codesystem/2,Version 2s,http://example.com/codesystem/3,Version 3t,Code 2b,Display 2b,Code 3b,Display 3b,equal,3b This is a comment.
|
||||
http://example.com/codesystem/2,Version 2s,http://example.com/codesystem/3,Version 3t,Code 2c,Display 2c,Code 3c,Display 3c,equal,3c This is a comment.
|
||||
http://example.com/codesystem/2,Version 2s,http://example.com/codesystem/3,Version 3t,Code 2d,Display 2d,Code 3d,Display 3d,equal,3d This is a comment.
|
||||
"SOURCE_CODE_SYSTEM","SOURCE_CODE_SYSTEM_VERSION","TARGET_CODE_SYSTEM","TARGET_CODE_SYSTEM_VERSION","SOURCE_CODE","SOURCE_DISPLAY","TARGET_CODE","TARGET_DISPLAY","EQUIVALENCE","COMMENT"
|
||||
"http://example.com/codesystem/1","Version 1s","http://example.com/codesystem/2","Version 2t","Code 1a","Display 1a","Code 2a","Display 2a","equal","2a This is a comment."
|
||||
"http://example.com/codesystem/1","Version 1s","http://example.com/codesystem/2","Version 2t","Code 1b","Display 1b","Code 2b","Display 2b","equal","2b This is a comment."
|
||||
"http://example.com/codesystem/1","Version 1s","http://example.com/codesystem/2","Version 2t","Code 1c","Display 1c","Code 2c","Display 2c","equal","2c This is a comment."
|
||||
"http://example.com/codesystem/1","Version 1s","http://example.com/codesystem/2","Version 2t","Code 1d","Display 1d","Code 2d","Display 2d","equal","2d This is a comment."
|
||||
"http://example.com/codesystem/1","Version 1s","http://example.com/codesystem/3","Version 3t","Code 1a","Display 1a","Code 3a","Display 3a","equal","3a This is a comment."
|
||||
"http://example.com/codesystem/1","Version 1s","http://example.com/codesystem/3","Version 3t","Code 1b","Display 1b","Code 3b","Display 3b","equal","3b This is a comment."
|
||||
"http://example.com/codesystem/1","Version 1s","http://example.com/codesystem/3","Version 3t","Code 1c","Display 1c","Code 3c","Display 3c","equal","3c This is a comment."
|
||||
"http://example.com/codesystem/1","Version 1s","http://example.com/codesystem/3","Version 3t","Code 1d","Display 1d","Code 3d","Display 3d","equal","3d This is a comment."
|
||||
"http://example.com/codesystem/2","Version 2s","http://example.com/codesystem/3","Version 3t","Code 2a","Display 2a","Code 3a","Display 3a","equal","3a This is a comment."
|
||||
"http://example.com/codesystem/2","Version 2s","http://example.com/codesystem/3","Version 3t","Code 2b","Display 2b","Code 3b","Display 3b","equal","3b This is a comment."
|
||||
"http://example.com/codesystem/2","Version 2s","http://example.com/codesystem/3","Version 3t","Code 2c","Display 2c","Code 3c","Display 3c","equal","3c This is a comment."
|
||||
"http://example.com/codesystem/2","Version 2s","http://example.com/codesystem/3","Version 3t","Code 2d","Display 2d","Code 3d","Display 3d","equal","3d This is a comment."
|
||||
|
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-cli</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-cli</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -80,23 +80,13 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-jetty-http</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -107,6 +107,9 @@ public class LoggingInterceptor implements IClientInterceptor {
|
||||
* Add response location
|
||||
*/
|
||||
List<String> locationHeaders = theResponse.getHeaders(Constants.HEADER_LOCATION);
|
||||
if (locationHeaders == null || locationHeaders.isEmpty()) {
|
||||
locationHeaders = theResponse.getHeaders(Constants.HEADER_CONTENT_LOCATION);
|
||||
}
|
||||
if (locationHeaders != null && locationHeaders.size() > 0) {
|
||||
String locationValue = locationHeaders.get(0);
|
||||
IdDt locationValueId = new IdDt(locationValue);
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -16,14 +16,14 @@
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Server -->
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-server</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -35,43 +35,43 @@
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-r4</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -77,6 +77,21 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>javax.mail-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-schematron</artifactId>
|
||||
@ -330,6 +345,13 @@
|
||||
<sourceDirectory>../hapi-fhir-client-okhttp/src/main/java</sourceDirectory>
|
||||
</sourceDirectories>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -88,6 +88,11 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Unit test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
@ -109,6 +114,20 @@
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
@ -129,6 +148,8 @@
|
||||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
|
@ -69,6 +69,7 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
||||
private org.hl7.fhir.dstu2016may.model.Conformance myDstu2_1Conformance;
|
||||
private org.hl7.fhir.instance.model.Conformance myDstu2Hl7OrgConformance;
|
||||
private ca.uhn.fhir.model.dstu2.resource.Conformance myDstu2Conformance;
|
||||
private boolean myInitialized;
|
||||
|
||||
/**
|
||||
* Constructor allowing the description, servername and server to be set
|
||||
@ -112,7 +113,11 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
||||
* conformance
|
||||
*/
|
||||
@PostConstruct
|
||||
protected void setUpPostConstruct() {
|
||||
protected synchronized void setUpPostConstruct() {
|
||||
if (myInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entry<Class<? extends IResourceProvider>, IResourceProvider> provider : getProviders().entrySet()) {
|
||||
addProvider(provider.getValue(), provider.getKey());
|
||||
}
|
||||
@ -155,6 +160,8 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
||||
default:
|
||||
throw new ConfigurationException("Unsupported Fhir version: " + fhirContextVersion);
|
||||
}
|
||||
|
||||
myInitialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,6 +191,8 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
||||
@GET
|
||||
@Path("/metadata")
|
||||
public Response conformance() throws IOException {
|
||||
setUpPostConstruct();
|
||||
|
||||
Builder request = getRequest(RequestTypeEnum.OPTIONS, RestOperationTypeEnum.METADATA);
|
||||
IRestfulResponse response = request.build().getResponse();
|
||||
response.addHeader(Constants.HEADER_CORS_ALLOW_ORIGIN, "*");
|
||||
|
@ -47,8 +47,8 @@ import ca.uhn.fhir.rest.server.method.BaseMethodBinding;
|
||||
* a large amount of the fhir api functionality using JAXRS
|
||||
* @author Peter Van Houte | peter.vanhoute@agfa.com | Agfa Healthcare
|
||||
*/
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON, Constants.CT_FHIR_JSON, Constants.CT_FHIR_XML, Constants.CT_FHIR_JSON_NEW, Constants.CT_FHIR_XML_NEW })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN, Constants.CT_FHIR_JSON, Constants.CT_FHIR_XML })
|
||||
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON, Constants.CT_FHIR_JSON, Constants.CT_FHIR_XML, Constants.CT_FHIR_JSON_NEW, Constants.CT_FHIR_XML_NEW, "application/octet-stream" })
|
||||
@Interceptors(JaxRsExceptionInterceptor.class)
|
||||
public abstract class AbstractJaxRsResourceProvider<R extends IBaseResource> extends AbstractJaxRsProvider
|
||||
|
||||
|
@ -118,7 +118,7 @@ public class JaxRsMethodBindings {
|
||||
*/
|
||||
public BaseMethodBinding<?> getBinding(RestOperationTypeEnum operationType, String theBindingKey) {
|
||||
String bindingKey = StringUtils.defaultIfBlank(theBindingKey, DEFAULT_METHOD_KEY);
|
||||
ConcurrentHashMap<String, BaseMethodBinding<?>> map = operationBindings.get(operationType);
|
||||
ConcurrentHashMap<String, BaseMethodBinding<?>> map = getMapForOperation(operationType);
|
||||
if(map == null || !map.containsKey(bindingKey)) {
|
||||
throw new NotImplementedOperationException("Operation not implemented");
|
||||
} else {
|
||||
|
@ -6,6 +6,7 @@ import static org.junit.Assert.*;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Priority;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -81,7 +82,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderFetchConformance() throws Exception {
|
||||
public void testAcceptHeaderFetchConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Conformance conf = new Conformance();
|
||||
@ -115,7 +116,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformance() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformance() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final Conformance conf = new Conformance();
|
||||
@ -145,7 +146,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final Conformance conf = new Conformance();
|
||||
@ -175,7 +176,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testConformance() throws Exception {
|
||||
public void testConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Conformance conf = new Conformance();
|
||||
@ -198,7 +199,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProviderWhereWeForgotToSetTheContext() throws Exception {
|
||||
public void testProviderWhereWeForgotToSetTheContext() {
|
||||
JaxRsRestfulClientFactory clientFactory = new JaxRsRestfulClientFactory(); // no ctx
|
||||
clientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
|
||||
@ -214,7 +215,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
public void testCreate() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
@ -246,7 +247,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateConditional() throws Exception {
|
||||
public void testCreateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -290,7 +291,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreatePrefer() throws Exception {
|
||||
public void testCreatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -315,7 +316,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateReturningResourceBody() throws Exception {
|
||||
public void testCreateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
@ -338,7 +339,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteConditional() throws Exception {
|
||||
public void testDeleteConditional() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
@ -363,7 +364,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() throws Exception {
|
||||
public void testDelete() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
@ -377,7 +378,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHistory() throws Exception {
|
||||
public void testHistory() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
@ -474,7 +475,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetaAdd() throws Exception {
|
||||
public void testMetaAdd() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
MetaDt inMeta = new MetaDt().addProfile("urn:profile:in");
|
||||
@ -507,7 +508,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetaGet() throws Exception {
|
||||
public void testMetaGet() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -563,7 +564,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithInParameters() throws Exception {
|
||||
public void testOperationAsGetWithInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -642,7 +643,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithNoInParameters() throws Exception {
|
||||
public void testOperationAsGetWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
@ -713,7 +714,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseJson() throws Exception {
|
||||
public void testOperationWithBundleResponseJson() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_JSON;
|
||||
final String respString = "{\n" + " \"resourceType\":\"Bundle\",\n" + " \"id\":\"8cef5f2a-0ba9-43a5-be26-c8dde9ff0e19\",\n" + " \"base\":\"http://localhost:" + ourPort + "/fhir\"\n" + "}";
|
||||
@ -743,7 +744,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseXml() throws Exception {
|
||||
public void testOperationWithBundleResponseXml() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -780,7 +781,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithInlineParams() throws Exception {
|
||||
public void testOperationWithInlineParams() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
@ -899,7 +900,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithProfiledDatatypeParam() throws IOException, Exception {
|
||||
public void testOperationWithProfiledDatatypeParam() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
@ -948,7 +949,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithListOfParameterResponse() throws Exception {
|
||||
public void testOperationWithListOfParameterResponse() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -1023,7 +1024,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithNoInParameters() throws Exception {
|
||||
public void testOperationWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -1102,7 +1103,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPageNext() throws Exception {
|
||||
public void testPageNext() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
|
||||
ourResponseBody = getPatientFeedWithOneResult();
|
||||
@ -1129,7 +1130,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPageNextNoLink() throws Exception {
|
||||
public void testPageNextNoLink() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle sourceBundle = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
@ -1141,7 +1142,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPagePrev() throws Exception {
|
||||
public void testPagePrev() {
|
||||
|
||||
|
||||
|
||||
@ -1187,7 +1188,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadByUri() throws Exception {
|
||||
public void testReadByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().addFamily("FAM");
|
||||
@ -1207,7 +1208,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadFluentByUri() throws Exception {
|
||||
public void testReadFluentByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().addFamily("FAM");
|
||||
@ -1220,13 +1221,13 @@ public class GenericJaxRsClientDstu2Test {
|
||||
|
||||
Patient response;
|
||||
|
||||
response = (Patient) client.read().resource(Patient.class).withUrl(new IdDt("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
response = client.read().resource(Patient.class).withUrl(new IdDt("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
assertEquals("http://localhost:" + ourPort + "/AAA/Patient/123", ourRequestUri);
|
||||
assertEquals("FAM", response.getName().get(0).getFamily().get(0).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() throws Exception {
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() {
|
||||
|
||||
|
||||
final String input = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
||||
@ -1264,7 +1265,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithElementsParam() throws Exception {
|
||||
public void testReadWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}";
|
||||
|
||||
|
||||
@ -1287,7 +1288,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryInvalid() throws Exception {
|
||||
public void testReadWithSummaryInvalid() {
|
||||
String msg = "<>>>><<<<>";
|
||||
|
||||
|
||||
@ -1313,7 +1314,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryParamHtml() throws Exception {
|
||||
public void testReadWithSummaryParamHtml() {
|
||||
String msg = "<div>HELP IM A DIV</div>";
|
||||
|
||||
|
||||
@ -1338,7 +1339,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByString() throws Exception {
|
||||
public void testSearchByString() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1362,7 +1363,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByUrl() throws Exception {
|
||||
public void testSearchByUrl() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
@ -1469,7 +1470,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithElementsParam() throws Exception {
|
||||
public void testSearchWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1496,7 +1497,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPost() throws Exception {
|
||||
public void testSearchByPost() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1533,7 +1534,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPostUseJson() throws Exception {
|
||||
public void testSearchByPostUseJson() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1571,7 +1572,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithLastUpdated() throws Exception {
|
||||
public void testSearchWithLastUpdated() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1598,7 +1599,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithProfileAndSecurity() throws Exception {
|
||||
public void testSearchWithProfileAndSecurity() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1628,7 +1629,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Test
|
||||
public void testSearchWithReverseInclude() throws Exception {
|
||||
public void testSearchWithReverseInclude() {
|
||||
|
||||
String msg = getPatientFeedWithOneResult();
|
||||
|
||||
@ -1655,7 +1656,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithSummaryParam() throws Exception {
|
||||
public void testSearchWithSummaryParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1682,7 +1683,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithListOfResources() throws Exception {
|
||||
public void testTransactionWithListOfResources() {
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
@ -1735,7 +1736,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithString() throws Exception {
|
||||
public void testTransactionWithString() {
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle req = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
Patient patient = new Patient();
|
||||
@ -1781,7 +1782,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithTransactionResource() throws Exception {
|
||||
public void testTransactionWithTransactionResource() {
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
@ -1822,7 +1823,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateConditional() throws Exception {
|
||||
public void testUpdateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -1877,7 +1878,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNonFluent() throws Exception {
|
||||
public void testUpdateNonFluent() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -1907,7 +1908,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePrefer() throws Exception {
|
||||
public void testUpdatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -1933,7 +1934,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateReturningResourceBody() throws Exception {
|
||||
public void testUpdateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
@ -1956,7 +1957,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateFluent() throws Exception {
|
||||
public void testValidateFluent() {
|
||||
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
@ -2010,7 +2011,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateNonFluent() throws Exception {
|
||||
public void testValidateNonFluent() {
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
final String msg = ourCtx.newXmlParser().encodeResourceToString(oo);
|
||||
@ -2080,7 +2081,7 @@ public class GenericJaxRsClientDstu2Test {
|
||||
ourServer.setHandler(new AbstractHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException, ServletException {
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException {
|
||||
theRequest.setHandled(true);
|
||||
ourRequestUri = "http:" + theRequest.getHttpURI().toString();
|
||||
ourRequestUriAll.add(ourRequestUri);
|
||||
|
@ -79,7 +79,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderFetchConformance() throws Exception {
|
||||
public void testAcceptHeaderFetchConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
CapabilityStatement conf = new CapabilityStatement();
|
||||
@ -113,7 +113,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformance() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformance() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final CapabilityStatement conf = new CapabilityStatement();
|
||||
@ -143,7 +143,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final CapabilityStatement conf = new CapabilityStatement();
|
||||
@ -172,7 +172,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConformance() throws Exception {
|
||||
public void testConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
CapabilityStatement conf = new CapabilityStatement();
|
||||
@ -188,7 +188,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
|
||||
|
||||
//@formatter:off
|
||||
CapabilityStatement resp = (CapabilityStatement)client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
CapabilityStatement resp = client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
|
||||
//@formatter:on
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/metadata", ourRequestUri);
|
||||
@ -199,7 +199,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProviderWhereWeForgotToSetTheContext() throws Exception {
|
||||
public void testProviderWhereWeForgotToSetTheContext() {
|
||||
JaxRsRestfulClientFactory clientFactory = new JaxRsRestfulClientFactory(); // no ctx
|
||||
clientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
|
||||
@ -215,7 +215,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
public void testCreate() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
@ -247,7 +247,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateConditional() throws Exception {
|
||||
public void testCreateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -289,7 +289,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate2() throws Exception {
|
||||
public void testCreate2() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
@ -310,7 +310,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreatePrefer() throws Exception {
|
||||
public void testCreatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -335,7 +335,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateReturningResourceBody() throws Exception {
|
||||
public void testCreateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
@ -358,7 +358,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteConditional() throws Exception {
|
||||
public void testDeleteConditional() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
@ -384,7 +384,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testDeleteNonFluent() throws Exception {
|
||||
public void testDeleteNonFluent() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
@ -398,7 +398,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHistory() throws Exception {
|
||||
public void testHistory() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
@ -494,7 +494,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetaAdd() throws Exception {
|
||||
public void testMetaAdd() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Meta inMeta = new Meta().addProfile("urn:profile:in");
|
||||
@ -527,7 +527,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetaGet() throws Exception {
|
||||
public void testMetaGet() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -583,7 +583,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithInParameters() throws Exception {
|
||||
public void testOperationAsGetWithInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -662,7 +662,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithNoInParameters() throws Exception {
|
||||
public void testOperationAsGetWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
@ -733,7 +733,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseJson() throws Exception {
|
||||
public void testOperationWithBundleResponseJson() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_JSON;
|
||||
final String respString = "{\n" + " \"resourceType\":\"Bundle\",\n" + " \"id\":\"8cef5f2a-0ba9-43a5-be26-c8dde9ff0e19\",\n" + " \"base\":\"http://localhost:" + ourPort + "/fhir\"\n" + "}";
|
||||
@ -763,7 +763,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseXml() throws Exception {
|
||||
public void testOperationWithBundleResponseXml() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -800,7 +800,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithInlineParams() throws Exception {
|
||||
public void testOperationWithInlineParams() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
@ -919,7 +919,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithProfiledDatatypeParam() throws IOException, Exception {
|
||||
public void testOperationWithProfiledDatatypeParam() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
@ -968,7 +968,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithListOfParameterResponse() throws Exception {
|
||||
public void testOperationWithListOfParameterResponse() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -1043,7 +1043,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithNoInParameters() throws Exception {
|
||||
public void testOperationWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
@ -1122,7 +1122,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPageNext() throws Exception {
|
||||
public void testPageNext() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
|
||||
ourResponseBody = getPatientFeedWithOneResult();
|
||||
@ -1149,7 +1149,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPageNextNoLink() throws Exception {
|
||||
public void testPageNextNoLink() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle sourceBundle = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
@ -1161,7 +1161,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPagePrev() throws Exception {
|
||||
public void testPagePrev() {
|
||||
|
||||
|
||||
|
||||
@ -1207,7 +1207,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadByUri() throws Exception {
|
||||
public void testReadByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().setFamily("FAM");
|
||||
@ -1227,7 +1227,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadFluentByUri() throws Exception {
|
||||
public void testReadFluentByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().setFamily("FAM");
|
||||
@ -1240,13 +1240,13 @@ public class GenericJaxRsClientDstu3Test {
|
||||
|
||||
Patient response;
|
||||
|
||||
response = (Patient) client.read().resource(Patient.class).withUrl(new IdType("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
response = client.read().resource(Patient.class).withUrl(new IdType("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
assertEquals("http://localhost:" + ourPort + "/AAA/Patient/123", ourRequestUri);
|
||||
assertEquals("FAM", response.getName().get(0).getFamily());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() throws Exception {
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() {
|
||||
|
||||
//@formatter:off
|
||||
final String input = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
||||
@ -1286,7 +1286,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithElementsParam() throws Exception {
|
||||
public void testReadWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}";
|
||||
|
||||
|
||||
@ -1311,7 +1311,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryInvalid() throws Exception {
|
||||
public void testReadWithSummaryInvalid() {
|
||||
String msg = "<>>>><<<<>";
|
||||
|
||||
|
||||
@ -1338,7 +1338,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryParamHtml() throws Exception {
|
||||
public void testReadWithSummaryParamHtml() {
|
||||
String msg = "<div>HELP IM A DIV</div>";
|
||||
|
||||
|
||||
@ -1365,7 +1365,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByString() throws Exception {
|
||||
public void testSearchByString() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1391,7 +1391,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByUrl() throws Exception {
|
||||
public void testSearchByUrl() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
@ -1498,7 +1498,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithElementsParam() throws Exception {
|
||||
public void testSearchWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1525,7 +1525,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPost() throws Exception {
|
||||
public void testSearchByPost() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1562,7 +1562,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPostUseJson() throws Exception {
|
||||
public void testSearchByPostUseJson() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1600,7 +1600,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithLastUpdated() throws Exception {
|
||||
public void testSearchWithLastUpdated() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1627,7 +1627,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithProfileAndSecurity() throws Exception {
|
||||
public void testSearchWithProfileAndSecurity() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1657,7 +1657,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Test
|
||||
public void testSearchWithReverseInclude() throws Exception {
|
||||
public void testSearchWithReverseInclude() {
|
||||
|
||||
String msg = getPatientFeedWithOneResult();
|
||||
|
||||
@ -1684,7 +1684,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithSummaryParam() throws Exception {
|
||||
public void testSearchWithSummaryParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
@ -1711,7 +1711,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithListOfResources() throws Exception {
|
||||
public void testTransactionWithListOfResources() {
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle resp = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
@ -1764,7 +1764,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithString() throws Exception {
|
||||
public void testTransactionWithString() {
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle req = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
Patient patient = new Patient();
|
||||
@ -1810,7 +1810,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithTransactionResource() throws Exception {
|
||||
public void testTransactionWithTransactionResource() {
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle resp = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
@ -1851,7 +1851,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateConditional() throws Exception {
|
||||
public void testUpdateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -1906,7 +1906,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNonFluent() throws Exception {
|
||||
public void testUpdateNonFluent() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -1936,7 +1936,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePrefer() throws Exception {
|
||||
public void testUpdatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
@ -1962,7 +1962,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateReturningResourceBody() throws Exception {
|
||||
public void testUpdateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
@ -1985,7 +1985,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateFluent() throws Exception {
|
||||
public void testValidateFluent() {
|
||||
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
@ -2039,7 +2039,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateNonFluent() throws Exception {
|
||||
public void testValidateNonFluent() {
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
final String msg = ourCtx.newXmlParser().encodeResourceToString(oo);
|
||||
@ -2109,7 +2109,7 @@ public class GenericJaxRsClientDstu3Test {
|
||||
ourServer.setHandler(new AbstractHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException, ServletException {
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException {
|
||||
theRequest.setHandled(true);
|
||||
ourRequestUri = "http:" + theRequest.getHttpURI().toString();
|
||||
ourRequestUriAll.add(ourRequestUri);
|
||||
|
@ -3,51 +3,56 @@ package ca.uhn.fhir.jaxrs.client;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Sebastien Riviere on 31/07/2017.
|
||||
*/
|
||||
public class JaxRsRestfulClientFactoryTest {
|
||||
|
||||
private final FhirContext context = FhirContext.forDstu2();
|
||||
private JaxRsRestfulClientFactory factory;
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(JaxRsRestfulClientFactoryTest.class);
|
||||
private final FhirContext context = FhirContext.forDstu2();
|
||||
private JaxRsRestfulClientFactory factory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
factory = new JaxRsRestfulClientFactory(context);
|
||||
}
|
||||
@Test
|
||||
public void emptyConstructorTest() {
|
||||
assertNotNull(new JaxRsRestfulClientFactory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyConstructorTest() {
|
||||
assertNotNull(new JaxRsRestfulClientFactory());
|
||||
}
|
||||
@Test
|
||||
public void getDefaultNativeClientTest() {
|
||||
assertNotNull(factory.getNativeClientClient());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefaultNativeClientTest() {
|
||||
assertNotNull(factory.getNativeClientClient());
|
||||
}
|
||||
@Test
|
||||
public void getNativeClientEmptyRegisteredComponentListTest() {
|
||||
factory.register(new ArrayList<>());
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
ourLog.info("Classes: {}", result.getConfiguration().getClasses());
|
||||
assertThat(result.getConfiguration().getClasses(), not(hasItem(ca.uhn.fhir.jaxrs.client.MyFilter.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNativeClientEmptyRegisteredComponentListTest() {
|
||||
factory.register(new ArrayList<Class<?>>());
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
assertTrue(result.getConfiguration().getClasses().isEmpty());
|
||||
}
|
||||
@Test
|
||||
public void getNativeClientRegisteredComponentListTest() {
|
||||
factory.register(Arrays.asList(MyFilter.class, String.class));
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
ourLog.info("Classes: {}", result.getConfiguration().getClasses());
|
||||
assertThat(result.getConfiguration().getClasses(), hasItem(ca.uhn.fhir.jaxrs.client.MyFilter.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNativeClientRegisteredComponentListTest() {
|
||||
factory.register(Arrays.asList(MyFilter.class, String.class));
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.getConfiguration().getClasses().size());
|
||||
}
|
||||
}
|
||||
@Before
|
||||
public void setUp() {
|
||||
factory = new JaxRsRestfulClientFactory(context);
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,24 @@
|
||||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2Hl7Org;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2Hl7Org;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2Hl7Org;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2Hl7Org;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu2Hl7OrgTest {
|
||||
|
||||
@ -29,16 +26,17 @@ public class AbstractJaxRsConformanceProviderDstu2Hl7OrgTest {
|
||||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
@ -1,27 +1,24 @@
|
||||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2_1;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2_1;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2_1;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2_1;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu2_1Test {
|
||||
|
||||
@ -29,19 +26,20 @@ public class AbstractJaxRsConformanceProviderDstu2_1Test {
|
||||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
providers = new ConcurrentHashMap<>();
|
||||
provider = createConformanceProvider(providers);
|
||||
}
|
||||
|
||||
|
@ -1,27 +1,24 @@
|
||||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu3;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu3Test {
|
||||
|
||||
@ -29,16 +26,17 @@ public class AbstractJaxRsConformanceProviderDstu3Test {
|
||||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
@ -1,27 +1,24 @@
|
||||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderR4;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderR4;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderR4;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderR4;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderR4Test {
|
||||
|
||||
@ -29,16 +26,17 @@ public class AbstractJaxRsConformanceProviderR4Test {
|
||||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
@ -1,26 +1,23 @@
|
||||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProvider;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderTest {
|
||||
|
||||
@ -28,16 +25,17 @@ public class AbstractJaxRsConformanceProviderTest {
|
||||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
@ -1,11 +1,24 @@
|
||||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsResponseException;
|
||||
import ca.uhn.fhir.jaxrs.server.test.RandomServerPortProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsConformanceRestProviderDstu3;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPageProviderDstu3;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu3;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.api.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
@ -16,22 +29,21 @@ import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.*;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.mockito.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsExceptionInterceptor;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsResponseException;
|
||||
import ca.uhn.fhir.jaxrs.server.test.*;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
@ -135,7 +147,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
@Test
|
||||
public void testConformance() {
|
||||
final CapabilityStatement conf = client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType().toString(), "Patient");
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType(), "Patient");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -149,7 +161,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome response = client.create().resource(toCreate).prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.execute();
|
||||
IBaseResource resource = (IBaseResource) response.getResource();
|
||||
IBaseResource resource = response.getResource();
|
||||
compareResultId(1, resource);
|
||||
assertEquals("myIdentifier", patientCaptor.getValue().getIdentifier().get(0).getValue());
|
||||
}
|
||||
@ -162,7 +174,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalDelete() throws Exception {
|
||||
public void testConditionalDelete() {
|
||||
when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome());
|
||||
client.delete().resourceConditionalByType("Patient").where(Patient.IDENTIFIER.exactly().identifier("2")).execute();
|
||||
assertEquals("Patient?identifier=2&_format=json", conditionalCaptor.getValue());
|
||||
@ -187,7 +199,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
assertEquals("outputValue", ((StringType)outParams.getParameter().get(0).getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
class StringTypeMatcher extends ArgumentMatcher<StringType> {
|
||||
class StringTypeMatcher implements ArgumentMatcher<StringType> {
|
||||
private StringType myStringType;
|
||||
|
||||
public StringTypeMatcher(StringType stringType) {
|
||||
@ -195,8 +207,8 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object argument) {
|
||||
return myStringType.getValue().equals(((StringType)argument).getValue());
|
||||
public boolean matches(StringType argument) {
|
||||
return myStringType.getValue().equals(argument.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
@ -214,17 +226,18 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
inParams.addParameter().setName("dummy").setValue(new StringType("myAwesomeDummyValue"));
|
||||
|
||||
// invoke
|
||||
Parameters outParams = client.operation().onInstance(new IdType("Patient", "1")).named("$someCustomOperation")
|
||||
.withParameters(inParams).useHttpGet().execute();
|
||||
Parameters outParams = client
|
||||
.operation()
|
||||
.onInstance(new IdType("Patient", "1"))
|
||||
.named("$someCustomOperation")
|
||||
.withParameters(inParams)
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
|
||||
// verify
|
||||
assertEquals("outputValue", ((StringType)outParams.getParameter().get(0).getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
// missing
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() {
|
||||
when(mock.find(idCaptor.capture())).thenReturn(createPatient(1));
|
||||
@ -236,7 +249,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
|
||||
/** Search - Compartments */
|
||||
@Test
|
||||
public void testSearchCompartements() {
|
||||
public void testSearchCompartments() {
|
||||
when(mock.searchCompartment(any(IdType.class))).thenReturn(Arrays.asList((IBaseResource) createPatient(1)));
|
||||
org.hl7.fhir.dstu3.model.Bundle response = client.search().forResource(Patient.class).withIdAndCompartment("1", "Condition")
|
||||
.returnBundle(org.hl7.fhir.dstu3.model.Bundle.class).execute();
|
||||
@ -248,7 +261,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(ArgumentMatchers.isNull(), ArgumentMatchers.isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
org.hl7.fhir.dstu3.model.Bundle result = client.search().forResource("Patient").usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(org.hl7.fhir.dstu3.model.Bundle.class).execute();
|
||||
@ -275,12 +288,12 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
/** Search - Multi-valued Parameters (ANY/OR) */
|
||||
@Test
|
||||
public void testSearchUsingGenericClientBySearchWithMultiValues() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNotNull(StringAndListParam.class)))
|
||||
when(mock.search(any(StringParam.class), ArgumentMatchers.notNull()))
|
||||
.thenReturn(Arrays.asList(createPatient(1)));
|
||||
final Bundle results = client.search().forResource(Patient.class)
|
||||
.where(Patient.ADDRESS.matches().values("Toronto")).and(Patient.ADDRESS.matches().values("Ontario"))
|
||||
.and(Patient.ADDRESS.matches().values("Canada"))
|
||||
.where(Patient.IDENTIFIER.exactly().systemAndIdentifier("SHORTNAME", "TOYS")).returnBundle(Bundle.class).execute();
|
||||
.where(Patient.NAME.matches().value("SHORTNAME")).returnBundle(Bundle.class).execute();
|
||||
IBaseResource resource = results.getEntry().get(0).getResource();
|
||||
|
||||
compareResultId(1, resource);
|
||||
@ -291,7 +304,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
@Test
|
||||
public void testSearchWithPaging() {
|
||||
// Perform a search
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(ArgumentMatchers.isNull(), ArgumentMatchers.isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
final org.hl7.fhir.dstu3.model.Bundle results = client.search().forResource(Patient.class).count(8).returnBundle(org.hl7.fhir.dstu3.model.Bundle.class)
|
||||
.execute();
|
||||
@ -416,17 +429,17 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
TestJaxRsMockPatientRestProviderDstu3.class.getCanonicalName(),
|
||||
JaxRsExceptionInterceptor.class.getCanonicalName(),
|
||||
// JaxRsExceptionInterceptor.class.getCanonicalName(),
|
||||
TestJaxRsConformanceRestProviderDstu3.class.getCanonicalName(),
|
||||
TestJaxRsMockPageProviderDstu3.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
|
||||
jettyServer.start();
|
||||
@ -441,7 +454,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
public static void tearDownClass() {
|
||||
try {
|
||||
jettyServer.destroy();
|
||||
} catch (Exception e) {
|
||||
|
@ -1,35 +1,23 @@
|
||||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsExceptionInterceptor;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsResponseException;
|
||||
import ca.uhn.fhir.jaxrs.server.test.*;
|
||||
import ca.uhn.fhir.jaxrs.server.test.RandomServerPortProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsConformanceRestProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPageProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProvider;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
||||
import ca.uhn.fhir.model.primitive.*;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.model.primitive.DateDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.api.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
@ -37,6 +25,26 @@ import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.junit.*;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class AbstractJaxRsResourceProviderTest {
|
||||
@ -127,7 +135,7 @@ public class AbstractJaxRsResourceProviderTest {
|
||||
@Test
|
||||
public void testConformance() {
|
||||
final Conformance conf = client.fetchConformance().ofType(Conformance.class).execute();
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType().toString(), "Patient");
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType(), "Patient");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -154,7 +162,7 @@ public class AbstractJaxRsResourceProviderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalDelete() throws Exception {
|
||||
public void testConditionalDelete() {
|
||||
when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome());
|
||||
client.delete().resourceConditionalByType("Patient").where(Patient.IDENTIFIER.exactly().identifier("2")).execute();
|
||||
assertEquals("Patient?identifier=2&_format=json", conditionalCaptor.getValue());
|
||||
@ -198,11 +206,6 @@ public class AbstractJaxRsResourceProviderTest {
|
||||
assertEquals("outputValue", ((StringDt) outParams.getParameter().get(0).getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
// missing
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() {
|
||||
when(mock.find(idCaptor.capture())).thenReturn(createPatient(1));
|
||||
@ -226,9 +229,12 @@ public class AbstractJaxRsResourceProviderTest {
|
||||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(isNull(), isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
Bundle result = client.search().forResource("Patient").usingStyle(SearchStyleEnum.POST)
|
||||
Bundle result = client
|
||||
.search()
|
||||
.forResource("Patient")
|
||||
.usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(Bundle.class).execute();
|
||||
IResource resource = result.getEntry().get(0).getResource();
|
||||
compareResultId(1, resource);
|
||||
@ -253,12 +259,12 @@ public class AbstractJaxRsResourceProviderTest {
|
||||
/** Search - Multi-valued Parameters (ANY/OR) */
|
||||
@Test
|
||||
public void testSearchUsingGenericClientBySearchWithMultiValues() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNotNull(StringAndListParam.class)))
|
||||
when(mock.search(any(StringParam.class), any(StringAndListParam.class)))
|
||||
.thenReturn(Arrays.asList(createPatient(1)));
|
||||
Bundle results = client.search().forResource(Patient.class)
|
||||
.where(Patient.ADDRESS.matches().values("Toronto")).and(Patient.ADDRESS.matches().values("Ontario"))
|
||||
.and(Patient.ADDRESS.matches().values("Canada"))
|
||||
.where(Patient.IDENTIFIER.exactly().systemAndIdentifier("SHORTNAME", "TOYS")).returnBundle(Bundle.class).execute();
|
||||
.where(Patient.NAME.matches().value("SHORTNAME")).returnBundle(Bundle.class).execute();
|
||||
IResource resource = results.getEntry().get(0).getResource();
|
||||
|
||||
compareResultId(1, resource);
|
||||
@ -269,7 +275,7 @@ public class AbstractJaxRsResourceProviderTest {
|
||||
@Test
|
||||
public void testSearchWithPaging() {
|
||||
// Perform a search
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(isNull(), isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
final Bundle results = client.search().forResource(Patient.class).limitTo(8).returnBundle(Bundle.class)
|
||||
.execute();
|
||||
@ -370,24 +376,17 @@ public class AbstractJaxRsResourceProviderTest {
|
||||
}
|
||||
|
||||
private <T> T withId(final T id) {
|
||||
return argThat(new BaseMatcher<T>() {
|
||||
@Override
|
||||
public void describeTo(Description arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object other) {
|
||||
IdDt thisId;
|
||||
IdDt otherId;
|
||||
if (id instanceof IdDt) {
|
||||
thisId = (IdDt) id;
|
||||
otherId = (IdDt) other;
|
||||
} else {
|
||||
thisId = ((IResource) id).getId();
|
||||
otherId = ((IResource) other).getId();
|
||||
}
|
||||
return thisId.getIdPartAsLong().equals(otherId.getIdPartAsLong());
|
||||
return argThat(other -> {
|
||||
IdDt thisId;
|
||||
IdDt otherId;
|
||||
if (id instanceof IdDt) {
|
||||
thisId = (IdDt) id;
|
||||
otherId = (IdDt) other;
|
||||
} else {
|
||||
thisId = ((IResource) id).getId();
|
||||
otherId = ((IResource) other).getId();
|
||||
}
|
||||
return thisId.getIdPartAsLong().equals(otherId.getIdPartAsLong());
|
||||
});
|
||||
}
|
||||
|
||||
@ -399,17 +398,16 @@ public class AbstractJaxRsResourceProviderTest {
|
||||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
TestJaxRsMockPatientRestProvider.class.getCanonicalName(),
|
||||
JaxRsExceptionInterceptor.class.getCanonicalName(),
|
||||
TestJaxRsConformanceRestProvider.class.getCanonicalName(),
|
||||
TestJaxRsMockPageProvider.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
|
||||
jettyServer.start();
|
||||
@ -424,7 +422,7 @@ public class AbstractJaxRsResourceProviderTest {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
public static void tearDownClass() {
|
||||
try {
|
||||
jettyServer.destroy();
|
||||
} catch (Exception e) {
|
||||
|
@ -1,34 +1,22 @@
|
||||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
import ca.uhn.fhir.jaxrs.server.util.JaxRsRequest;
|
||||
import ca.uhn.fhir.jaxrs.server.util.JaxRsResponse;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class JaxRsRequestDstu3Test {
|
||||
|
||||
@ -38,7 +26,7 @@ public class JaxRsRequestDstu3Test {
|
||||
|
||||
private JaxRsRequest details;
|
||||
private MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<String, String>();
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private TestJaxRsDummyPatientProviderDstu3 provider;
|
||||
|
||||
@Before
|
||||
@ -52,11 +40,11 @@ public class JaxRsRequestDstu3Test {
|
||||
String headerValue = "location_value";
|
||||
String headerValue2 = "location_value_2";
|
||||
assertTrue(StringUtils.isBlank(details.getHeader(headerKey)));
|
||||
headers.header(headerKey, headerValue);
|
||||
queryParameters.add(headerKey, headerValue);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue), details.getHeaders(headerKey));
|
||||
|
||||
headers.header(headerKey, headerValue2);
|
||||
queryParameters.add(headerKey, headerValue2);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue, headerValue2), details.getHeaders(headerKey));
|
||||
}
|
||||
@ -98,9 +86,9 @@ public class JaxRsRequestDstu3Test {
|
||||
assertEquals(this.provider, details.getServer());
|
||||
}
|
||||
|
||||
public JaxRsRequest createRequestDetails() throws URISyntaxException {
|
||||
//headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null, new MapPropertiesDelegate());
|
||||
public JaxRsRequest createRequestDetails() {
|
||||
// headers
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
//uri info
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
|
@ -1,31 +1,22 @@
|
||||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class JaxRsRequestTest {
|
||||
|
||||
@ -35,7 +26,7 @@ public class JaxRsRequestTest {
|
||||
|
||||
private JaxRsRequest details;
|
||||
private MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<String, String>();
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private TestJaxRsDummyPatientProvider provider;
|
||||
|
||||
@Before
|
||||
@ -49,11 +40,11 @@ public class JaxRsRequestTest {
|
||||
String headerValue = "location_value";
|
||||
String headerValue2 = "location_value_2";
|
||||
assertTrue(StringUtils.isBlank(details.getHeader(headerKey)));
|
||||
headers.header(headerKey, headerValue);
|
||||
queryParameters.add(headerKey, headerValue);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue), details.getHeaders(headerKey));
|
||||
|
||||
headers.header(headerKey, headerValue2);
|
||||
queryParameters.add(headerKey, headerValue2);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue, headerValue2), details.getHeaders(headerKey));
|
||||
}
|
||||
@ -96,8 +87,10 @@ public class JaxRsRequestTest {
|
||||
}
|
||||
|
||||
public JaxRsRequest createRequestDetails() throws URISyntaxException {
|
||||
//headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null, new MapPropertiesDelegate());
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
//uri info
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -58,24 +58,12 @@
|
||||
<version>${jetty_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet-core</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-jetty-http</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
|
@ -43,15 +43,15 @@ public class JaxRsPatientProviderDstu3Test {
|
||||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
JaxRsConformanceProviderDstu3.class.getCanonicalName(),
|
||||
JaxRsPatientRestProviderDstu3.class.getCanonicalName(),
|
||||
JaxRsPageProviderDstu3.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
jettyServer.start();
|
||||
|
||||
@ -108,11 +108,6 @@ public class JaxRsPatientProviderDstu3Test {
|
||||
}
|
||||
}
|
||||
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
//missing
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
|
@ -47,15 +47,15 @@ public class JaxRsPatientProviderTest {
|
||||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
JaxRsConformanceProvider.class.getCanonicalName(),
|
||||
JaxRsPatientRestProvider.class.getCanonicalName(),
|
||||
JaxRsPageProvider.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
jettyServer.start();
|
||||
|
||||
@ -119,11 +119,6 @@ public class JaxRsPatientProviderTest {
|
||||
}
|
||||
}
|
||||
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
// missing
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>3.4.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -205,7 +205,25 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--
|
||||
Dependencies that need to be added since JDK9
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test Database -->
|
||||
<dependency>
|
||||
@ -368,11 +386,22 @@
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.activation</groupId>
|
||||
<artifactId>javax.activation</artifactId>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>javax.el-api</artifactId>
|
||||
@ -566,9 +595,19 @@
|
||||
as JDK9 no longer includes them by default
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>${jaxb_runtime_version}</version>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>${jaxb_api_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>${jaxb_core_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>${jaxb_core_version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
@ -58,6 +58,7 @@ import ca.uhn.fhir.util.*;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.hash.HashFunction;
|
||||
import com.google.common.hash.Hashing;
|
||||
@ -85,6 +86,7 @@ import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
@ -372,22 +374,22 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao,
|
||||
}
|
||||
|
||||
private void expungeCurrentVersionOfResource(Long theResourceId) {
|
||||
ResourceTable resource = myResourceTableDao.findOne(theResourceId);
|
||||
ResourceTable resource = myResourceTableDao.findById(theResourceId).orElseThrow(IllegalStateException::new);
|
||||
|
||||
ResourceHistoryTable currentVersion = myResourceHistoryTableDao.findForIdAndVersion(resource.getId(), resource.getVersion());
|
||||
expungeHistoricalVersion(currentVersion.getId());
|
||||
|
||||
ourLog.info("Deleting current version of resource {}", resource.getIdDt().getValue());
|
||||
|
||||
myResourceIndexedSearchParamUriDao.delete(resource.getParamsUri());
|
||||
myResourceIndexedSearchParamCoordsDao.delete(resource.getParamsCoords());
|
||||
myResourceIndexedSearchParamDateDao.delete(resource.getParamsDate());
|
||||
myResourceIndexedSearchParamNumberDao.delete(resource.getParamsNumber());
|
||||
myResourceIndexedSearchParamQuantityDao.delete(resource.getParamsQuantity());
|
||||
myResourceIndexedSearchParamStringDao.delete(resource.getParamsString());
|
||||
myResourceIndexedSearchParamTokenDao.delete(resource.getParamsToken());
|
||||
myResourceIndexedSearchParamUriDao.deleteAll(resource.getParamsUri());
|
||||
myResourceIndexedSearchParamCoordsDao.deleteAll(resource.getParamsCoords());
|
||||
myResourceIndexedSearchParamDateDao.deleteAll(resource.getParamsDate());
|
||||
myResourceIndexedSearchParamNumberDao.deleteAll(resource.getParamsNumber());
|
||||
myResourceIndexedSearchParamQuantityDao.deleteAll(resource.getParamsQuantity());
|
||||
myResourceIndexedSearchParamStringDao.deleteAll(resource.getParamsString());
|
||||
myResourceIndexedSearchParamTokenDao.deleteAll(resource.getParamsToken());
|
||||
|
||||
myResourceTagDao.delete(resource.getTags());
|
||||
myResourceTagDao.deleteAll(resource.getTags());
|
||||
resource.getTags().clear();
|
||||
|
||||
if (resource.getForcedId() != null) {
|
||||
@ -402,15 +404,15 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao,
|
||||
}
|
||||
|
||||
protected void expungeHistoricalVersion(Long theNextVersionId) {
|
||||
ResourceHistoryTable version = myResourceHistoryTableDao.findOne(theNextVersionId);
|
||||
ResourceHistoryTable version = myResourceHistoryTableDao.findById(theNextVersionId).orElseThrow(IllegalArgumentException::new);
|
||||
ourLog.info("Deleting resource version {}", version.getIdDt().getValue());
|
||||
|
||||
myResourceHistoryTagDao.delete(version.getTags());
|
||||
myResourceHistoryTagDao.deleteAll(version.getTags());
|
||||
myResourceHistoryTableDao.delete(version);
|
||||
}
|
||||
|
||||
protected void expungeHistoricalVersionsOfId(Long theResourceId, AtomicInteger theRemainingCount) {
|
||||
ResourceTable resource = myResourceTableDao.findOne(theResourceId);
|
||||
ResourceTable resource = myResourceTableDao.findById(theResourceId).orElseThrow(IllegalArgumentException::new);
|
||||
|
||||
Pageable page = new PageRequest(0, theRemainingCount.get());
|
||||
|
||||
@ -727,23 +729,32 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao,
|
||||
|
||||
private Map<Class<? extends IBaseResource>, IFhirResourceDao<?>> getDaos() {
|
||||
if (myResourceTypeToDao == null) {
|
||||
Map<Class<? extends IBaseResource>, IFhirResourceDao<?>> theResourceTypeToDao = new HashMap<>();
|
||||
Map<Class<? extends IBaseResource>, IFhirResourceDao<?>> resourceTypeToDao = new HashMap<>();
|
||||
|
||||
Map<String, IFhirResourceDao> daos = myApplicationContext.getBeansOfType(IFhirResourceDao.class, false, false);
|
||||
|
||||
String[] beanNames = myApplicationContext.getBeanNamesForType(IFhirResourceDao.class);
|
||||
|
||||
for (IFhirResourceDao<?> next : daos.values()) {
|
||||
theResourceTypeToDao.put(next.getResourceType(), next);
|
||||
resourceTypeToDao.put(next.getResourceType(), next);
|
||||
}
|
||||
|
||||
if (this instanceof IFhirResourceDao<?>) {
|
||||
IFhirResourceDao<?> thiz = (IFhirResourceDao<?>) this;
|
||||
theResourceTypeToDao.put(thiz.getResourceType(), thiz);
|
||||
resourceTypeToDao.put(thiz.getResourceType(), thiz);
|
||||
}
|
||||
|
||||
myResourceTypeToDao = theResourceTypeToDao;
|
||||
myResourceTypeToDao = resourceTypeToDao;
|
||||
}
|
||||
|
||||
return Collections.unmodifiableMap(myResourceTypeToDao);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void startClearCaches() {
|
||||
myResourceTypeToDao = null;
|
||||
}
|
||||
|
||||
|
||||
protected Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return mySearchParamExtractor.extractSearchParamCoords(theEntity, theResource);
|
||||
@ -948,7 +959,14 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao,
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext theApplicationContext) throws BeansException {
|
||||
myApplicationContext = theApplicationContext;
|
||||
/*
|
||||
* We do a null check here because Smile's module system tries to
|
||||
* initialize the application context twice if two modules depend on
|
||||
* the persistence module. The second time sets the dependency's appctx.
|
||||
*/
|
||||
if (myApplicationContext == null) {
|
||||
myApplicationContext = theApplicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfig(DaoConfig theConfig) {
|
||||
|
@ -1314,7 +1314,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
||||
|
||||
if (myDaoConfig.isEnforceReferentialIntegrityOnDelete() == false && !theForValidate) {
|
||||
ourLog.debug("Deleting {} resource dependencies which can no longer be satisfied", resultList.size());
|
||||
myResourceLinkDao.delete(resultList);
|
||||
myResourceLinkDao.deleteAll(resultList);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1336,5 +1336,9 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void start() {
|
||||
ourLog.debug("Starting resource DAO for type: {}", getResourceName());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ public abstract class BaseHapiFhirSystemDao<T, MT> extends BaseHapiFhirDao<IBase
|
||||
@Transactional(propagation = Propagation.NEVER)
|
||||
public Integer performReindexingPass(final Integer theCount) {
|
||||
if (!myReindexLock.tryLock()) {
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
try {
|
||||
return doPerformReindexingPass(theCount);
|
||||
@ -288,7 +288,7 @@ public abstract class BaseHapiFhirSystemDao<T, MT> extends BaseHapiFhirDao<IBase
|
||||
reindexFailure = txTemplate.execute(new TransactionCallback<Throwable>() {
|
||||
@Override
|
||||
public Throwable doInTransaction(TransactionStatus theStatus) {
|
||||
ResourceTable resourceTable = myResourceTableDao.findOne(myNextId);
|
||||
ResourceTable resourceTable = myResourceTableDao.findById(myNextId).orElseThrow(IllegalStateException::new);
|
||||
|
||||
try {
|
||||
/*
|
||||
@ -305,7 +305,7 @@ public abstract class BaseHapiFhirSystemDao<T, MT> extends BaseHapiFhirDao<IBase
|
||||
|
||||
final IBaseResource resource = toResource(resourceTable, false);
|
||||
|
||||
@SuppressWarnings("rawtypes") final IFhirResourceDao dao = getDao(resource.getClass());
|
||||
@SuppressWarnings("rawtypes") final IFhirResourceDao dao = getDaoOrThrowException(resource.getClass());
|
||||
dao.reindex(resource, resourceTable);
|
||||
return null;
|
||||
|
||||
|
@ -3,9 +3,11 @@ package ca.uhn.fhir.jpa.dao;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceEncodingEnum;
|
||||
import ca.uhn.fhir.jpa.util.JpaConstants;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -62,6 +64,19 @@ public class DaoConfig {
|
||||
* @see #setMaximumSearchResultCountInTransaction(Integer)
|
||||
*/
|
||||
private static final Integer DEFAULT_MAXIMUM_SEARCH_RESULT_COUNT_IN_TRANSACTION = null;
|
||||
/**
|
||||
* Default {@link #setBundleTypesAllowedForStorage(Set)} value:
|
||||
* <ul>
|
||||
* <li>collection</li>
|
||||
* <li>document</li>
|
||||
* <li>message</li>
|
||||
* </ul>
|
||||
*/
|
||||
private static final Set<String> DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE = Collections.unmodifiableSet(new TreeSet<>(Sets.newHashSet(
|
||||
Bundle.BundleType.COLLECTION.toCode(),
|
||||
Bundle.BundleType.DOCUMENT.toCode(),
|
||||
Bundle.BundleType.MESSAGE.toCode()
|
||||
)));
|
||||
private IndexEnabledEnum myIndexMissingFieldsEnabled = IndexEnabledEnum.DISABLED;
|
||||
/**
|
||||
* update setter javadoc if default changes
|
||||
@ -128,6 +143,7 @@ public class DaoConfig {
|
||||
private boolean myMarkResourcesForReindexingUponSearchParameterChange;
|
||||
private boolean myExpungeEnabled;
|
||||
private int myReindexThreadCount;
|
||||
private Set<String> myBundleTypesAllowedForStorage;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -138,6 +154,7 @@ public class DaoConfig {
|
||||
setSubscriptionPurgeInactiveAfterMillis(Long.MAX_VALUE);
|
||||
setMarkResourcesForReindexingUponSearchParameterChange(true);
|
||||
setReindexThreadCount(Runtime.getRuntime().availableProcessors());
|
||||
setBundleTypesAllowedForStorage(DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,6 +171,27 @@ public class DaoConfig {
|
||||
myTreatReferencesAsLogical.add(theTreatReferencesAsLogical);
|
||||
}
|
||||
|
||||
/**
|
||||
* This setting specifies the bundle types (<code>Bundle.type</code>) that
|
||||
* are allowed to be stored as-is on the /Bundle endpoint.
|
||||
*
|
||||
* @see #DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE
|
||||
*/
|
||||
public Set<String> getBundleTypesAllowedForStorage() {
|
||||
return myBundleTypesAllowedForStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* This setting specifies the bundle types (<code>Bundle.type</code>) that
|
||||
* are allowed to be stored as-is on the /Bundle endpoint.
|
||||
*
|
||||
* @see #DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE
|
||||
*/
|
||||
public void setBundleTypesAllowedForStorage(Set<String> theBundleTypesAllowedForStorage) {
|
||||
Validate.notNull(theBundleTypesAllowedForStorage, "theBundleTypesAllowedForStorage must not be null");
|
||||
myBundleTypesAllowedForStorage = theBundleTypesAllowedForStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the highest number that a client is permitted to use in a
|
||||
* <code>Cache-Control: nostore, max-results=NNN</code>
|
||||
@ -418,11 +456,8 @@ public class DaoConfig {
|
||||
/**
|
||||
* This may be used to optionally register server interceptors directly against the DAOs.
|
||||
*/
|
||||
public void setInterceptors(IServerInterceptor... theInterceptor) {
|
||||
setInterceptors(new ArrayList<IServerInterceptor>());
|
||||
if (theInterceptor != null && theInterceptor.length != 0) {
|
||||
getInterceptors().addAll(Arrays.asList(theInterceptor));
|
||||
}
|
||||
public void setInterceptors(List<IServerInterceptor> theInterceptors) {
|
||||
myInterceptors = theInterceptors;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1164,8 +1199,11 @@ public class DaoConfig {
|
||||
/**
|
||||
* This may be used to optionally register server interceptors directly against the DAOs.
|
||||
*/
|
||||
public void setInterceptors(List<IServerInterceptor> theInterceptors) {
|
||||
myInterceptors = theInterceptors;
|
||||
public void setInterceptors(IServerInterceptor... theInterceptor) {
|
||||
setInterceptors(new ArrayList<IServerInterceptor>());
|
||||
if (theInterceptor != null && theInterceptor.length != 0) {
|
||||
getInterceptors().addAll(Arrays.asList(theInterceptor));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,14 +25,19 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
||||
public class FhirResourceDaoBundleDstu2 extends FhirResourceDaoDstu2<Bundle> {
|
||||
|
||||
@Override
|
||||
protected void preProcessResourceForStorage(Bundle theResource) {
|
||||
super.preProcessResourceForStorage(theResource);
|
||||
|
||||
if (theResource.getTypeElement().getValueAsEnum() != BundleTypeEnum.DOCUMENT && theResource.getTypeElement().getValueAsEnum() != BundleTypeEnum.COLLECTION) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type of: " + (theResource.getTypeElement().getValueAsEnum() != null ? theResource.getTypeElement().getValueAsEnum().getCode() : "(missing)");
|
||||
Set<String> allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage();
|
||||
if (!allowedBundleTypes.contains(defaultString(theResource.getType()))) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type value of: " + (theResource.getType() != null ? theResource.getType() : "(missing)");
|
||||
throw new UnprocessableEntityException(message);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,9 @@ import org.hibernate.search.query.dsl.QueryBuilder;
|
||||
import org.hl7.fhir.dstu3.model.BaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
@ -57,10 +59,14 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
|
||||
|
||||
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
|
||||
private EntityManager myEntityManager;
|
||||
@Autowired
|
||||
private PlatformTransactionManager myTxManager;
|
||||
|
||||
@Autowired
|
||||
protected IForcedIdDao myForcedIdDao;
|
||||
|
||||
private Boolean ourDisabled;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -73,7 +79,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
|
||||
return;
|
||||
}
|
||||
for (List<? extends IQueryParameterType> nextAnd : theTerms) {
|
||||
Set<String> terms = new HashSet<String>();
|
||||
Set<String> terms = new HashSet<>();
|
||||
for (IQueryParameterType nextOr : nextAnd) {
|
||||
StringParam nextOrString = (StringParam) nextOr;
|
||||
String nextValueTrimmed = StringUtils.defaultString(nextOrString.getValue()).trim();
|
||||
@ -229,15 +235,25 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
try {
|
||||
FullTextEntityManager em = org.hibernate.search.jpa.Search.getFullTextEntityManager(myEntityManager);
|
||||
em.getSearchFactory().buildQueryBuilder().forEntity(ResourceTable.class).get();
|
||||
} catch (Exception e) {
|
||||
ourLog.trace("FullText test failed", e);
|
||||
ourLog.debug("Hibernate Search (Lucene) appears to be disabled on this server, fulltext will be disabled");
|
||||
return true;
|
||||
Boolean retVal = ourDisabled;
|
||||
|
||||
if (retVal == null) {
|
||||
retVal = new TransactionTemplate(myTxManager).execute(t -> {
|
||||
try {
|
||||
FullTextEntityManager em = org.hibernate.search.jpa.Search.getFullTextEntityManager(myEntityManager);
|
||||
em.getSearchFactory().buildQueryBuilder().forEntity(ResourceTable.class).get();
|
||||
return Boolean.FALSE;
|
||||
} catch (Exception e) {
|
||||
ourLog.trace("FullText test failed", e);
|
||||
ourLog.debug("Hibernate Search (Lucene) appears to be disabled on this server, fulltext will be disabled");
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
});
|
||||
ourDisabled = retVal;
|
||||
}
|
||||
return false;
|
||||
|
||||
assert retVal != null;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Transactional()
|
||||
@ -246,6 +262,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
|
||||
return doSearch(theResourceName, theParams, null);
|
||||
}
|
||||
|
||||
@Transactional()
|
||||
@Override
|
||||
public List<Suggestion> suggestKeywords(String theContext, String theSearchParam, String theText) {
|
||||
Validate.notBlank(theContext, "theContext must be provided");
|
||||
|
@ -144,7 +144,7 @@ import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
/**
|
||||
* The SearchBuilder is responsible for actually forming the SQL query that handles
|
||||
* searchs for resources
|
||||
* searches for resources
|
||||
*/
|
||||
public class SearchBuilder implements ISearchBuilder {
|
||||
|
||||
@ -152,6 +152,7 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchBuilder.class);
|
||||
private static Long NO_MORE = -1L;
|
||||
private static HandlerTypeEnum ourLastHandlerMechanismForUnitTest;
|
||||
private static SearchParameterMap ourLastHandlerParamsForUnitTest;
|
||||
private List<Long> myAlsoIncludePids;
|
||||
private CriteriaBuilder myBuilder;
|
||||
private BaseHapiFhirDao<?> myCallingDao;
|
||||
@ -1089,6 +1090,8 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
num = builder.or(lowPred, highPred);
|
||||
}
|
||||
break;
|
||||
case ENDS_BEFORE:
|
||||
case STARTS_AFTER:
|
||||
default:
|
||||
String msg = myContext.getLocalizer().getMessage(SearchBuilder.class, invalidMessageName, thePrefix.getValue(), theParam.getValueAsQueryToken(myContext));
|
||||
throw new InvalidRequestException(msg);
|
||||
@ -1374,6 +1377,7 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
}
|
||||
|
||||
Set<String> uniqueQueryStrings = BaseHapiFhirDao.extractCompositeStringUniquesValueChains(myResourceName, params);
|
||||
ourLastHandlerParamsForUnitTest = theParams;
|
||||
ourLastHandlerMechanismForUnitTest = HandlerTypeEnum.UNIQUE_INDEX;
|
||||
return new UniqueIndexIterator(uniqueQueryStrings);
|
||||
|
||||
@ -1385,6 +1389,7 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
ourLastHandlerParamsForUnitTest = theParams;
|
||||
ourLastHandlerMechanismForUnitTest = HandlerTypeEnum.STANDARD_QUERY;
|
||||
return new QueryIterator();
|
||||
}
|
||||
@ -1598,6 +1603,8 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
sortAttrName = new String[] {"myValue"};
|
||||
joinType = JoinEnum.QUANTITY;
|
||||
break;
|
||||
case COMPOSITE:
|
||||
case HAS:
|
||||
default:
|
||||
throw new InvalidRequestException("This server does not support _sort specifications of type " + param.getParamType() + " - Can't serve _sort=" + theSort.getParamName());
|
||||
}
|
||||
@ -1832,7 +1839,6 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
roundCounts++;
|
||||
|
||||
HashSet<Long> pidsToInclude = new HashSet<>();
|
||||
Set<Long> nextRoundOmit = new HashSet<>();
|
||||
|
||||
for (Iterator<Include> iter = includes.iterator(); iter.hasNext(); ) {
|
||||
Include nextInclude = iter.next();
|
||||
@ -1927,8 +1933,6 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pidsToInclude.removeAll(nextRoundOmit);
|
||||
|
||||
addedSomeThisRound = allAdded.addAll(pidsToInclude);
|
||||
nextRoundMatches = pidsToInclude;
|
||||
} while (includes.size() > 0 && nextRoundMatches.size() > 0 && addedSomeThisRound);
|
||||
@ -2104,6 +2108,8 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
case REFERENCE:
|
||||
qp = new ReferenceParam();
|
||||
break;
|
||||
case URI:
|
||||
case HAS:
|
||||
default:
|
||||
throw new InternalErrorException("Don't know how to convert param type: " + theParam.getParamType());
|
||||
}
|
||||
@ -2202,14 +2208,18 @@ public class SearchBuilder implements ISearchBuilder {
|
||||
|
||||
@VisibleForTesting
|
||||
public static HandlerTypeEnum getLastHandlerMechanismForUnitTest() {
|
||||
ourLog.info("Retrieving last handler mechanism: {}", ourLastHandlerMechanismForUnitTest);
|
||||
return ourLastHandlerMechanismForUnitTest;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static SearchParameterMap getLastHandlerParamsForUnitTest() {
|
||||
return ourLastHandlerParamsForUnitTest;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static void resetLastHandlerMechanismForUnitTest() {
|
||||
ourLog.info("Clearing last handler mechanism (was {})", ourLastHandlerMechanismForUnitTest);
|
||||
ourLastHandlerMechanismForUnitTest = null;
|
||||
ourLastHandlerParamsForUnitTest = null;
|
||||
}
|
||||
|
||||
static Predicate[] toArray(List<Predicate> thePredicates) {
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.data.repository.query.Param;
|
||||
*/
|
||||
|
||||
public interface ITermConceptMapGroupDao extends JpaRepository<TermConceptMapGroup, Long> {
|
||||
@Query("DELETE FROM TermConceptMapGroup g WHERE g.myConceptMap.myId = :pid")
|
||||
@Query("DELETE FROM TermConceptMapGroup g WHERE g.myId = :pid")
|
||||
@Modifying
|
||||
void deleteTermConceptMapGroupById(@Param("pid") Long theId);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.data.repository.query.Param;
|
||||
*/
|
||||
|
||||
public interface ITermConceptMapGroupElementDao extends JpaRepository<TermConceptMapGroupElement, Long> {
|
||||
@Query("DELETE FROM TermConceptMapGroupElement e WHERE e.myConceptMapGroup.myConceptMap.myId = :pid")
|
||||
@Query("DELETE FROM TermConceptMapGroupElement e WHERE e.myId = :pid")
|
||||
@Modifying
|
||||
void deleteTermConceptMapGroupElementById(@Param("pid") Long theId);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.data.repository.query.Param;
|
||||
*/
|
||||
|
||||
public interface ITermConceptMapGroupElementTargetDao extends JpaRepository<TermConceptMapGroupElementTarget, Long> {
|
||||
@Query("DELETE FROM TermConceptMapGroupElementTarget t WHERE t.myConceptMapGroupElement.myConceptMapGroup.myConceptMap.myId = :pid")
|
||||
@Query("DELETE FROM TermConceptMapGroupElementTarget t WHERE t.myId = :pid")
|
||||
@Modifying
|
||||
void deleteTermConceptMapGroupElementTargetById(@Param("pid") Long theId);
|
||||
}
|
||||
|
@ -25,13 +25,18 @@ import org.hl7.fhir.dstu3.model.Bundle.BundleType;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
||||
public class FhirResourceDaoBundleDstu3 extends FhirResourceDaoDstu3<Bundle> {
|
||||
|
||||
@Override
|
||||
protected void preProcessResourceForStorage(Bundle theResource) {
|
||||
super.preProcessResourceForStorage(theResource);
|
||||
|
||||
if (theResource.getType() != BundleType.DOCUMENT && theResource.getType() != BundleType.COLLECTION) {
|
||||
Set<String> allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage();
|
||||
if (theResource.getType() == null || !allowedBundleTypes.contains(defaultString(theResource.getType().toCode()))) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type value of: " + (theResource.getType() != null ? theResource.getType().toCode() : "(missing)");
|
||||
throw new UnprocessableEntityException(message);
|
||||
}
|
||||
|
@ -25,19 +25,23 @@ import org.hl7.fhir.r4.model.Bundle.BundleType;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
||||
public class FhirResourceDaoBundleR4 extends FhirResourceDaoR4<Bundle> {
|
||||
|
||||
@Override
|
||||
protected void preProcessResourceForStorage(Bundle theResource) {
|
||||
super.preProcessResourceForStorage(theResource);
|
||||
|
||||
if (theResource.getType() != BundleType.DOCUMENT && theResource.getType() != BundleType.COLLECTION) {
|
||||
Set<String> allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage();
|
||||
if (theResource.getType() == null || !allowedBundleTypes.contains(defaultString(theResource.getType().toCode()))) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type value of: " + (theResource.getType() != null ? theResource.getType().toCode() : "(missing)");
|
||||
throw new UnprocessableEntityException(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -115,11 +115,12 @@ public class TermConceptMap implements Serializable {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("myId", myId)
|
||||
.append("myResource", myResource.toString())
|
||||
.append(myResource != null ? ("myResource=" + myResource.toString()) : ("myResource=(null)"))
|
||||
.append("myResourcePid", myResourcePid)
|
||||
.append("mySource", mySource)
|
||||
.append("myTarget", myTarget)
|
||||
.append("myUrl", myUrl)
|
||||
.append("myConceptMapGroups - size", myConceptMapGroups.size())
|
||||
.append(myConceptMapGroups != null ? ("myConceptMapGroups - size=" + myConceptMapGroups.size()) : ("myConceptMapGroups=(null)"))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -137,12 +137,12 @@ public class TermConceptMapGroup implements Serializable {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("myId", myId)
|
||||
.append("myConceptMap - id", myConceptMap.getId())
|
||||
.append(myConceptMap != null ? ("myConceptMap - id=" + myConceptMap.getId()) : ("myConceptMap=(null)"))
|
||||
.append("mySource", mySource)
|
||||
.append("mySourceVersion", mySourceVersion)
|
||||
.append("myTarget", myTarget)
|
||||
.append("myTargetVersion", myTargetVersion)
|
||||
.append("myConceptMapGroupElements - size", myConceptMapGroupElements.size())
|
||||
.append(myConceptMapGroupElements != null ? ("myConceptMapGroupElements - size=" + myConceptMapGroupElements.size()) : ("myConceptMapGroupElements=(null)"))
|
||||
.append("myConceptMapUrl", this.getConceptMapUrl())
|
||||
.append("mySourceValueSet", this.getSourceValueSet())
|
||||
.append("myTargetValueSet", this.getTargetValueSet())
|
||||
|
@ -151,10 +151,10 @@ public class TermConceptMapGroupElement implements Serializable {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("myId", myId)
|
||||
.append("myConceptMapGroup - id", myConceptMapGroup.getId())
|
||||
.append(myConceptMapGroup != null ? ("myConceptMapGroup - id=" + myConceptMapGroup.getId()) : ("myConceptMapGroup=(null)"))
|
||||
.append("myCode", myCode)
|
||||
.append("myDisplay", myDisplay)
|
||||
.append("myConceptMapGroupElementTargets - size", myConceptMapGroupElementTargets.size())
|
||||
.append(myConceptMapGroupElementTargets != null ? ("myConceptMapGroupElementTargets - size=" + myConceptMapGroupElementTargets.size()) : ("myConceptMapGroupElementTargets=(null)"))
|
||||
.append("myConceptMapUrl", this.getConceptMapUrl())
|
||||
.append("mySystem", this.getSystem())
|
||||
.append("mySystemVersion", this.getSystemVersion())
|
||||
|
@ -153,7 +153,7 @@ public class TermConceptMapGroupElementTarget implements Serializable {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("myId", myId)
|
||||
.append("myConceptMapGroupElement - id", myConceptMapGroupElement.getId())
|
||||
.append(myConceptMapGroupElement != null ? ("myConceptMapGroupElement - id=" + myConceptMapGroupElement.getId()) : ("myConceptMapGroupElement=(null)"))
|
||||
.append("myCode", myCode)
|
||||
.append("myDisplay", myDisplay)
|
||||
.append("myEquivalence", myEquivalence.toCode())
|
||||
|
@ -75,13 +75,13 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
||||
mySearchEntity = null;
|
||||
}
|
||||
|
||||
protected List<IBaseResource> doHistoryInTransaction(int theFromIndex, int theToIndex) {
|
||||
private List<IBaseResource> doHistoryInTransaction(int theFromIndex, int theToIndex) {
|
||||
List<ResourceHistoryTable> results;
|
||||
|
||||
CriteriaBuilder cb = myEntityManager.getCriteriaBuilder();
|
||||
CriteriaQuery<ResourceHistoryTable> q = cb.createQuery(ResourceHistoryTable.class);
|
||||
Root<ResourceHistoryTable> from = q.from(ResourceHistoryTable.class);
|
||||
List<Predicate> predicates = new ArrayList<Predicate>();
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (mySearchEntity.getResourceType() == null) {
|
||||
// All resource types
|
||||
@ -215,6 +215,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return myUuid;
|
||||
}
|
||||
@ -223,7 +224,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
||||
return myCacheHit;
|
||||
}
|
||||
|
||||
public void setCacheHit(boolean theCacheHit) {
|
||||
void setCacheHit(boolean theCacheHit) {
|
||||
myCacheHit = theCacheHit;
|
||||
}
|
||||
|
||||
@ -253,7 +254,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
||||
mySearchDao = theSearchDao;
|
||||
}
|
||||
|
||||
protected void setSearchEntity(Search theSearchEntity) {
|
||||
void setSearchEntity(Search theSearchEntity) {
|
||||
mySearchEntity = theSearchEntity;
|
||||
}
|
||||
|
||||
@ -269,8 +270,8 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
||||
return Math.max(0, size);
|
||||
}
|
||||
|
||||
protected List<IBaseResource> toResourceList(ISearchBuilder sb, List<Long> pidsSubList) {
|
||||
Set<Long> includedPids = new HashSet<Long>();
|
||||
List<IBaseResource> toResourceList(ISearchBuilder sb, List<Long> pidsSubList) {
|
||||
Set<Long> includedPids = new HashSet<>();
|
||||
if (mySearchEntity.getSearchType() == SearchTypeEnum.SEARCH) {
|
||||
includedPids.addAll(sb.loadReverseIncludes(myDao, myContext, myEntityManager, pidsSubList, mySearchEntity.toRevIncludesList(), true, mySearchEntity.getLastUpdated()));
|
||||
includedPids.addAll(sb.loadReverseIncludes(myDao, myContext, myEntityManager, pidsSubList, mySearchEntity.toIncludesList(), false, mySearchEntity.getLastUpdated()));
|
||||
|
@ -420,7 +420,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
public long getOffset() {
|
||||
return theFromIndex;
|
||||
}
|
||||
};
|
||||
@ -702,7 +702,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
||||
nextResult.setOrder(myCountSaved++);
|
||||
resultsToSave.add(nextResult);
|
||||
}
|
||||
mySearchResultDao.save(resultsToSave);
|
||||
mySearchResultDao.saveAll(resultsToSave);
|
||||
|
||||
synchronized (mySyncedPids) {
|
||||
int numSyncedThisPass = myUnsyncedPids.size();
|
||||
|
@ -67,13 +67,12 @@ public class StaleSearchDeletingSvcImpl implements IStaleSearchDeletingSvc {
|
||||
private PlatformTransactionManager myTransactionManager;
|
||||
|
||||
private void deleteSearch(final Long theSearchPid) {
|
||||
Search searchToDelete = mySearchDao.findOne(theSearchPid);
|
||||
if (searchToDelete != null) {
|
||||
mySearchDao.findById(theSearchPid).ifPresent(searchToDelete -> {
|
||||
ourLog.info("Deleting search {}/{} - Created[{}] -- Last returned[{}]", searchToDelete.getId(), searchToDelete.getUuid(), new InstantType(searchToDelete.getCreated()), new InstantType(searchToDelete.getSearchLastReturned()));
|
||||
mySearchIncludeDao.deleteForSearch(searchToDelete.getId());
|
||||
mySearchResultDao.deleteForSearch(searchToDelete.getId());
|
||||
mySearchDao.delete(searchToDelete);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,7 +104,7 @@ public class SearchParamPresenceSvcImpl implements ISearchParamPresenceSvc {
|
||||
}
|
||||
|
||||
mySearchParamPresentDao.deleteInBatch(entitiesToDelete);
|
||||
mySearchParamPresentDao.save(entitiesToSave);
|
||||
mySearchParamPresentDao.saveAll(entitiesToSave);
|
||||
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
||||
ourLog.info(" * Deleting code system {}", theCodeSystem.getPid());
|
||||
|
||||
myEntityManager.flush();
|
||||
TermCodeSystem cs = myCodeSystemDao.findOne(theCodeSystem.getPid());
|
||||
TermCodeSystem cs = myCodeSystemDao.findById(theCodeSystem.getPid()).orElseThrow(IllegalStateException::new);
|
||||
cs.setCurrentVersion(null);
|
||||
myCodeSystemDao.save(cs);
|
||||
myCodeSystemDao.flush();
|
||||
@ -252,8 +252,8 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
||||
for (TermCodeSystemVersion next : myCodeSystemVersionDao.findByCodeSystemResource(theCodeSystem.getPid())) {
|
||||
myConceptParentChildLinkDao.deleteByCodeSystemVersion(next.getPid());
|
||||
for (TermConcept nextConcept : myConceptDao.findByCodeSystemVersion(next.getPid())) {
|
||||
myConceptPropertyDao.delete(nextConcept.getProperties());
|
||||
myConceptDesignationDao.delete(nextConcept.getDesignations());
|
||||
myConceptPropertyDao.deleteAll(nextConcept.getProperties());
|
||||
myConceptDesignationDao.deleteAll(nextConcept.getDesignations());
|
||||
myConceptDao.delete(nextConcept);
|
||||
}
|
||||
if (next.getCodeSystem().getCurrentVersion() == next) {
|
||||
@ -639,7 +639,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
||||
while (relCount < count && myConceptLinksToSaveLater.size() > 0) {
|
||||
TermConceptParentChildLink next = myConceptLinksToSaveLater.remove(0);
|
||||
|
||||
if (myConceptDao.findOne(next.getChild().getId()) == null || myConceptDao.findOne(next.getParent().getId()) == null) {
|
||||
if (!myConceptDao.findById(next.getChild().getId()).isPresent() || !myConceptDao.findById(next.getParent().getId()).isPresent()) {
|
||||
ourLog.warn("Not inserting link from child {} to parent {} because it appears to have been deleted", next.getParent().getCode(), next.getChild().getCode());
|
||||
continue;
|
||||
}
|
||||
@ -850,7 +850,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
||||
ourLog.info(" * Deleting code system version {}", next.getPid());
|
||||
myConceptParentChildLinkDao.deleteByCodeSystemVersion(next.getPid());
|
||||
for (TermConcept nextConcept : myConceptDao.findByCodeSystemVersion(next.getPid())) {
|
||||
myConceptPropertyDao.delete(nextConcept.getProperties());
|
||||
myConceptPropertyDao.deleteAll(nextConcept.getProperties());
|
||||
myConceptDao.delete(nextConcept);
|
||||
}
|
||||
}
|
||||
@ -964,20 +964,33 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
||||
termConceptMap.setUrl(theConceptMap.getUrl());
|
||||
|
||||
// Get existing entity so it can be deleted.
|
||||
Optional<TermConceptMap> optionalExistingTermConceptMapById = myConceptMapDao.findTermConceptMapByResourcePid(termConceptMap.getResourcePid());
|
||||
Optional<TermConceptMap> optionalExistingTermConceptMapById = myConceptMapDao.findTermConceptMapByResourcePid(theResourceTable.getId());
|
||||
|
||||
/*
|
||||
* For now we always delete old versions. At some point, it would be nice to allow configuration to keep old versions.
|
||||
*/
|
||||
|
||||
if (optionalExistingTermConceptMapById.isPresent()) {
|
||||
Long id = optionalExistingTermConceptMapById.get().getId();
|
||||
ourLog.info("Deleting existing TermConceptMap {} and its children...", id);
|
||||
myConceptMapGroupElementTargetDao.deleteTermConceptMapGroupElementTargetById(id);
|
||||
myConceptMapGroupElementDao.deleteTermConceptMapGroupElementById(id);
|
||||
myConceptMapGroupDao.deleteTermConceptMapGroupById(id);
|
||||
myConceptMapDao.deleteTermConceptMapById(id);
|
||||
ourLog.info("Done deleting existing TermConceptMap {} and its children.", id);
|
||||
TermConceptMap existingTermConceptMap = optionalExistingTermConceptMapById.get();
|
||||
|
||||
ourLog.info("Deleting existing TermConceptMap {} and its children...", existingTermConceptMap.getId());
|
||||
for (TermConceptMapGroup group : existingTermConceptMap.getConceptMapGroups()) {
|
||||
|
||||
for (TermConceptMapGroupElement element : group.getConceptMapGroupElements()) {
|
||||
|
||||
for (TermConceptMapGroupElementTarget target : element.getConceptMapGroupElementTargets()) {
|
||||
|
||||
myConceptMapGroupElementTargetDao.deleteTermConceptMapGroupElementTargetById(target.getId());
|
||||
}
|
||||
|
||||
myConceptMapGroupElementDao.deleteTermConceptMapGroupElementById(element.getId());
|
||||
}
|
||||
|
||||
myConceptMapGroupDao.deleteTermConceptMapGroupById(group.getId());
|
||||
}
|
||||
|
||||
myConceptMapDao.deleteTermConceptMapById(existingTermConceptMap.getId());
|
||||
ourLog.info("Done deleting existing TermConceptMap {} and its children.", existingTermConceptMap.getId());
|
||||
|
||||
ourLog.info("Flushing...");
|
||||
myConceptMapGroupElementTargetDao.flush();
|
||||
|
@ -21,11 +21,6 @@ public class SearchBuilderTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAA() {
|
||||
assertTrue(123.00004f <= 123.0001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateMultiplierEqualNoDecimal() {
|
||||
BigDecimal in = new BigDecimal("200");
|
||||
|
@ -14,7 +14,6 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
|
||||
import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
|
||||
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
|
||||
@ -42,7 +41,6 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
import javax.persistence.EntityManager;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@ -181,12 +179,13 @@ public abstract class BaseJpaDstu2Test extends BaseJpaTest {
|
||||
}
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
public void beforeFlushFT() {
|
||||
FullTextEntityManager ftem = Search.getFullTextEntityManager(myEntityManager);
|
||||
ftem.purgeAll(ResourceTable.class);
|
||||
ftem.purgeAll(ResourceIndexedSearchParamString.class);
|
||||
ftem.flushToIndexes();
|
||||
runInTransaction(() -> {
|
||||
FullTextEntityManager ftem = Search.getFullTextEntityManager(myEntityManager);
|
||||
ftem.purgeAll(ResourceTable.class);
|
||||
ftem.purgeAll(ResourceIndexedSearchParamString.class);
|
||||
ftem.flushToIndexes();
|
||||
});
|
||||
|
||||
myDaoConfig.setSchedulingDisabled(true);
|
||||
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);
|
||||
|
@ -319,7 +319,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
||||
myBundleDao.create(bundle, mySrd);
|
||||
fail();
|
||||
} catch (UnprocessableEntityException e) {
|
||||
assertEquals("Unable to store a Bundle resource on this server with a Bundle.type of: (missing)", e.getMessage());
|
||||
assertEquals("Unable to store a Bundle resource on this server with a Bundle.type value of: (missing)", e.getMessage());
|
||||
}
|
||||
|
||||
bundle = new Bundle();
|
||||
@ -329,7 +329,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
||||
myBundleDao.create(bundle, mySrd);
|
||||
fail();
|
||||
} catch (UnprocessableEntityException e) {
|
||||
assertEquals("Unable to store a Bundle resource on this server with a Bundle.type of: batch-response", e.getMessage());
|
||||
assertEquals("Unable to store a Bundle resource on this server with a Bundle.type value of: batch-response", e.getMessage());
|
||||
}
|
||||
|
||||
bundle = new Bundle();
|
||||
@ -2435,6 +2435,8 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
||||
assertThat(actual, contains(id3, id2, id1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSortByQuantity() {
|
||||
Observation res;
|
||||
|
||||
@ -2700,6 +2702,8 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSortByUri() {
|
||||
ConceptMap res = new ConceptMap();
|
||||
res.addElement().addTarget().addDependsOn().setElement("http://foo2");
|
||||
|
@ -274,12 +274,13 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
|
||||
}
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
public void beforeFlushFT() {
|
||||
FullTextEntityManager ftem = Search.getFullTextEntityManager(myEntityManager);
|
||||
ftem.purgeAll(ResourceTable.class);
|
||||
ftem.purgeAll(ResourceIndexedSearchParamString.class);
|
||||
ftem.flushToIndexes();
|
||||
runInTransaction(() -> {
|
||||
FullTextEntityManager ftem = Search.getFullTextEntityManager(myEntityManager);
|
||||
ftem.purgeAll(ResourceTable.class);
|
||||
ftem.purgeAll(ResourceIndexedSearchParamString.class);
|
||||
ftem.flushToIndexes();
|
||||
});
|
||||
|
||||
myDaoConfig.setSchedulingDisabled(true);
|
||||
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);
|
||||
|
@ -63,7 +63,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
|
||||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
@ -106,7 +106,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
|
||||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
@ -143,7 +143,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
|
||||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
@ -707,7 +707,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
|
||||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user