Finally building correctly!

This commit is contained in:
James 2017-07-09 21:32:16 -04:00
parent 6464ce9304
commit bd4e1d3388
35 changed files with 291 additions and 595 deletions

View File

@ -37,12 +37,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId> <artifactId>hapi-fhir-structures-dstu2</artifactId>
@ -230,31 +224,6 @@
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
</execution> </execution>
<!-- dstu jar -->
<execution>
<id>dstu</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedClassifierName>dstu</shadedClassifierName>
<artifactSet>
<includes>
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
</includes>
</artifactSet>
<!-- Exclude server side stuff, except exceptions which are used clientside -->
<!--filters>
<filter>
<artifact>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</artifact>
<excludes>
<exclude>ca/uhn/fhir/rest/server/**</exclude>
</excludes>
</filter>
</filters-->
</configuration>
</execution>
<!-- dstu2 jar --> <!-- dstu2 jar -->
<execution> <execution>
<id>dstu2</id> <id>dstu2</id>

View File

@ -1,14 +1,13 @@
package ca.uhn.fhir.android; package ca.uhn.fhir.android;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import javax.naming.ConfigurationException;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter; import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -18,7 +17,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.composite.QuantityDt; import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
import ca.uhn.fhir.model.dstu2.resource.Observation; import ca.uhn.fhir.model.dstu2.resource.Observation;
import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.rest.client.IGenericClient; import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
public class BuiltJarDstu2IT { public class BuiltJarDstu2IT {

View File

@ -9,14 +9,13 @@ import java.util.zip.ZipFile;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter; import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.composite.QuantityDt; import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
import ca.uhn.fhir.model.dstu2.resource.Observation; import ca.uhn.fhir.model.dstu2.resource.Observation;
import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.rest.client.IGenericClient; import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
public class BuiltJarDstu2ShadeIT { public class BuiltJarDstu2ShadeIT {

View File

@ -1,10 +1,6 @@
package ca.uhn.fhir.android.client; package ca.uhn.fhir.android.client;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -12,14 +8,8 @@ import java.io.IOException;
import java.util.Date; import java.util.Date;
import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ClientProtocolException;
import org.hl7.fhir.dstu3.model.Binary; import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.Bundle; import org.junit.*;
import org.hl7.fhir.dstu3.model.OperationOutcome;
import org.hl7.fhir.dstu3.model.Patient;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
@ -28,12 +18,12 @@ import org.mockito.stubbing.Answer;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.PreferReturnEnum; import ca.uhn.fhir.rest.api.PreferReturnEnum;
import ca.uhn.fhir.rest.client.IGenericClient; import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.ServerValidationModeEnum; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.TestUtil;
import ca.uhn.fhir.util.VersionUtil; import ca.uhn.fhir.util.VersionUtil;
import okhttp3.*; import okhttp3.*;

View File

@ -76,6 +76,11 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId> <artifactId>hapi-fhir-structures-dstu3</artifactId>

View File

@ -35,14 +35,14 @@ public class MultiVersionXmlParserTest {
String str; String str;
str = ourCtxDstu2.newXmlParser().encodeResourceToString(p); str = ourCtxDstu2.newXmlParser().encodeResourceToString(p);
ourLog.info(str); ourLog.info(str);
assertThat(str, Matchers.stringContainsInOrder("<extension url=\"http://foo#ext\"><valueQuantity><value value=\"2.2\"", "<comparator value=\"&lt;\"", "<units value=\"g/L\"", assertThat(str, Matchers.stringContainsInOrder("<extension url=\"http://foo#ext\"><valueQuantity><value value=\"2.2\"", "<comparator value=\"&lt;\"", "<unit value=\"g/L\"",
"</valueQuantity></extension>")); "</valueQuantity></extension>"));
try { try {
FhirContext.forDstu2().newXmlParser().encodeResourceToString(p); FhirContext.forDstu3().newXmlParser().encodeResourceToString(p);
fail(); fail();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertEquals("This parser is for FHIR version DSTU2 - Can not encode a structure for version DSTU1", e.getMessage()); assertEquals("This parser is for FHIR version DSTU3 - Can not encode a structure for version DSTU2", e.getMessage());
} }
} }
@ -61,16 +61,16 @@ public class MultiVersionXmlParserTest {
String res = ourCtxDstu2.newXmlParser().encodeResourceToString(p); String res = ourCtxDstu2.newXmlParser().encodeResourceToString(p);
try { try {
ourCtxDstu2.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Patient.class, res); ourCtxDstu3.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Patient.class, res);
fail(); fail();
} catch (ConfigurationException e) { } catch (ConfigurationException e) {
assertEquals("This context is for FHIR version \"DSTU1\" but the class \"ca.uhn.fhir.model.dstu2.resource.Patient\" is for version \"DSTU2\"", e.getMessage()); assertEquals("This context is for FHIR version \"DSTU3\" but the class \"ca.uhn.fhir.model.dstu2.resource.Patient\" is for version \"DSTU2\"", e.getMessage());
} }
try { try {
ourCtxDstu3.newXmlParser().parseResource(Patient.class, res); ourCtxDstu3.newXmlParser().parseResource(Patient.class, res);
fail(); fail();
} catch (ConfigurationException e) { } catch (ConfigurationException e) {
assertEquals("This context is for FHIR version \"DSTU2\" but the class \"ca.uhn.fhir.model.dstu.resource.Patient\" is for version \"DSTU1\"", e.getMessage()); assertEquals("This context is for FHIR version \"DSTU3\" but the class \"ca.uhn.fhir.model.dstu2.resource.Patient\" is for version \"DSTU2\"", e.getMessage());
} }
} }

View File

@ -11,9 +11,9 @@ import ca.uhn.fhir.model.dstu2.resource.Patient;
public class FhirContextTest { public class FhirContextTest {
@Test @Test
public void testWrongVersionDoesntGetInContext1() { public void testWrongVersionDoesntGetInContext2() {
FhirContext ctx = FhirContext.forDstu1(); FhirContext ctx = FhirContext.forDstu2();
RuntimeResourceDefinition def = ctx.getResourceDefinition("Patient"); RuntimeResourceDefinition def = ctx.getResourceDefinition("Patient");
assertEquals(Patient.class, def.getImplementingClass()); assertEquals(Patient.class, def.getImplementingClass());
} }

View File

@ -5,10 +5,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import org.hl7.fhir.dstu3.model.Patient;
import org.junit.Test; import org.junit.Test;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.validation.FhirValidator; import ca.uhn.fhir.validation.FhirValidator;
public class ValidatorTest { public class ValidatorTest {
@ -16,14 +16,14 @@ public class ValidatorTest {
@Test @Test
public void testValidator() { public void testValidator() {
FhirContext ctx = FhirContext.forDstu1(); FhirContext ctx = FhirContext.forDstu2();
FhirValidator val = ctx.newValidator(); FhirValidator val = ctx.newValidator();
try { try {
val.validateWithResult(new Patient()); val.validateWithResult(new Patient());
fail(); fail();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertEquals("This parser is for FHIR version DSTU1 - Can not encode a structure for version DSTU2", e.getMessage()); assertEquals("This parser is for FHIR version DSTU2 - Can not encode a structure for version DSTU3", e.getMessage());
} }
// Phloc is not onthe classpath // Phloc is not onthe classpath

View File

@ -48,11 +48,6 @@
<classifier>classes</classifier> <classifier>classes</classifier>
</dependency> </dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId> <artifactId>hapi-fhir-structures-dstu2</artifactId>

View File

@ -25,18 +25,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- At least one "structures" JAR must also be included -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>${project.version}</version>
</dependency>
<!-- This dependency includes the JPA server itself, which is packaged separately from the rest of HAPI FHIR --> <!-- This dependency includes the JPA server itself, which is packaged separately from the rest of HAPI FHIR -->
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>

View File

@ -21,11 +21,6 @@
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId> <artifactId>hapi-fhir-structures-dstu2</artifactId>
@ -264,6 +259,8 @@
<directory>${basedir}/..</directory> <directory>${basedir}/..</directory>
<includes> <includes>
<include>hapi-fhir-base/target/jacoco.exec</include> <include>hapi-fhir-base/target/jacoco.exec</include>
<include>hapi-fhir-client/target/jacoco.exec</include>
<include>hapi-fhir-server/target/jacoco.exec</include>
<include>hapi-fhir-structures-dstu/target/jacoco.exec</include> <include>hapi-fhir-structures-dstu/target/jacoco.exec</include>
<include>hapi-fhir-structures-dstu2/target/jacoco.exec</include> <include>hapi-fhir-structures-dstu2/target/jacoco.exec</include>
<include>hapi-fhir-structures-hl7org-dstu2/target/jacoco.exec</include> <include>hapi-fhir-structures-hl7org-dstu2/target/jacoco.exec</include>
@ -287,6 +284,8 @@
<serviceJobId>${env.TRAVIS_JOB_ID}</serviceJobId> <serviceJobId>${env.TRAVIS_JOB_ID}</serviceJobId>
<sourceDirectories> <sourceDirectories>
<sourceDirectory>../hapi-fhir-base/src/main/java</sourceDirectory> <sourceDirectory>../hapi-fhir-base/src/main/java</sourceDirectory>
<sourceDirectory>../hapi-fhir-client/src/main/java</sourceDirectory>
<sourceDirectory>../hapi-fhir-server/src/main/java</sourceDirectory>
<sourceDirectory>../hapi-fhir-structures-dstu/src/test/java</sourceDirectory> <sourceDirectory>../hapi-fhir-structures-dstu/src/test/java</sourceDirectory>
<sourceDirectory>../hapi-fhir-structures-dstu2/src/test/java</sourceDirectory> <sourceDirectory>../hapi-fhir-structures-dstu2/src/test/java</sourceDirectory>
<sourceDirectory>../hapi-fhir-structures-hl7org-dstu2/src/test/java</sourceDirectory> <sourceDirectory>../hapi-fhir-structures-hl7org-dstu2/src/test/java</sourceDirectory>
@ -309,6 +308,8 @@
<configuration> <configuration>
<sources> <sources>
<source>../hapi-fhir-base/src/main/java</source> <source>../hapi-fhir-base/src/main/java</source>
<source>../hapi-fhir-client/src/main/java</source>
<source>../hapi-fhir-server/src/main/java</source>
<source>../hapi-fhir-jpaserver-base/src/main/java</source> <source>../hapi-fhir-jpaserver-base/src/main/java</source>
</sources> </sources>
</configuration> </configuration>

View File

@ -64,11 +64,6 @@
<artifactId>hapi-fhir-server</artifactId> <artifactId>hapi-fhir-server</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId> <artifactId>hapi-fhir-structures-dstu2</artifactId>
@ -563,11 +558,6 @@
</execution> </execution>
</executions> </executions>
<dependencies> <dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId> <artifactId>hapi-fhir-structures-dstu2</artifactId>

View File

@ -1,6 +1,5 @@
package ca.uhn.fhir.jpa.dao; package ca.uhn.fhir.jpa.dao;
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
/* /*
* #%L * #%L
* HAPI FHIR JPA Server * HAPI FHIR JPA Server
@ -20,9 +19,7 @@ import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
* limitations under the License. * limitations under the License.
* #L% * #L%
*/ */
import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.commons.lang3.StringUtils.trim;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.Normalizer; import java.text.Normalizer;
@ -37,9 +34,8 @@ import javax.xml.stream.events.XMLEvent;
import org.apache.commons.lang3.*; import org.apache.commons.lang3.*;
import org.apache.http.NameValuePair; import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.client.utils.URLEncodedUtils;
import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb; import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb;
import org.hl7.fhir.dstu3.model.IdType;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.instance.model.api.*; import org.hl7.fhir.instance.model.api.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
@ -61,17 +57,16 @@ import ca.uhn.fhir.jpa.util.DeleteConflict;
import ca.uhn.fhir.model.api.*; import ca.uhn.fhir.model.api.*;
import ca.uhn.fhir.model.base.composite.BaseCodingDt; import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt; import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
import ca.uhn.fhir.model.dstu.resource.BaseResource;
import ca.uhn.fhir.model.primitive.*; import ca.uhn.fhir.model.primitive.*;
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum; import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
import ca.uhn.fhir.parser.*; import ca.uhn.fhir.parser.*;
import ca.uhn.fhir.rest.api.*; import ca.uhn.fhir.rest.api.*;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.param.*; import ca.uhn.fhir.rest.param.*;
import ca.uhn.fhir.rest.server.exceptions.*; import ca.uhn.fhir.rest.server.exceptions.*;
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
import ca.uhn.fhir.rest.server.method.MethodUtil;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.util.*; import ca.uhn.fhir.util.*;

View File

@ -36,6 +36,7 @@ import org.hibernate.search.jpa.FullTextEntityManager;
import org.hibernate.search.jpa.FullTextQuery; import org.hibernate.search.jpa.FullTextQuery;
import org.hibernate.search.query.dsl.BooleanJunction; import org.hibernate.search.query.dsl.BooleanJunction;
import org.hibernate.search.query.dsl.QueryBuilder; import org.hibernate.search.query.dsl.QueryBuilder;
import org.hl7.fhir.dstu3.model.BaseResource;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -44,7 +45,6 @@ import com.google.common.collect.Sets;
import ca.uhn.fhir.jpa.entity.ResourceTable; import ca.uhn.fhir.jpa.entity.ResourceTable;
import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.dstu.resource.BaseResource;
import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;

View File

@ -38,6 +38,7 @@ import org.apache.commons.lang3.tuple.Pair;
import org.hibernate.ScrollMode; import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults; import org.hibernate.ScrollableResults;
import org.hibernate.query.Query; import org.hibernate.query.Query;
import org.hl7.fhir.dstu3.model.BaseResource;
import org.hl7.fhir.instance.model.api.*; import org.hl7.fhir.instance.model.api.*;
import com.google.common.collect.*; import com.google.common.collect.*;
@ -51,7 +52,6 @@ import ca.uhn.fhir.jpa.term.VersionIndependentConcept;
import ca.uhn.fhir.jpa.util.StopWatch; import ca.uhn.fhir.jpa.util.StopWatch;
import ca.uhn.fhir.model.api.*; import ca.uhn.fhir.model.api.*;
import ca.uhn.fhir.model.base.composite.*; import ca.uhn.fhir.model.base.composite.*;
import ca.uhn.fhir.model.dstu.resource.BaseResource;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.InstantDt; import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum; import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;

View File

@ -22,7 +22,6 @@ import ca.uhn.fhir.jpa.dao.data.ISearchParamPresentDao;
import ca.uhn.fhir.jpa.entity.*; import ca.uhn.fhir.jpa.entity.*;
import ca.uhn.fhir.model.api.*; import ca.uhn.fhir.model.api.*;
import ca.uhn.fhir.model.base.composite.BaseCodingDt; import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.model.dstu.resource.BaseResource;
import ca.uhn.fhir.model.dstu2.composite.*; import ca.uhn.fhir.model.dstu2.composite.*;
import ca.uhn.fhir.model.dstu2.resource.*; import ca.uhn.fhir.model.dstu2.resource.*;
import ca.uhn.fhir.model.dstu2.valueset.*; import ca.uhn.fhir.model.dstu2.valueset.*;

View File

@ -351,13 +351,13 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
* be fixed. * be fixed.
*/ */
assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR); assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR);
assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.ERROR.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR); assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR);
assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.ERROR.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR); assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.ERROR.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR);
assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO); assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO);
assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.INFORMATION.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO); assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO);
assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.INFORMATION.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO); assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.INFORMATION.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO);
assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.WARNING.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_WARN); assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.WARNING.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_WARN);
assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.WARNING.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_WARN); assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.WARNING.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_WARN);
assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.WARNING.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_WARN); assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.WARNING.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_WARN);
} }

View File

@ -503,27 +503,6 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
obs = myObservationDao.read(obsId.toUnqualifiedVersionless(), mySrd); obs = myObservationDao.read(obsId.toUnqualifiedVersionless(), mySrd);
} }
@Test
public void testCreateDuplicateIdFails() {
String methodName = "testCreateDuplocateIdFailsText";
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.setId("Patient/" + methodName);
IIdType id = myPatientDao.create(p, mySrd).getId();
ourLog.info("Created patient, got it: {}", id);
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
try {
myPatientDao.create(p, mySrd);
fail();
} catch (UnprocessableEntityException e) {
assertThat(e.getMessage(), containsString("Can not create entity with ID[" + methodName + "], a resource with this ID already exists"));
}
}
@Test @Test
public void testCreateDuplicateTagsDoesNotCauseDuplicates() { public void testCreateDuplicateTagsDoesNotCauseDuplicates() {
@ -608,9 +587,9 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
Patient p = new Patient(); Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testCreateNumericIdFails"); p.addIdentifier().setSystem("urn:system").setValue("testCreateNumericIdFails");
p.addName().setFamily("Hello"); p.addName().setFamily("Hello");
p.setId("Patient/123"); p.setId("Patient/9999999999999");
try { try {
myPatientDao.create(p, mySrd); myPatientDao.update(p, mySrd);
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertThat(e.getMessage(), containsString("clients may only assign IDs which contain at least one non-numeric")); assertThat(e.getMessage(), containsString("clients may only assign IDs which contain at least one non-numeric"));
@ -624,13 +603,13 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
* be fixed. * be fixed.
*/ */
assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirDao.OO_SEVERITY_ERROR); assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirDao.OO_SEVERITY_ERROR);
assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.ERROR.getCode(), BaseHapiFhirDao.OO_SEVERITY_ERROR); assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR);
assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirDao.OO_SEVERITY_ERROR); assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirDao.OO_SEVERITY_ERROR);
assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirDao.OO_SEVERITY_INFO); assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirDao.OO_SEVERITY_INFO);
assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.INFORMATION.getCode(), BaseHapiFhirDao.OO_SEVERITY_INFO); assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO);
assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirDao.OO_SEVERITY_INFO); assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirDao.OO_SEVERITY_INFO);
assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.WARNING.toCode(), BaseHapiFhirDao.OO_SEVERITY_WARN); assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.WARNING.toCode(), BaseHapiFhirDao.OO_SEVERITY_WARN);
assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.WARNING.getCode(), BaseHapiFhirDao.OO_SEVERITY_WARN); assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.WARNING.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_WARN);
assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.WARNING.toCode(), BaseHapiFhirDao.OO_SEVERITY_WARN); assertEquals(org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity.WARNING.toCode(), BaseHapiFhirDao.OO_SEVERITY_WARN);
} }
@ -3563,7 +3542,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
p1.addIdentifier().setSystem("urn:system").setValue("testUpdateRejectsIdWhichPointsToForcedId01"); p1.addIdentifier().setSystem("urn:system").setValue("testUpdateRejectsIdWhichPointsToForcedId01");
p1.addName().setFamily("Tester").addGiven("testUpdateRejectsIdWhichPointsToForcedId01"); p1.addName().setFamily("Tester").addGiven("testUpdateRejectsIdWhichPointsToForcedId01");
p1.setId("ABABA"); p1.setId("ABABA");
IIdType p1id = myPatientDao.create(p1, mySrd).getId(); IIdType p1id = myPatientDao.update(p1, mySrd).getId();
assertEquals("ABABA", p1id.getIdPart()); assertEquals("ABABA", p1id.getIdPart());
Patient p2 = new Patient(); Patient p2 = new Patient();

View File

@ -25,11 +25,6 @@
<artifactId>hapi-fhir-jpaserver-base</artifactId> <artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId> <artifactId>hapi-fhir-structures-dstu2</artifactId>

View File

@ -1,26 +0,0 @@
package ca.uhn.fhirtest;
import ca.uhn.fhir.model.dstu.resource.Profile;
import ca.uhn.fhir.model.dstu.resource.Profile.ExtensionDefn;
import ca.uhn.fhir.model.dstu.valueset.DataTypeEnum;
import ca.uhn.fhir.model.dstu.valueset.ExtensionContextEnum;
public class PopulateProfiles {
public static void main(String[] args) {
Profile hapiExtensions = new Profile();
ExtensionDefn ext = hapiExtensions.addExtensionDefn();
ext.addContext("Conformance.rest.resource");
ext.getCode().setValue("resourceCount");
ext.getContextType().setValueAsEnum(ExtensionContextEnum.RESOURCE);
ext.getDisplay().setValue("Resource count on server");
ext.getDefinition().addType().setCode(DataTypeEnum.DECIMAL);
}
}

View File

@ -138,37 +138,36 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
Set<SummaryEnum> summaryMode = RestfulServerUtils.determineSummaryMode(theRequest); Set<SummaryEnum> summaryMode = RestfulServerUtils.determineSummaryMode(theRequest);
for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) { for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
IServerInterceptor next = theServer.getInterceptors().get(i); IServerInterceptor next = theServer.getInterceptors().get(i);
boolean continueProcessing = next.outgoingResponse(theRequest, response); boolean continueProcessing = next.outgoingResponse(theRequest, response);
if (!continueProcessing) { if (!continueProcessing) {
return null; return null;
}
} }
}
boolean prettyPrint = RestfulServerUtils.prettyPrintResponse(theServer, theRequest); boolean prettyPrint = RestfulServerUtils.prettyPrintResponse(theServer, theRequest);
return theRequest.getResponse().streamResponseAsResource(response, prettyPrint, summaryMode, Constants.STATUS_HTTP_200_OK, null, theRequest.isRespondGzip(), isAddContentLocationHeader());
return theRequest.getResponse().streamResponseAsResource(response, prettyPrint, summaryMode, Constants.STATUS_HTTP_200_OK, null, theRequest.isRespondGzip(), isAddContentLocationHeader());
// DSTU1 Bundle // DSTU1 Bundle
// // Is this request coming from a browser // // Is this request coming from a browser
// String uaHeader = theRequest.getHeader("user-agent"); // String uaHeader = theRequest.getHeader("user-agent");
// boolean requestIsBrowser = false; // boolean requestIsBrowser = false;
// if (uaHeader != null && uaHeader.contains("Mozilla")) { // if (uaHeader != null && uaHeader.contains("Mozilla")) {
// requestIsBrowser = true; // requestIsBrowser = true;
// } // }
// //
// for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) { // for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
// IServerInterceptor next = theServer.getInterceptors().get(i); // IServerInterceptor next = theServer.getInterceptors().get(i);
// boolean continueProcessing = next.outgoingResponse(theRequest, responseObject.getDstu1Bundle()); // boolean continueProcessing = next.outgoingResponse(theRequest, responseObject.getDstu1Bundle());
// if (!continueProcessing) { // if (!continueProcessing) {
// ourLog.debug("Interceptor {} returned false, not continuing processing"); // ourLog.debug("Interceptor {} returned false, not continuing processing");
// return null; // return null;
// } // }
// } // }
// //
// return theRequest.getResponse().streamResponseAsBundle(responseObject.getDstu1Bundle(), summaryMode, theRequest.isRespondGzip(), requestIsBrowser); // return theRequest.getResponse().streamResponseAsBundle(responseObject.getDstu1Bundle(), summaryMode, theRequest.isRespondGzip(), requestIsBrowser);
} }
public IBaseResource doInvokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) { public IBaseResource doInvokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) {
@ -188,195 +187,188 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
final IBaseResource responseObject; final IBaseResource responseObject;
switch (getReturnType()) { switch (getReturnType()) {
case BUNDLE: { case BUNDLE: {
/*
* Figure out the self-link for this request
*/
String serverBase = theRequest.getServerBaseForRequest();
String linkSelf;
StringBuilder b = new StringBuilder();
b.append(serverBase);
if (isNotBlank(theRequest.getRequestPath())) {
b.append('/');
b.append(theRequest.getRequestPath());
}
// For POST the URL parameters get jumbled with the post body parameters so don't include them, they might be huge
if (theRequest.getRequestType() == RequestTypeEnum.GET) {
boolean first = true;
Map<String, String[]> parameters = theRequest.getParameters();
for (String nextParamName : new TreeSet<String>(parameters.keySet())) {
for (String nextParamValue : parameters.get(nextParamName)) {
if (first) {
b.append('?');
first = false;
} else {
b.append('&');
}
b.append(UrlUtil.escape(nextParamName));
b.append('=');
b.append(UrlUtil.escape(nextParamValue));
}
}
}
linkSelf = b.toString();
if (getMethodReturnType() == MethodReturnTypeEnum.BUNDLE_RESOURCE) {
IBaseResource resource;
IPrimitiveType<Date> lastUpdated;
if (resultObj instanceof IBundleProvider) {
IBundleProvider result = (IBundleProvider) resultObj;
resource = result.getResources(0, 1).get(0);
lastUpdated = result.getPublished();
} else {
resource = (IBaseResource) resultObj;
lastUpdated = theServer.getFhirContext().getVersion().getLastUpdated(resource);
}
/* /*
* Figure out the self-link for this request * We assume that the bundle we got back from the handling method may not have everything populated (e.g. self links, bundle type, etc) so we do that here.
*/ */
String serverBase = theRequest.getServerBaseForRequest(); IVersionSpecificBundleFactory bundleFactory = theServer.getFhirContext().newBundleFactory();
String linkSelf; bundleFactory.initializeWithBundleResource(resource);
StringBuilder b = new StringBuilder(); bundleFactory.addRootPropertiesToBundle(null, theRequest.getFhirServerBase(), linkSelf, null, null, count, getResponseBundleType(), lastUpdated);
b.append(serverBase);
if (isNotBlank(theRequest.getRequestPath())) {
b.append('/');
b.append(theRequest.getRequestPath());
}
// For POST the URL parameters get jumbled with the post body parameters so don't include them, they might be huge
if (theRequest.getRequestType() == RequestTypeEnum.GET) {
boolean first = true;
Map<String, String[]> parameters = theRequest.getParameters();
for (String nextParamName : new TreeSet<String>(parameters.keySet())) {
for (String nextParamValue : parameters.get(nextParamName)) {
if (first) {
b.append('?');
first = false;
} else {
b.append('&');
}
b.append(UrlUtil.escape(nextParamName));
b.append('=');
b.append(UrlUtil.escape(nextParamValue));
}
}
}
linkSelf = b.toString();
if (getMethodReturnType() == MethodReturnTypeEnum.BUNDLE_RESOURCE) {
IBaseResource resource;
IPrimitiveType<Date> lastUpdated;
if (resultObj instanceof IBundleProvider) {
IBundleProvider result = (IBundleProvider) resultObj;
resource = result.getResources(0, 1).get(0);
lastUpdated = result.getPublished();
} else {
resource = (IBaseResource) resultObj;
lastUpdated = theServer.getFhirContext().getVersion().getLastUpdated(resource);
}
/*
* We assume that the bundle we got back from the handling method may not have everything populated (e.g. self links, bundle type, etc) so we do that here.
*/
IVersionSpecificBundleFactory bundleFactory = theServer.getFhirContext().newBundleFactory();
bundleFactory.initializeWithBundleResource(resource);
bundleFactory.addRootPropertiesToBundle(null, theRequest.getFhirServerBase(), linkSelf, null, null, count, getResponseBundleType(), lastUpdated);
responseObject = resource;
} else {
Set<Include> includes = getRequestIncludesFromParams(params);
IBundleProvider result = (IBundleProvider) resultObj;
if (count == null) {
count = result.preferredPageSize();
}
Integer offsetI = RestfulServerUtils.tryToExtractNamedParameter(theRequest, Constants.PARAM_PAGINGOFFSET);
if (offsetI == null || offsetI < 0) {
offsetI = 0;
}
Integer resultSize = result.size();
int start;
if (resultSize != null) {
start = Math.max(0, Math.min(offsetI, resultSize - 1));
} else {
start = offsetI;
}
ResponseEncoding responseEncoding = RestfulServerUtils.determineResponseEncodingNoDefault(theRequest, theServer.getDefaultResponseEncoding());
EncodingEnum linkEncoding = theRequest.getParameters().containsKey(Constants.PARAM_FORMAT) && responseEncoding != null ? responseEncoding.getEncoding() : null;
responseObject = createBundleFromBundleProvider(theServer, theRequest, count, linkSelf, includes, result, start, getResponseBundleType(), linkEncoding, null);
}
break;
}
case RESOURCE: {
IBundleProvider result = (IBundleProvider) resultObj;
if (result.size() == 0) {
throw new ResourceNotFoundException(theRequest.getId());
} else if (result.size() > 1) {
throw new InternalErrorException("Method returned multiple resources");
}
IBaseResource resource = result.getResources(0, 1).get(0);
responseObject = resource; responseObject = resource;
break; } else {
Set<Include> includes = getRequestIncludesFromParams(params);
IBundleProvider result = (IBundleProvider) resultObj;
if (count == null) {
count = result.preferredPageSize();
}
Integer offsetI = RestfulServerUtils.tryToExtractNamedParameter(theRequest, Constants.PARAM_PAGINGOFFSET);
if (offsetI == null || offsetI < 0) {
offsetI = 0;
}
Integer resultSize = result.size();
int start;
if (resultSize != null) {
start = Math.max(0, Math.min(offsetI, resultSize - 1));
} else {
start = offsetI;
}
ResponseEncoding responseEncoding = RestfulServerUtils.determineResponseEncodingNoDefault(theRequest, theServer.getDefaultResponseEncoding());
EncodingEnum linkEncoding = theRequest.getParameters().containsKey(Constants.PARAM_FORMAT) && responseEncoding != null ? responseEncoding.getEncoding() : null;
responseObject = createBundleFromBundleProvider(theServer, theRequest, count, linkSelf, includes, result, start, getResponseBundleType(), linkEncoding, null);
} }
default: break;
throw new IllegalStateException(); // should not happen }
case RESOURCE: {
IBundleProvider result = (IBundleProvider) resultObj;
if (result.size() == 0) {
throw new ResourceNotFoundException(theRequest.getId());
} else if (result.size() > 1) {
throw new InternalErrorException("Method returned multiple resources");
}
IBaseResource resource = result.getResources(0, 1).get(0);
responseObject = resource;
break;
}
default:
throw new IllegalStateException(); // should not happen
} }
return responseObject; return responseObject;
} }
protected IBaseResource createBundleFromBundleProvider(IRestfulServer<?> theServer, RequestDetails theRequest, Integer theLimit, String theLinkSelf, Set<Include> theIncludes, IBundleProvider theResult, int theOffset, BundleTypeEnum theBundleType, EncodingEnum theLinkEncoding, String theSearchId) { protected IBaseResource createBundleFromBundleProvider(IRestfulServer<?> theServer, RequestDetails theRequest, Integer theLimit, String theLinkSelf, Set<Include> theIncludes,
IBundleProvider theResult, int theOffset, BundleTypeEnum theBundleType, EncodingEnum theLinkEncoding, String theSearchId) {
IVersionSpecificBundleFactory bundleFactory = theServer.getFhirContext().newBundleFactory(); IVersionSpecificBundleFactory bundleFactory = theServer.getFhirContext().newBundleFactory();
int numToReturn; int numToReturn;
String searchId = null; String searchId = null;
List<IBaseResource> resourceList; List<IBaseResource> resourceList;
Integer numTotalResults = theResult.size(); Integer numTotalResults = theResult.size();
if (theServer.getPagingProvider() == null) { if (theServer.getPagingProvider() == null) {
numToReturn = numTotalResults; numToReturn = numTotalResults;
if (numToReturn > 0) { if (numToReturn > 0) {
resourceList = theResult.getResources(0, numToReturn); resourceList = theResult.getResources(0, numToReturn);
} else { } else {
resourceList = Collections.emptyList(); resourceList = Collections.emptyList();
} }
RestfulServerUtils.validateResourceListNotNull(resourceList); RestfulServerUtils.validateResourceListNotNull(resourceList);
} else { } else {
IPagingProvider pagingProvider = theServer.getPagingProvider(); IPagingProvider pagingProvider = theServer.getPagingProvider();
if (theLimit == null || theLimit.equals(Integer.valueOf(0))) { if (theLimit == null || theLimit.equals(Integer.valueOf(0))) {
numToReturn = pagingProvider.getDefaultPageSize(); numToReturn = pagingProvider.getDefaultPageSize();
} else { } else {
numToReturn = Math.min(pagingProvider.getMaximumPageSize(), theLimit); numToReturn = Math.min(pagingProvider.getMaximumPageSize(), theLimit);
} }
if (numTotalResults != null) { if (numTotalResults != null) {
numToReturn = Math.min(numToReturn, numTotalResults - theOffset); numToReturn = Math.min(numToReturn, numTotalResults - theOffset);
} }
if (numToReturn > 0) { if (numToReturn > 0) {
resourceList = theResult.getResources(theOffset, numToReturn + theOffset); resourceList = theResult.getResources(theOffset, numToReturn + theOffset);
} else { } else {
resourceList = Collections.emptyList(); resourceList = Collections.emptyList();
} }
RestfulServerUtils.validateResourceListNotNull(resourceList); RestfulServerUtils.validateResourceListNotNull(resourceList);
if (theSearchId != null) { if (theSearchId != null) {
searchId = theSearchId; searchId = theSearchId;
} else { } else {
if (numTotalResults == null || numTotalResults > numToReturn) { if (numTotalResults == null || numTotalResults > numToReturn) {
searchId = pagingProvider.storeResultList(theResult); searchId = pagingProvider.storeResultList(theResult);
if (isBlank(searchId)) { if (isBlank(searchId)) {
ourLog.info("Found {} results but paging provider did not provide an ID to use for paging", numTotalResults); ourLog.info("Found {} results but paging provider did not provide an ID to use for paging", numTotalResults);
} }
} }
} }
} }
for (IBaseResource next : resourceList) { for (IBaseResource next : resourceList) {
if (next.getIdElement() == null || next.getIdElement().isEmpty()) { if (next.getIdElement() == null || next.getIdElement().isEmpty()) {
if (!(next instanceof BaseOperationOutcome)) { if (!(next instanceof BaseOperationOutcome)) {
throw new InternalErrorException("Server method returned resource of type[" + next.getClass().getSimpleName() + "] with no ID specified (IResource#setId(IdDt) must be called)"); throw new InternalErrorException("Server method returned resource of type[" + next.getClass().getSimpleName() + "] with no ID specified (IResource#setId(IdDt) must be called)");
} }
} }
} }
String serverBase = theRequest.getFhirServerBase(); String serverBase = theRequest.getFhirServerBase();
boolean prettyPrint = RestfulServerUtils.prettyPrintResponse(theServer, theRequest); boolean prettyPrint = RestfulServerUtils.prettyPrintResponse(theServer, theRequest);
String linkPrev= null; String linkPrev = null;
String linkNext = null; String linkNext = null;
if (searchId != null) { if (searchId != null) {
if (numTotalResults == null || theOffset + numToReturn < numTotalResults) { if (numTotalResults == null || theOffset + numToReturn < numTotalResults) {
linkNext = (RestfulServerUtils.createPagingLink(theIncludes, serverBase, searchId, theOffset + numToReturn, numToReturn, theLinkEncoding, prettyPrint, theBundleType)); linkNext = (RestfulServerUtils.createPagingLink(theIncludes, serverBase, searchId, theOffset + numToReturn, numToReturn, theLinkEncoding, prettyPrint, theBundleType));
} }
if (theOffset > 0) { if (theOffset > 0) {
int start = Math.max(0, theOffset - theLimit); int start = Math.max(0, theOffset - theLimit);
linkPrev = RestfulServerUtils.createPagingLink(theIncludes, serverBase, searchId, start, theLimit, theLinkEncoding, prettyPrint, theBundleType); linkPrev = RestfulServerUtils.createPagingLink(theIncludes, serverBase, searchId, start, theLimit, theLinkEncoding, prettyPrint, theBundleType);
} }
} }
bundleFactory.addRootPropertiesToBundle(null, serverBase, theLinkSelf, linkPrev, linkNext, theResult.size(), theBundleType, theResult.getPublished());
bundleFactory.addResourcesToBundle(new ArrayList<IBaseResource>(resourceList), theBundleType, serverBase, theServer.getBundleInclusionRule(), theIncludes);
if (theServer.getPagingProvider() != null) {
int limit;
limit = theLimit != null ? theLimit : theServer.getPagingProvider().getDefaultPageSize();
limit = Math.min(limit, theServer.getPagingProvider().getMaximumPageSize());
bundleFactory.addRootPropertiesToBundle(null, serverBase, theLinkSelf, linkPrev, linkNext, theResult.size(), theBundleType, theResult.getPublished()); }
bundleFactory.addResourcesToBundle(new ArrayList<IBaseResource>(resourceList), theBundleType, serverBase, theServer.getBundleInclusionRule(), theIncludes);
if (theServer.getPagingProvider() != null) {
int limit;
limit = theLimit != null ? theLimit : theServer.getPagingProvider().getDefaultPageSize();
limit = Math.min(limit, theServer.getPagingProvider().getMaximumPageSize());
}
return bundleFactory.getResourceBundle(); return bundleFactory.getResourceBundle();
} }
public abstract Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException; public abstract Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException;
@ -393,12 +385,17 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
} }
public enum MethodReturnTypeEnum { public enum MethodReturnTypeEnum {
BUNDLE, BUNDLE_PROVIDER, BUNDLE_RESOURCE, LIST_OF_RESOURCES, METHOD_OUTCOME, RESOURCE BUNDLE,
BUNDLE_PROVIDER,
BUNDLE_RESOURCE,
LIST_OF_RESOURCES,
METHOD_OUTCOME,
RESOURCE
} }
public enum ReturnTypeEnum { public enum ReturnTypeEnum {
BUNDLE, RESOURCE BUNDLE,
RESOURCE
} }
} }

View File

@ -72,6 +72,11 @@ public class PatchMethodBinding extends BaseOutcomeReturningMethodBindingWithRes
} }
} }
@Override
protected boolean allowVoidReturnType() {
return true;
}
@Override @Override
public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) { public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) {
boolean retVal = super.incomingServerRequestMatchesMethod(theRequest); boolean retVal = super.incomingServerRequestMatchesMethod(theRequest);

View File

@ -108,6 +108,23 @@ public class ServletRequestDetails extends RequestDetails {
} }
} }
@Override
public Charset getCharset() {
Charset charset = null;
String charsetString = myServletRequest.getCharacterEncoding();
if (isNotBlank(charsetString)) {
charset = Charset.forName(charsetString);
}
return charset;
}
@Override
public FhirContext getFhirContext() {
return getServer().getFhirContext();
}
@Override @Override
public String getHeader(String name) { public String getHeader(String name) {
return getServletRequest().getHeader(name); return getServletRequest().getHeader(name);
@ -159,28 +176,4 @@ public class ServletRequestDetails extends RequestDetails {
this.myServletResponse = myServletResponse; this.myServletResponse = myServletResponse;
} }
@Override
public Charset getCharset() {
Charset charset = null;
String charsetString = myServletResponse.getCharacterEncoding();
if (isNotBlank(charsetString)) {
charset = Charset.forName(charsetString);
}
// String ct = getHeader(Constants.HEADER_CONTENT_TYPE);
//
// if (isNotBlank(ct)) {
// ContentType parsedCt = ContentType.parse(ct);
// charset = parsedCt.getCharset();
// }
return charset;
}
@Override
public FhirContext getFhirContext() {
return getServer().getFhirContext();
}
} }

View File

@ -221,10 +221,14 @@
<classFolders> <classFolders>
<classFolder>${basedir}/target/classes</classFolder> <classFolder>${basedir}/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-base/target/classes</classFolder> <classFolder>${basedir}/../hapi-fhir-base/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-client/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-server/target/classes</classFolder>
</classFolders> </classFolders>
<sourceFolders> <sourceFolders>
<sourceFolder>${basedir}/src/main/java</sourceFolder> <sourceFolder>${basedir}/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-base/src/main/java</sourceFolder> <sourceFolder>${basedir}/../hapi-fhir-base/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-client/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-server/src/main/java</sourceFolder>
</sourceFolders> </sourceFolders>
<dumpOnExit>true</dumpOnExit> <dumpOnExit>true</dumpOnExit>
</configuration> </configuration>

View File

@ -185,10 +185,14 @@
<classFolders> <classFolders>
<classFolder>${basedir}/target/classes</classFolder> <classFolder>${basedir}/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-base/target/classes</classFolder> <classFolder>${basedir}/../hapi-fhir-base/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-client/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-server/target/classes</classFolder>
</classFolders> </classFolders>
<sourceFolders> <sourceFolders>
<sourceFolder>${basedir}/src/main/java</sourceFolder> <sourceFolder>${basedir}/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-base/src/main/java</sourceFolder> <sourceFolder>${basedir}/../hapi-fhir-base/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-client/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-server/src/main/java</sourceFolder>
</sourceFolders> </sourceFolders>
<dumpOnExit>true</dumpOnExit> <dumpOnExit>true</dumpOnExit>
</configuration> </configuration>

View File

@ -213,10 +213,14 @@
<classFolders> <classFolders>
<classFolder>${basedir}/target/classes</classFolder> <classFolder>${basedir}/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-base/target/classes</classFolder> <classFolder>${basedir}/../hapi-fhir-base/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-client/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-server/target/classes</classFolder>
</classFolders> </classFolders>
<sourceFolders> <sourceFolders>
<sourceFolder>${basedir}/src/main/java</sourceFolder> <sourceFolder>${basedir}/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-base/src/main/java</sourceFolder> <sourceFolder>${basedir}/../hapi-fhir-base/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-client/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-server/src/main/java</sourceFolder>
</sourceFolders> </sourceFolders>
<dumpOnExit>true</dumpOnExit> <dumpOnExit>true</dumpOnExit>
</configuration> </configuration>

View File

@ -220,10 +220,14 @@
<classFolders> <classFolders>
<classFolder>${basedir}/target/classes</classFolder> <classFolder>${basedir}/target/classes</classFolder>
<classFolder>${basedir}../hapi-fhir-base/target/classes</classFolder> <classFolder>${basedir}../hapi-fhir-base/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-client/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-server/target/classes</classFolder>
</classFolders> </classFolders>
<sourceFolders> <sourceFolders>
<sourceFolder>${basedir}/src/main/java</sourceFolder> <sourceFolder>${basedir}/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-base/src/main/java</sourceFolder> <sourceFolder>${basedir}/../hapi-fhir-base/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-client/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-server/src/main/java</sourceFolder>
</sourceFolders> </sourceFolders>
<dumpOnExit>true</dumpOnExit> <dumpOnExit>true</dumpOnExit>
</configuration> </configuration>

View File

@ -36,14 +36,14 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId> <artifactId>hapi-fhir-server</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId> <artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>

View File

@ -29,8 +29,6 @@ import ca.uhn.fhir.context.*;
import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.ExtensionDt; import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Conformance.Rest;
import ca.uhn.fhir.model.primitive.DecimalDt; import ca.uhn.fhir.model.primitive.DecimalDt;
import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.EncodingEnum;
@ -295,8 +293,6 @@ public class BaseController {
private IBaseResource loadAndAddConf(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) { private IBaseResource loadAndAddConf(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
switch (theRequest.getFhirVersion(myConfig)) { switch (theRequest.getFhirVersion(myConfig)) {
case DSTU1:
return loadAndAddConfDstu1(theServletRequest, theRequest, theModel);
case DSTU2: case DSTU2:
return loadAndAddConfDstu2(theServletRequest, theRequest, theModel); return loadAndAddConfDstu2(theServletRequest, theRequest, theModel);
case DSTU3: case DSTU3:
@ -308,65 +304,6 @@ public class BaseController {
throw new IllegalStateException("Unknown version: " + theRequest.getFhirVersion(myConfig)); throw new IllegalStateException("Unknown version: " + theRequest.getFhirVersion(myConfig));
} }
private Conformance loadAndAddConfDstu1(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
CaptureInterceptor interceptor = new CaptureInterceptor();
GenericClient client = theRequest.newClient(theServletRequest, getContext(theRequest), myConfig, interceptor);
Conformance conformance;
try {
conformance = (Conformance) client.conformance();
} catch (Exception e) {
ourLog.warn("Failed to load conformance statement", e);
theModel.put("errorMsg", "Failed to load conformance statement, error was: " + e.toString());
conformance = new Conformance();
}
theModel.put("jsonEncodedConf", getContext(theRequest).newJsonParser().encodeResourceToString(conformance));
Map<String, Number> resourceCounts = new HashMap<String, Number>();
long total = 0;
for (Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dstu.resource.Conformance.RestResource nextResource : nextRest.getResource()) {
List<ExtensionDt> exts = nextResource.getUndeclaredExtensionsByUrl(RESOURCE_COUNT_EXT_URL);
if (exts != null && exts.size() > 0) {
Number nextCount = ((DecimalDt) (exts.get(0).getValue())).getValueAsNumber();
resourceCounts.put(nextResource.getType().getValue(), nextCount);
total += nextCount.longValue();
}
}
}
theModel.put("resourceCounts", resourceCounts);
if (total > 0) {
for (Rest nextRest : conformance.getRest()) {
Collections.sort(nextRest.getResource(), new Comparator<ca.uhn.fhir.model.dstu.resource.Conformance.RestResource>() {
@Override
public int compare(ca.uhn.fhir.model.dstu.resource.Conformance.RestResource theO1, ca.uhn.fhir.model.dstu.resource.Conformance.RestResource theO2) {
DecimalDt count1 = new DecimalDt();
List<ExtensionDt> count1exts = theO1.getUndeclaredExtensionsByUrl(RESOURCE_COUNT_EXT_URL);
if (count1exts != null && count1exts.size() > 0) {
count1 = (DecimalDt) count1exts.get(0).getValue();
}
DecimalDt count2 = new DecimalDt();
List<ExtensionDt> count2exts = theO2.getUndeclaredExtensionsByUrl(RESOURCE_COUNT_EXT_URL);
if (count2exts != null && count2exts.size() > 0) {
count2 = (DecimalDt) count2exts.get(0).getValue();
}
int retVal = count2.compareTo(count1);
if (retVal == 0) {
retVal = theO1.getType().getValue().compareTo(theO2.getType().getValue());
}
return retVal;
}
});
}
}
theModel.put("conf", conformance);
theModel.put("requiredParamExtension", ExtensionConstants.PARAM_IS_REQUIRED);
return conformance;
}
private IResource loadAndAddConfDstu2(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) { private IResource loadAndAddConfDstu2(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
CaptureInterceptor interceptor = new CaptureInterceptor(); CaptureInterceptor interceptor = new CaptureInterceptor();

View File

@ -21,11 +21,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import ca.uhn.fhir.context.*; import ca.uhn.fhir.context.*;
import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.dstu.resource.Conformance; import ca.uhn.fhir.model.dstu2.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Conformance.*;
import ca.uhn.fhir.model.dstu.valueset.SearchParamTypeEnum;
import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum; import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
import ca.uhn.fhir.model.primitive.*; import ca.uhn.fhir.model.primitive.*;
import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.parser.DataFormatException;
@ -36,7 +33,6 @@ import ca.uhn.fhir.rest.gclient.*;
import ca.uhn.fhir.rest.gclient.NumberClientParam.IMatches; import ca.uhn.fhir.rest.gclient.NumberClientParam.IMatches;
import ca.uhn.fhir.rest.gclient.QuantityClientParam.IAndUnits; import ca.uhn.fhir.rest.gclient.QuantityClientParam.IAndUnits;
import ca.uhn.fhir.to.model.*; import ca.uhn.fhir.to.model.*;
import ca.uhn.fhir.util.ExtensionConstants;
@org.springframework.stereotype.Controller() @org.springframework.stereotype.Controller()
public class Controller extends BaseController { public class Controller extends BaseController {
@ -309,19 +305,15 @@ public class Controller extends BaseController {
TreeSet<String> includes = new TreeSet<String>(); TreeSet<String> includes = new TreeSet<String>();
TreeSet<String> revIncludes = new TreeSet<String>(); TreeSet<String> revIncludes = new TreeSet<String>();
TreeSet<String> sortParams = new TreeSet<String>(); TreeSet<String> sortParams = new TreeSet<String>();
List<RestQuery> queries = new ArrayList<Conformance.RestQuery>();
boolean haveSearchParams = false; boolean haveSearchParams = false;
List<List<String>> queryIncludes = new ArrayList<List<String>>(); List<List<String>> queryIncludes = new ArrayList<List<String>>();
switch (theRequest.getFhirVersion(myConfig)) { switch (theRequest.getFhirVersion(myConfig)) {
case DSTU1:
haveSearchParams = extractSearchParamsDstu1(conformance, resourceName, includes, sortParams, queries, haveSearchParams, queryIncludes);
break;
case DSTU2: case DSTU2:
haveSearchParams = extractSearchParamsDstu2(conformance, resourceName, includes, revIncludes, sortParams, queries, haveSearchParams, queryIncludes); haveSearchParams = extractSearchParamsDstu2(conformance, resourceName, includes, revIncludes, sortParams, haveSearchParams, queryIncludes);
break; break;
case DSTU3: case DSTU3:
haveSearchParams = extractSearchParamsDstu3CapabilityStatement(conformance, resourceName, includes, revIncludes, sortParams, queries, haveSearchParams, queryIncludes); haveSearchParams = extractSearchParamsDstu3CapabilityStatement(conformance, resourceName, includes, revIncludes, sortParams, haveSearchParams, queryIncludes);
break; break;
default: default:
throw new IllegalStateException("Unknown FHIR version: " + theRequest.getFhirVersion(myConfig)); throw new IllegalStateException("Unknown FHIR version: " + theRequest.getFhirVersion(myConfig));
@ -329,7 +321,7 @@ public class Controller extends BaseController {
theModel.put("includes", includes); theModel.put("includes", includes);
theModel.put("revincludes", revIncludes); theModel.put("revincludes", revIncludes);
theModel.put("queries", queries); theModel.put("queries", Collections.emptyList()); //TODO: remove this, it does nothing
theModel.put("haveSearchParams", haveSearchParams); theModel.put("haveSearchParams", haveSearchParams);
theModel.put("queryIncludes", queryIncludes); theModel.put("queryIncludes", queryIncludes);
theModel.put("sortParams", sortParams); theModel.put("sortParams", sortParams);
@ -702,55 +694,8 @@ public class Controller extends BaseController {
} }
private boolean extractSearchParamsDstu1(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, List<List<String>> queryIncludes) {
Conformance conformance = (Conformance) theConformance;
for (Rest nextRest : conformance.getRest()) {
for (RestResource nextRes : nextRest.getResource()) {
if (nextRes.getType().getValue().equals(resourceName)) {
for (StringDt next : nextRes.getSearchInclude()) {
if (next.isEmpty() == false) {
includes.add(next.getValue());
}
}
for (RestResourceSearchParam next : nextRes.getSearchParam()) {
if (next.getType().getValueAsEnum() != SearchParamTypeEnum.COMPOSITE) {
sortParams.add(next.getName().getValue());
}
}
if (nextRes.getSearchParam().size() > 0) {
haveSearchParams = true;
}
}
}
for (RestQuery nextQuery : nextRest.getQuery()) {
boolean queryMatchesResource = false;
List<ExtensionDt> returnTypeExt = nextQuery.getUndeclaredExtensionsByUrl(ExtensionConstants.QUERY_RETURN_TYPE);
if (returnTypeExt != null) {
for (ExtensionDt nextExt : returnTypeExt) {
if (resourceName.equals(nextExt.getValueAsPrimitive().getValueAsString())) {
queries.add(nextQuery);
queryMatchesResource = true;
break;
}
}
}
if (queryMatchesResource) { private boolean extractSearchParamsDstu2(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, boolean haveSearchParams, List<List<String>> queryIncludes) {
ArrayList<String> nextQueryIncludes = new ArrayList<String>();
queryIncludes.add(nextQueryIncludes);
List<ExtensionDt> includesExt = nextQuery.getUndeclaredExtensionsByUrl(ExtensionConstants.QUERY_ALLOWED_INCLUDE);
if (includesExt != null) {
for (ExtensionDt nextExt : includesExt) {
nextQueryIncludes.add(nextExt.getValueAsPrimitive().getValueAsString());
}
}
}
}
}
return haveSearchParams;
}
private boolean extractSearchParamsDstu2(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, List<List<String>> queryIncludes) {
ca.uhn.fhir.model.dstu2.resource.Conformance conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) theConformance; ca.uhn.fhir.model.dstu2.resource.Conformance conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) theConformance;
for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) { for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource nextRes : nextRest.getResource()) { for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource nextRes : nextRest.getResource()) {
@ -786,7 +731,7 @@ public class Controller extends BaseController {
return haveSearchParams; return haveSearchParams;
} }
private boolean extractSearchParamsDstu3CapabilityStatement(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, List<List<String>> queryIncludes) { private boolean extractSearchParamsDstu3CapabilityStatement(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, boolean haveSearchParams, List<List<String>> queryIncludes) {
CapabilityStatement conformance = (org.hl7.fhir.dstu3.model.CapabilityStatement) theConformance; CapabilityStatement conformance = (org.hl7.fhir.dstu3.model.CapabilityStatement) theConformance;
for (CapabilityStatementRestComponent nextRest : conformance.getRest()) { for (CapabilityStatementRestComponent nextRest : conformance.getRest()) {
for (CapabilityStatementRestResourceComponent nextRes : nextRest.getResource()) { for (CapabilityStatementRestResourceComponent nextRes : nextRest.getResource()) {

View File

@ -10,9 +10,9 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.dstu.composite.IdentifierDt; import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport; import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport;
import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.rest.annotation.*; import ca.uhn.fhir.rest.annotation.*;
import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.param.TokenOrListParam;
@ -139,14 +139,14 @@ public class OverlayTestApp {
@Description(shortDefinition = "This is a query by date!") @Description(shortDefinition = "This is a query by date!")
@Search @Search
public List<DiagnosticReport> findDiagnosticReportsByPatient(@RequiredParam(name = DiagnosticReport.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER) IdentifierDt thePatientId, @OptionalParam(name = DiagnosticReport.SP_NAME) TokenOrListParam theNames, public List<DiagnosticReport> findDiagnosticReportsByPatient(@RequiredParam(name = DiagnosticReport.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER) IdentifierDt thePatientId, @OptionalParam(name = DiagnosticReport.SP_CODE) TokenOrListParam theNames,
@OptionalParam(name = DiagnosticReport.SP_DATE) DateRangeParam theDateRange, @IncludeParam(allow = { "DiagnosticReport.result" }) Set<Include> theIncludes) throws Exception { @OptionalParam(name = DiagnosticReport.SP_DATE) DateRangeParam theDateRange, @IncludeParam(allow = { "DiagnosticReport.result" }) Set<Include> theIncludes) throws Exception {
return null; return null;
} }
@Description(shortDefinition = "This is a query by issued.. blah blah foo bar blah blah") @Description(shortDefinition = "This is a query by issued.. blah blah foo bar blah blah")
@Search @Search
public List<DiagnosticReport> findDiagnosticReportsByPatientIssued(@RequiredParam(name = DiagnosticReport.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER) IdentifierDt thePatientId, @OptionalParam(name = DiagnosticReport.SP_NAME) TokenOrListParam theNames, public List<DiagnosticReport> findDiagnosticReportsByPatientIssued(@RequiredParam(name = DiagnosticReport.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER) IdentifierDt thePatientId, @OptionalParam(name = DiagnosticReport.SP_CODE) TokenOrListParam theNames,
@OptionalParam(name = DiagnosticReport.SP_ISSUED) DateRangeParam theDateRange, @IncludeParam(allow = { "DiagnosticReport.result" }) Set<Include> theIncludes) throws Exception { @OptionalParam(name = DiagnosticReport.SP_ISSUED) DateRangeParam theDateRange, @IncludeParam(allow = { "DiagnosticReport.result" }) Set<Include> theIncludes) throws Exception {
return null; return null;
} }

View File

@ -1,34 +0,0 @@
package test;
import static org.junit.Assert.*;
import java.io.IOException;
import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.test.customstructs.resource.Organization;
import ca.uhn.test.customstructs.valueset.ConnectingGTAProviderIDNamespacesEnum;
public class TestCustomStructures {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TestCustomStructures.class);
@Test
public void testExtension() throws DataFormatException, IOException {
Organization org = new Organization();
org.addProviderIdPool(ConnectingGTAProviderIDNamespacesEnum.UNIVERSITY_HEALTH_NETWORK_PROVIDER_IDS);
FhirContext ctx = new FhirContext(Organization.class);
String str = ctx.newXmlParser().encodeResourceToString(org);
ourLog.info(str);
assertTrue(str.contains("<extension url=\"http://foo1#providerIdPool\"><valueCode value=\"urn:oid:1.3.6.1.4.1.12201.1\"/></extension>"));
}
}

View File

@ -1,23 +0,0 @@
package test;
import java.util.List;
import org.junit.Test;
import ca.uhn.test.generic.single.TestConfigDstu1;
import ca.uhn.test.generic.multi.*;
import test.ResourceTest;
public class TestGenerics {
@Test
public void testGeneratedListReferencingGenerics() {
// This won't compile if tinder didn't generate the right names...
TestConfigDstu1 config = new TestConfigDstu1();
List<ResourceTest> generics = config.testProvidersDstu1();
for (ResourceTest generic : generics) {
String name = generic.getResourceName();
}
}
}

View File

@ -3,7 +3,7 @@ package test;
import org.junit.Test; import org.junit.Test;
import ca.uhn.test.realstructs.resource.ListResource; import ca.uhn.test.realstructs.resource.ListResource;
import ca.uhn.test.realstructs.resource.SecurityEvent.ObjectElement; import ca.uhn.test.realstructs.resource.AuditEvent.ObjectElement;
public class TestParticulars { public class TestParticulars {

View File

@ -1,18 +0,0 @@
package test;
import static org.junit.Assert.*;
import org.junit.Test;
import ca.uhn.test.customstructs.resource.Patient;
public class TestProfileGenerator {
@Test
public void testIncludes() {
assertEquals("Patient.link.other", Patient.INCLUDE_LINK_OTHER.getValue());
}
}