Merge remote-tracking branch 'origin/master' into hl7org_structs

Conflicts:
	hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IFhirVersion.java
	hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/model/dstu/FhirDstu1.java
This commit is contained in:
jamesagnew 2014-12-17 16:08:59 -05:00
commit 3963bb68e8
44 changed files with 648 additions and 203 deletions

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -17,12 +17,12 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</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-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -0,0 +1,117 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hapi-deployable-pom</artifactId>
<packaging>pom</packaging>
<name>HAPI FHIR - Deployable Artifact Parent POM</name>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
<reportSets>
<reportSet>
<reports>
<report>scm</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven_javadoc_plugin_version}</version>
<reportSets>
<reportSet>
<id>default</id>
<reports>
<report>javadoc</report>
</reports>
<configuration>
<links>
<link>http://jamesagnew.github.io/hapi-fhir/apidocs/</link>
<link>https://docs.oracle.com/javaee/7/api/</link>
</links>
</configuration>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<profiles>
<profile>
<id>DIST</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<minmemory>128m</minmemory>
<maxmemory>1g</maxmemory>
<linksource>true</linksource>
<verbose>false</verbose>
<debug>false</debug>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven_source_plugin_version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${maven_license_plugin_version}</version>
<executions>
<execution>
<id>first</id>
<goals>
<goal>update-file-header</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<licenseName>apache_v2</licenseName>
<canUpdateDescription>true</canUpdateDescription>
<canUpdateCopyright>true</canUpdateCopyright>
<roots>
<root>src/main/java</root>
</roots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>
@ -195,39 +195,13 @@
</plugins> </plugins>
</reporting> </reporting>
</profile> </profile>
<profile>
<id>DIST</id>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven_assembly_plugin_version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>false</attach>
<descriptors>
<descriptor>${project.basedir}/src/assembly/hapi-fhir-all.xml</descriptor>
<!-- <descriptor>src/assembly/hapi-jdk14.xml</descriptor> -->
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile> <profile>
<id>ANDROID</id> <id>ANDROID</id>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId> <artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -32,6 +32,9 @@ import org.hl7.fhir.instance.model.IBaseResource;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.annotation.ResourceDef; import ca.uhn.fhir.model.api.annotation.ResourceDef;
import com.phloc.commons.url.URLValidator;
import javax.servlet.http.HttpServletRequest;
public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefinition<IBaseResource> { public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefinition<IBaseResource> {
@ -76,10 +79,30 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
return ChildTypeEnum.RESOURCE; return ChildTypeEnum.RESOURCE;
} }
@Deprecated
public String getResourceProfile() { public String getResourceProfile() {
return myResourceProfile; return myResourceProfile;
} }
public String getResourceProfile(String theServerBase) {
String profile;
if (!myResourceProfile.isEmpty()) {
profile = myResourceProfile;
} else if (!myId.isEmpty()) {
profile = myId;
} else {
return "";
}
if (!URLValidator.isValid(profile)) {
String profileWithUrl = theServerBase + "/Profile/" + profile;
if (URLValidator.isValid(profileWithUrl)) {
return profileWithUrl;
}
}
return profile;
}
public RuntimeSearchParam getSearchParam(String theName) { public RuntimeSearchParam getSearchParam(String theName) {
return myNameToSearchParam.get(theName); return myNameToSearchParam.get(theName);
} }
@ -117,17 +140,26 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
} while (target.equals(Object.class)==false); } while (target.equals(Object.class)==false);
} }
@Deprecated
public synchronized IResource toProfile() { public synchronized IResource toProfile() {
if (myProfileDef != null) { if (myProfileDef != null) {
return myProfileDef; return myProfileDef;
} }
IResource retVal = myContext.getVersion().generateProfile(this); IResource retVal = myContext.getVersion().generateProfile(this, null);
myProfileDef = retVal; myProfileDef = retVal;
return retVal; return retVal;
} }
public synchronized IResource toProfile(String theServerBase) {
if (myProfileDef != null) {
return myProfileDef;
}
IResource retVal = myContext.getVersion().generateProfile(this, theServerBase);
myProfileDef = retVal;
return retVal;
}
} }

View File

@ -27,6 +27,8 @@ import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.RestfulServer;
import javax.servlet.http.HttpServletRequest;
public interface IFhirVersion { public interface IFhirVersion {
FhirVersionEnum getVersion(); FhirVersionEnum getVersion();
@ -39,4 +41,10 @@ public interface IFhirVersion {
InputStream getFhirVersionPropertiesFile(); InputStream getFhirVersionPropertiesFile();
IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase);
Object createServerConformanceProvider(RestfulServer theServer);
IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer);
} }

View File

@ -33,17 +33,27 @@ import java.lang.annotation.Target;
public @interface ResourceDef { public @interface ResourceDef {
/** /**
* The name of the resource (e.g. "Patient" or "DiagnosticReport") * The name of the resource (e.g. "Patient" or "DiagnosticReport"). If you are defining your
* own custom extension to a built-in FHIR resource definition type (e.g. you are extending
* the built-in Patient class) you do not need to supply a value for this property, as it
* will be inferred from the parent class.
*/ */
String name() default ""; String name() default "";
/** /**
* if set, will be used as the id for any profiles generated for this resource * if set, will be used as the id for any profiles generated for this resource. This property
* should be set for custom profile definition classes, and will be used as the resource ID
* for the generated profile exported by the server. For example, if you set this value to
* "hello" on a custom resource class, your server will automatically export a profile with the
* identity: <code>http://localhost:8080/fhir/Profile/hello</code> (the base URL will be whatever
* your server uses, not necessarily "http://localhost:8080/fhir")
*/ */
String id() default ""; String id() default "";
/** /**
* The URL indicating the profile for this resource definition, if known * The URL indicating the profile for this resource definition, if known. If this value is set
* on a custom profile definition class in a server, the profile is assumed to be external to
* the server, so the server will not export a profile for it.
*/ */
String profile() default ""; String profile() default "";

View File

@ -469,11 +469,7 @@ public class RestfulServer extends HttpServlet {
requestPath = requestPath.substring(1); requestPath = requestPath.substring(1);
} }
fhirServerBase = myServerAddressStrategy.determineServerBase(getServletContext(), theRequest); fhirServerBase = getServerBaseForRequest(theRequest);
if (fhirServerBase.endsWith("/")) {
fhirServerBase = fhirServerBase.substring(0, fhirServerBase.length() - 1);
}
String completeUrl = StringUtils.isNotBlank(theRequest.getQueryString()) ? requestUrl + "?" + theRequest.getQueryString() : requestUrl.toString(); String completeUrl = StringUtils.isNotBlank(theRequest.getQueryString()) ? requestUrl + "?" + theRequest.getQueryString() : requestUrl.toString();
@ -707,7 +703,16 @@ public class RestfulServer extends HttpServlet {
theResponse.getWriter().close(); theResponse.getWriter().close();
} }
}
public String getServerBaseForRequest(HttpServletRequest theRequest) {
String fhirServerBase;
fhirServerBase = myServerAddressStrategy.determineServerBase(getServletContext(), theRequest);
if (fhirServerBase.endsWith("/")) {
fhirServerBase = fhirServerBase.substring(0, fhirServerBase.length() - 1);
}
return fhirServerBase;
} }
/** /**
@ -944,7 +949,7 @@ public class RestfulServer extends HttpServlet {
myInterceptors.remove(theInterceptor); myInterceptors.remove(theInterceptor);
} }
private static void addProfileToBundleEntry(FhirContext theContext, IResource theResource) { private static void addProfileToBundleEntry(FhirContext theContext, IResource theResource, String theServerBase) {
TagList tl = ResourceMetadataKeyEnum.TAG_LIST.get(theResource); TagList tl = ResourceMetadataKeyEnum.TAG_LIST.get(theResource);
if (tl == null) { if (tl == null) {
@ -953,7 +958,7 @@ public class RestfulServer extends HttpServlet {
} }
RuntimeResourceDefinition nextDef = theContext.getResourceDefinition(theResource); RuntimeResourceDefinition nextDef = theContext.getResourceDefinition(theResource);
String profile = nextDef.getResourceProfile(); String profile = nextDef.getResourceProfile(theServerBase);
if (isNotBlank(profile)) { if (isNotBlank(profile)) {
tl.add(new Tag(Tag.HL7_ORG_PROFILE_TAG, profile, null)); tl.add(new Tag(Tag.HL7_ORG_PROFILE_TAG, profile, null));
} }
@ -1017,7 +1022,7 @@ public class RestfulServer extends HttpServlet {
for (IResource nextRes : resourceList) { for (IResource nextRes : resourceList) {
RuntimeResourceDefinition def = theServer.getFhirContext().getResourceDefinition(nextRes); RuntimeResourceDefinition def = theServer.getFhirContext().getResourceDefinition(nextRes);
if (theServer.getAddProfileTag() == AddProfileTagEnum.ALWAYS || !def.isStandardProfile()) { if (theServer.getAddProfileTag() == AddProfileTagEnum.ALWAYS || !def.isStandardProfile()) {
addProfileToBundleEntry(theServer.getFhirContext(), nextRes); addProfileToBundleEntry(theServer.getFhirContext(), nextRes, theServerBase);
} }
} }
} }
@ -1336,7 +1341,7 @@ public class RestfulServer extends HttpServlet {
if (theServer.getAddProfileTag() != AddProfileTagEnum.NEVER) { if (theServer.getAddProfileTag() != AddProfileTagEnum.NEVER) {
RuntimeResourceDefinition def = theServer.getFhirContext().getResourceDefinition(theResource); RuntimeResourceDefinition def = theServer.getFhirContext().getResourceDefinition(theResource);
if (theServer.getAddProfileTag() == AddProfileTagEnum.ALWAYS || !def.isStandardProfile()) { if (theServer.getAddProfileTag() == AddProfileTagEnum.ALWAYS || !def.isStandardProfile()) {
addProfileToBundleEntry(theServer.getFhirContext(), theResource); addProfileToBundleEntry(theServer.getFhirContext(), theResource, theServerBase);
} }
} }

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
@ -40,12 +40,12 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</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-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
</dependencies> </dependencies>

100
hapi-fhir-dist/pom.xml Normal file
View File

@ -0,0 +1,100 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>0.8</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<packaging>pom</packaging>
<name>HAPI FHIR Structures - DSTU (FHIR 0.80)</name>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>0.8</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.8</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dev</artifactId>
<version>0.8</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback_version}</version>
</dependency>
<dependency>
<groupId>org.ebaysf.web</groupId>
<artifactId>cors-filter</artifactId>
<version>${ebay_cors_filter_version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>${thymeleaf-version}</version>
</dependency>
<dependency>
<groupId>com.phloc</groupId>
<artifactId>phloc-schematron</artifactId>
<version>${phloc_schematron_version}</version>
</dependency>
<dependency>
<groupId>com.phloc</groupId>
<artifactId>phloc-commons</artifactId>
<version>${phloc_commons_version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>DIST</id>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven_assembly_plugin_version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>false</attach>
<descriptors>
<descriptor>${project.basedir}/src/assembly/hapi-fhir-all.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -20,18 +20,11 @@
<include>NOTICE*</include> <include>NOTICE*</include>
</includes> </includes>
</fileSet> </fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets> </fileSets>
<dependencySets> <dependencySets>
<dependencySet> <dependencySet>
<outputDirectory>/lib/dependency</outputDirectory> <outputDirectory>/lib</outputDirectory>
<useProjectArtifact>true</useProjectArtifact> <useProjectArtifact>true</useProjectArtifact>
<unpack>false</unpack> <unpack>false</unpack>
<scope>runtime</scope> <scope>runtime</scope>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -35,7 +35,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>commons-logging</artifactId> <artifactId>commons-logging</artifactId>
@ -46,7 +46,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId> <artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -19,6 +19,8 @@ public class SearchParameterMap extends HashMap<String, List<List<? extends IQue
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Integer myCount;
private Set<Include> myIncludes; private Set<Include> myIncludes;
private SortSpec mySort; private SortSpec mySort;
@ -66,6 +68,10 @@ public class SearchParameterMap extends HashMap<String, List<List<? extends IQue
getIncludes().add(theInclude); getIncludes().add(theInclude);
} }
public Integer getCount() {
return myCount;
}
public Set<Include> getIncludes() { public Set<Include> getIncludes() {
if (myIncludes == null) { if (myIncludes == null) {
myIncludes = new HashSet<Include>(); myIncludes = new HashSet<Include>();
@ -77,6 +83,10 @@ public class SearchParameterMap extends HashMap<String, List<List<? extends IQue
return mySort; return mySort;
} }
public void setCount(Integer theCount) {
myCount = theCount;
}
public void setIncludes(Set<Include> theIncludes) { public void setIncludes(Set<Include> theIncludes) {
myIncludes = theIncludes; myIncludes = theIncludes;
} }

View File

@ -19,6 +19,8 @@ import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider; import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider;
import ca.uhn.fhir.util.ExtensionConstants; import ca.uhn.fhir.util.ExtensionConstants;
import javax.servlet.http.HttpServletRequest;
public class JpaConformanceProvider extends ServerConformanceProvider { public class JpaConformanceProvider extends ServerConformanceProvider {
private String myImplementationDescription; private String myImplementationDescription;
@ -34,14 +36,14 @@ public class JpaConformanceProvider extends ServerConformanceProvider {
} }
@Override @Override
public Conformance getServerConformance() { public Conformance getServerConformance(HttpServletRequest theRequest) {
Conformance retVal = myCachedValue; Conformance retVal = myCachedValue;
Map<String, Long> counts = mySystemDao.getResourceCounts(); Map<String, Long> counts = mySystemDao.getResourceCounts();
FhirContext ctx = myRestfulServer.getFhirContext(); FhirContext ctx = myRestfulServer.getFhirContext();
retVal = super.getServerConformance(); retVal = super.getServerConformance(theRequest);
for (Rest nextRest : retVal.getRest()) { for (Rest nextRest : retVal.getRest()) {
for (RestResource nextResource : nextRest.getResource()) { for (RestResource nextResource : nextRest.getResource()) {

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -17,7 +17,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId> <artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.thymeleaf</groupId> <groupId>org.thymeleaf</groupId>
@ -127,7 +127,7 @@
<plugin> <plugin>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId> <artifactId>hapi-tinder-plugin</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<executions> <executions>
<execution> <execution>
<id>buildclient</id> <id>buildclient</id>
@ -160,7 +160,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId> <artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>

View File

@ -3,7 +3,9 @@ package ca.uhn.fhir.jpa.test;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
@ -15,6 +17,7 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.provider.JpaSystemProvider; import ca.uhn.fhir.jpa.provider.JpaSystemProvider;
@ -43,6 +46,7 @@ import ca.uhn.fhir.rest.client.IGenericClient;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.rest.gclient.StringClientParam; import ca.uhn.fhir.rest.gclient.StringClientParam;
import ca.uhn.fhir.rest.gclient.TokenClientParam; import ca.uhn.fhir.rest.gclient.TokenClientParam;
import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider;
import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
@ -67,6 +71,8 @@ public class CompleteResourceProviderTest {
private static IFhirResourceDao<Questionnaire> ourQuestionnaireDao; private static IFhirResourceDao<Questionnaire> ourQuestionnaireDao;
private static Server ourServer; private static Server ourServer;
private static IFhirResourceDao<Organization> ourOrganizationDao; private static IFhirResourceDao<Organization> ourOrganizationDao;
private static OrganizationResourceProvider ourOrganizationRp;
private static DaoConfig ourDaoConfig;
// private static JpaConformanceProvider ourConfProvider; // private static JpaConformanceProvider ourConfProvider;
@ -97,6 +103,29 @@ public class CompleteResourceProviderTest {
} }
} }
@Test
public void testCountParam() throws Exception {
// NB this does not get used- The paging provider has its own limits built in
ourDaoConfig.setHardSearchLimit(100);
List<IResource> resources = new ArrayList<>();
for (int i = 0; i < 100; i++) {
Organization org = new Organization();
org.setName("testCountParam_01");
resources.add(org);
}
ourClient.transaction().withResources(resources).prettyPrint().encodedXml().execute();
Bundle found = ourClient.search().forResource(Organization.class).where(Organization.NAME.matches().value("testCountParam_01")).limitTo(10).execute();
assertEquals(100, found.getTotalResults().getValue().intValue());
assertEquals(10, found.getEntries().size());
found = ourClient.search().forResource(Organization.class).where(Organization.NAME.matches().value("testCountParam_01")).limitTo(999).execute();
assertEquals(100, found.getTotalResults().getValue().intValue());
assertEquals(50, found.getEntries().size());
}
/** /**
* See issue #52 * See issue #52
*/ */
@ -212,7 +241,8 @@ public class CompleteResourceProviderTest {
} }
Bundle history = ourClient.history(null, (String) null, null, null); Bundle history = ourClient.history(null, (String) null, null, null);
assertEquals(p1Id.getIdPart(), history.getEntries().get(0).getId().getIdPart());
assertEquals("Expected[" + p1Id.getIdPart() + "] but was " + history.getEntries().get(0).getId(), p1Id.getIdPart(), history.getEntries().get(0).getId().getIdPart());
assertNotNull(history.getEntries().get(0).getResource()); assertNotNull(history.getEntries().get(0).getResource());
} }
@ -452,6 +482,8 @@ public class CompleteResourceProviderTest {
if (true) { if (true) {
ourAppCtx = new ClassPathXmlApplicationContext("fhir-spring-test-config.xml"); ourAppCtx = new ClassPathXmlApplicationContext("fhir-spring-test-config.xml");
ourDaoConfig = (DaoConfig)ourAppCtx.getBean(DaoConfig.class);
ourPatientDao = (IFhirResourceDao<Patient>) ourAppCtx.getBean("myPatientDao", IFhirResourceDao.class); ourPatientDao = (IFhirResourceDao<Patient>) ourAppCtx.getBean("myPatientDao", IFhirResourceDao.class);
PatientResourceProvider patientRp = new PatientResourceProvider(); PatientResourceProvider patientRp = new PatientResourceProvider();
patientRp.setDao(ourPatientDao); patientRp.setDao(ourPatientDao);
@ -473,8 +505,8 @@ public class CompleteResourceProviderTest {
encounterRp.setDao(encounterDao); encounterRp.setDao(encounterDao);
ourOrganizationDao = (IFhirResourceDao<Organization>) ourAppCtx.getBean("myOrganizationDao", IFhirResourceDao.class); ourOrganizationDao = (IFhirResourceDao<Organization>) ourAppCtx.getBean("myOrganizationDao", IFhirResourceDao.class);
OrganizationResourceProvider organizationRp = new OrganizationResourceProvider(); ourOrganizationRp = new OrganizationResourceProvider();
organizationRp.setDao(ourOrganizationDao); ourOrganizationRp.setDao(ourOrganizationDao);
IFhirResourceDao<ImagingStudy> imagingStudyDao = (IFhirResourceDao<ImagingStudy>) ourAppCtx.getBean("myImagingStudyDao", IFhirResourceDao.class); IFhirResourceDao<ImagingStudy> imagingStudyDao = (IFhirResourceDao<ImagingStudy>) ourAppCtx.getBean("myImagingStudyDao", IFhirResourceDao.class);
ImagingStudyResourceProvider imagingStudyRp = new ImagingStudyResourceProvider(); ImagingStudyResourceProvider imagingStudyRp = new ImagingStudyResourceProvider();
@ -492,7 +524,7 @@ public class CompleteResourceProviderTest {
DocumentReferenceResourceProvider documentReferenceRp = new DocumentReferenceResourceProvider(); DocumentReferenceResourceProvider documentReferenceRp = new DocumentReferenceResourceProvider();
documentReferenceRp.setDao(documentReferenceDao); documentReferenceRp.setDao(documentReferenceDao);
restServer.setResourceProviders(diagnosticOrderRp, documentManifestRp, documentReferenceRp, encounterRp, locationRp, patientRp, questionnaireRp, organizationRp, imagingStudyRp); restServer.setResourceProviders(diagnosticOrderRp, documentManifestRp, documentReferenceRp, encounterRp, locationRp, patientRp, questionnaireRp, ourOrganizationRp, imagingStudyRp);
restServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); restServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
IFhirSystemDao systemDao = (IFhirSystemDao) ourAppCtx.getBean("mySystemDao", IFhirSystemDao.class); IFhirSystemDao systemDao = (IFhirSystemDao) ourAppCtx.getBean("mySystemDao", IFhirSystemDao.class);
@ -502,6 +534,8 @@ public class CompleteResourceProviderTest {
// ourConfProvider = new JpaConformanceProvider(restServer, systemDao, // ourConfProvider = new JpaConformanceProvider(restServer, systemDao,
// Collections.singletonList((IFhirResourceDao)patientDao)); // Collections.singletonList((IFhirResourceDao)patientDao));
restServer.setPagingProvider(new FifoMemoryPagingProvider(10));
ourServer = new Server(port); ourServer = new Server(port);
ServletContextHandler proxyHandler = new ServletContextHandler(); ServletContextHandler proxyHandler = new ServletContextHandler();

View File

@ -15,7 +15,7 @@
<dependent-module archiveName="hapi-fhir-structures-dstu-0.8-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-structures-dstu/hapi-fhir-structures-dstu"> <dependent-module archiveName="hapi-fhir-structures-dstu-0.8-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-structures-dstu/hapi-fhir-structures-dstu">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/prj/hapi-fhir-testpage-overlay?includes=**/**&amp;excludes=META-INF/MANIFEST.MF"> <dependent-module deploy-path="/" handle="module:/overlay/var/M2_REPO/ca/uhn/hapi/fhir/hapi-fhir-testpage-overlay/0.8-SNAPSHOT/hapi-fhir-testpage-overlay-0.8-SNAPSHOT.war?unpackFolder=target/m2e-wtp/overlays&amp;includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
<dependency-type>consumes</dependency-type> <dependency-type>consumes</dependency-type>
</dependent-module> </dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&amp;excludes=META-INF/MANIFEST.MF"> <dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -16,17 +16,17 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId> <artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</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-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId> <artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<type>war</type> <type>war</type>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -34,7 +34,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-test</artifactId> <artifactId>hapi-fhir-jpaserver-test</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -190,7 +190,7 @@
<plugin> <plugin>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId> <artifactId>hapi-tinder-plugin</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<executions> <executions>
<execution> <execution>
<id>buildclient</id> <id>buildclient</id>
@ -274,7 +274,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId> <artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>
@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<dependency> <dependency>
@ -33,7 +33,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId> <artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
--> -->
@ -203,7 +203,7 @@
<plugin> <plugin>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId> <artifactId>hapi-tinder-plugin</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

View File

@ -36,6 +36,8 @@ import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.provider.dev.ServerConformanceProvider; import ca.uhn.fhir.rest.server.provider.dev.ServerConformanceProvider;
import ca.uhn.fhir.rest.server.provider.dev.ServerProfileProvider; import ca.uhn.fhir.rest.server.provider.dev.ServerProfileProvider;
import javax.servlet.http.HttpServletRequest;
public class FhirDev implements IFhirVersion { public class FhirDev implements IFhirVersion {
private String myId; private String myId;
@ -46,7 +48,7 @@ public class FhirDev implements IFhirVersion {
} }
@Override @Override
public IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition) { public IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase) {
Profile retVal = new Profile(); Profile retVal = new Profile();
RuntimeResourceDefinition def = theRuntimeResourceDefinition; RuntimeResourceDefinition def = theRuntimeResourceDefinition;
@ -62,7 +64,7 @@ public class FhirDev implements IFhirVersion {
@Override @Override
public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) { public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) {
return new ServerProfileProvider(theRestfulServer.getFhirContext()); return new ServerProfileProvider(theRestfulServer);
} }
@Override @Override

View File

@ -34,13 +34,18 @@ import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Read; import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
import javax.servlet.http.HttpServletRequest;
public class ServerProfileProvider implements IResourceProvider { public class ServerProfileProvider implements IResourceProvider {
private FhirContext myContext; private final FhirContext myContext;
private final RestfulServer myRestfulServer;
public ServerProfileProvider(FhirContext theCtx) { public ServerProfileProvider(RestfulServer theServer) {
myContext = theCtx; myContext = theServer.getFhirContext();
myRestfulServer = theServer;
} }
@Override @Override
@ -49,31 +54,36 @@ public class ServerProfileProvider implements IResourceProvider {
} }
@Read() @Read()
public Profile getProfileById(@IdParam IdDt theId) { public Profile getProfileById(HttpServletRequest theRequest, @IdParam IdDt theId) {
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getValue()); RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getValue());
if (retVal==null) { if (retVal==null) {
return null; return null;
} }
return (Profile) retVal.toProfile(); String serverBase = getServerBase(theRequest);
return (Profile) retVal.toProfile(serverBase);
} }
@Search() @Search()
public List<Profile> getAllProfiles() { public List<Profile> getAllProfiles(HttpServletRequest theRequest) {
final String serverBase = getServerBase(theRequest);
List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitions()); List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitions());
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() { Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
@Override @Override
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
int cmp = theO1.getName().compareTo(theO2.getName()); int cmp = theO1.getName().compareTo(theO2.getName());
if (cmp==0) { if (cmp==0) {
cmp=theO1.getResourceProfile().compareTo(theO2.getResourceProfile()); cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase));
} }
return cmp; return cmp;
}}); }});
ArrayList<Profile> retVal = new ArrayList<Profile>(); ArrayList<Profile> retVal = new ArrayList<Profile>();
for (RuntimeResourceDefinition next : defs) { for (RuntimeResourceDefinition next : defs) {
retVal.add((Profile) next.toProfile()); retVal.add((Profile) next.toProfile(serverBase));
} }
return retVal; return retVal;
} }
private String getServerBase(HttpServletRequest theHttpRequest) {
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
}
} }

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>
@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<dependency> <dependency>
@ -195,7 +195,7 @@
<plugin> <plugin>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId> <artifactId>hapi-tinder-plugin</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

View File

@ -73,6 +73,8 @@ import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider; import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider;
import ca.uhn.fhir.rest.server.provider.ServerProfileProvider; import ca.uhn.fhir.rest.server.provider.ServerProfileProvider;
import javax.servlet.http.HttpServletRequest;
public class FhirDstu1 implements IFhirVersion { public class FhirDstu1 implements IFhirVersion {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirDstu1.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirDstu1.class);
@ -146,7 +148,7 @@ public class FhirDstu1 implements IFhirVersion {
} }
} }
private void fillName(StructureElement elem, BaseRuntimeElementDefinition<?> nextDef) { private void fillName(StructureElement elem, BaseRuntimeElementDefinition<?> nextDef, String theServerBase) {
if (nextDef instanceof RuntimeResourceReferenceDefinition) { if (nextDef instanceof RuntimeResourceReferenceDefinition) {
RuntimeResourceReferenceDefinition rr = (RuntimeResourceReferenceDefinition) nextDef; RuntimeResourceReferenceDefinition rr = (RuntimeResourceReferenceDefinition) nextDef;
for (Class<? extends IBaseResource> next : rr.getResourceTypes()) { for (Class<? extends IBaseResource> next : rr.getResourceTypes()) {
@ -156,7 +158,7 @@ public class FhirDstu1 implements IFhirVersion {
if (next != IResource.class) { if (next != IResource.class) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
RuntimeResourceDefinition resDef = rr.getDefinitionForResourceType((Class<? extends IResource>) next); RuntimeResourceDefinition resDef = rr.getDefinitionForResourceType((Class<? extends IResource>) next);
type.getProfile().setValueAsString(resDef.getResourceProfile()); type.getProfile().setValueAsString(resDef.getResourceProfile(theServerBase));
} }
} }
@ -172,7 +174,7 @@ public class FhirDstu1 implements IFhirVersion {
type.setCode(fromCodeString); type.setCode(fromCodeString);
} }
private void fillProfile(Structure theStruct, StructureElement theElement, BaseRuntimeElementDefinition<?> def, LinkedList<String> path, BaseRuntimeDeclaredChildDefinition theChild) { private void fillProfile(Structure theStruct, StructureElement theElement, BaseRuntimeElementDefinition<?> def, LinkedList<String> path, BaseRuntimeDeclaredChildDefinition theChild, String theServerBase) {
fillBasics(theElement, def, path, theChild); fillBasics(theElement, def, path, theChild);
@ -220,7 +222,7 @@ public class FhirDstu1 implements IFhirVersion {
if (child instanceof RuntimeChildResourceBlockDefinition) { if (child instanceof RuntimeChildResourceBlockDefinition) {
RuntimeResourceBlockDefinition nextDef = (RuntimeResourceBlockDefinition) child.getSingleChildOrThrow(); RuntimeResourceBlockDefinition nextDef = (RuntimeResourceBlockDefinition) child.getSingleChildOrThrow();
fillProfile(theStruct, elem, nextDef, path, child); fillProfile(theStruct, elem, nextDef, path, child, theServerBase);
} else if (child instanceof RuntimeChildContainedResources) { } else if (child instanceof RuntimeChildContainedResources) {
// ignore // ignore
} else if (child instanceof RuntimeChildDeclaredExtensionDefinition) { } else if (child instanceof RuntimeChildDeclaredExtensionDefinition) {
@ -231,10 +233,10 @@ public class FhirDstu1 implements IFhirVersion {
String nextName = childNamesIter.next(); String nextName = childNamesIter.next();
BaseRuntimeElementDefinition<?> nextDef = child.getChildByName(nextName); BaseRuntimeElementDefinition<?> nextDef = child.getChildByName(nextName);
fillBasics(elem, nextDef, path, child); fillBasics(elem, nextDef, path, child);
fillName(elem, nextDef); fillName(elem, nextDef, theServerBase);
while (childNamesIter.hasNext()) { while (childNamesIter.hasNext()) {
nextDef = child.getChildByName(childNamesIter.next()); nextDef = child.getChildByName(childNamesIter.next());
fillName(elem, nextDef); fillName(elem, nextDef, theServerBase);
} }
path.pollLast(); path.pollLast();
} else { } else {
@ -250,7 +252,7 @@ public class FhirDstu1 implements IFhirVersion {
} }
@Override @Override
public IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition) { public IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase) {
Profile retVal = new Profile(); Profile retVal = new Profile();
RuntimeResourceDefinition def = theRuntimeResourceDefinition; RuntimeResourceDefinition def = theRuntimeResourceDefinition;
@ -279,8 +281,7 @@ public class FhirDstu1 implements IFhirVersion {
StructureElement element = struct.addElement(); StructureElement element = struct.addElement();
element.getDefinition().setMin(1); element.getDefinition().setMin(1);
element.getDefinition().setMax("1"); element.getDefinition().setMax("1");
fillProfile(struct, element, def, path, null, theServerBase);
fillProfile(struct, element, def, path, null);
retVal.getStructure().get(0).getElement().get(0).getDefinition().addType().getCode().setValue("Resource"); retVal.getStructure().get(0).getElement().get(0).getDefinition().addType().getCode().setValue("Resource");
@ -337,7 +338,7 @@ public class FhirDstu1 implements IFhirVersion {
@Override @Override
public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) { public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) {
return new ServerProfileProvider(theRestfulServer.getFhirContext()); return new ServerProfileProvider(theRestfulServer);
} }
@Override @Override

View File

@ -59,6 +59,8 @@ import ca.uhn.fhir.rest.server.ResourceBinding;
import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.util.ExtensionConstants; import ca.uhn.fhir.util.ExtensionConstants;
import javax.servlet.http.HttpServletRequest;
/** /**
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation * Server FHIR Provider which serves the conformance statement for a RESTful server implementation
* *
@ -95,7 +97,7 @@ public class ServerConformanceProvider {
* See the class documentation for an important note if you are extending this class * See the class documentation for an important note if you are extending this class
*/ */
@Metadata @Metadata
public Conformance getServerConformance() { public Conformance getServerConformance(HttpServletRequest theRequest) {
if (myConformance != null && myCache) { if (myConformance != null && myCache) {
return myConformance; return myConformance;
} }
@ -134,7 +136,7 @@ public class ServerConformanceProvider {
String resourceName = next.getResourceName(); String resourceName = next.getResourceName();
RuntimeResourceDefinition def = myRestfulServer.getFhirContext().getResourceDefinition(resourceName); RuntimeResourceDefinition def = myRestfulServer.getFhirContext().getResourceDefinition(resourceName);
resource.getType().setValue(def.getName()); resource.getType().setValue(def.getName());
resource.getProfile().setReference(new IdDt(def.getResourceProfile())); resource.getProfile().setReference(new IdDt(def.getResourceProfile(myRestfulServer.getServerBaseForRequest(theRequest))));
TreeSet<String> includes = new TreeSet<String>(); TreeSet<String> includes = new TreeSet<String>();

View File

@ -34,13 +34,19 @@ import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Read; import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.annotation.Search; import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
import org.apache.http.HttpRequest;
import javax.servlet.http.HttpServletRequest;
public class ServerProfileProvider implements IResourceProvider { public class ServerProfileProvider implements IResourceProvider {
private FhirContext myContext; private final FhirContext myContext;
private final RestfulServer myRestfulServer;
public ServerProfileProvider(FhirContext theCtx) { public ServerProfileProvider(RestfulServer theServer) {
myContext = theCtx; myContext = theServer.getFhirContext();
myRestfulServer = theServer;
} }
@Override @Override
@ -49,31 +55,36 @@ public class ServerProfileProvider implements IResourceProvider {
} }
@Read() @Read()
public Profile getProfileById(@IdParam IdDt theId) { public Profile getProfileById(HttpServletRequest theRequest, @IdParam IdDt theId) {
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
if (retVal==null) { if (retVal==null) {
return null; return null;
} }
return (Profile) retVal.toProfile(); String serverBase = getServerBase(theRequest);
return (Profile) retVal.toProfile(serverBase);
} }
@Search() @Search()
public List<Profile> getAllProfiles() { public List<Profile> getAllProfiles(HttpServletRequest theRequest) {
final String serverBase = getServerBase(theRequest);
List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitions()); List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitions());
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() { Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
@Override @Override
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
int cmp = theO1.getName().compareTo(theO2.getName()); int cmp = theO1.getName().compareTo(theO2.getName());
if (cmp==0) { if (cmp==0) {
cmp=theO1.getResourceProfile().compareTo(theO2.getResourceProfile()); cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase));
} }
return cmp; return cmp;
}}); }});
ArrayList<Profile> retVal = new ArrayList<Profile>(); ArrayList<Profile> retVal = new ArrayList<Profile>();
for (RuntimeResourceDefinition next : defs) { for (RuntimeResourceDefinition next : defs) {
retVal.add((Profile) next.toProfile()); retVal.add((Profile) next.toProfile(serverBase));
} }
return retVal; return retVal;
} }
private String getServerBase(HttpServletRequest theHttpRequest) {
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
}
} }

View File

@ -25,13 +25,13 @@ public class DuplicateExtensionTest extends TestCase {
public void testScannerShouldAddProvidedResources() { public void testScannerShouldAddProvidedResources() {
FhirContext ctx = new FhirContext(); FhirContext ctx = new FhirContext();
RuntimeResourceDefinition patientDef = ctx.getResourceDefinition(CustomPatient.class); RuntimeResourceDefinition patientDef = ctx.getResourceDefinition(CustomPatient.class);
Profile profile = (Profile) patientDef.toProfile(); Profile profile = (Profile) patientDef.toProfile("http://foo.org/fhir");
String res = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(profile); String res = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(profile);
ourLog.info(res); ourLog.info(res);
RuntimeResourceDefinition observationDef = ctx.getResourceDefinition(CustomObservation.class); RuntimeResourceDefinition observationDef = ctx.getResourceDefinition(CustomObservation.class);
profile = (Profile) observationDef.toProfile(); profile = (Profile) observationDef.toProfile("http://foo.org/fhir");
} }
@ResourceDef(name = "Observation", id = "CustomObservation") @ResourceDef(name = "Observation", id = "CustomObservation")

View File

@ -80,7 +80,7 @@ public class ExtensionTest {
{ {
FhirContext ctx2 = new FhirContext(); FhirContext ctx2 = new FhirContext();
RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient); RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient);
System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile())); System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile("http://foo.org/fhir")));
} }
} }

View File

@ -1,11 +1,6 @@
package ca.uhn.fhir.context; package ca.uhn.fhir.context;
import static org.junit.Assert.*; import ca.uhn.fhir.model.api.annotation.ResourceDef;
import java.util.List;
import org.junit.Test;
import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.dstu.resource.Profile; import ca.uhn.fhir.model.dstu.resource.Profile;
import ca.uhn.fhir.model.dstu.resource.Profile.ExtensionDefn; import ca.uhn.fhir.model.dstu.resource.Profile.ExtensionDefn;
@ -13,6 +8,12 @@ import ca.uhn.fhir.model.dstu.resource.Profile.Structure;
import ca.uhn.fhir.model.dstu.resource.Profile.StructureElement; import ca.uhn.fhir.model.dstu.resource.Profile.StructureElement;
import ca.uhn.fhir.model.dstu.resource.ValueSet; import ca.uhn.fhir.model.dstu.resource.ValueSet;
import ca.uhn.fhir.model.dstu.valueset.DataTypeEnum; import ca.uhn.fhir.model.dstu.valueset.DataTypeEnum;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class RuntimeResourceDefinitionTest { public class RuntimeResourceDefinitionTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RuntimeResourceDefinitionTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RuntimeResourceDefinitionTest.class);
@ -22,7 +23,7 @@ public class RuntimeResourceDefinitionTest {
FhirContext ctx = new FhirContext(Patient.class, Profile.class); FhirContext ctx = new FhirContext(Patient.class, Profile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(Patient.class); RuntimeResourceDefinition def = ctx.getResourceDefinition(Patient.class);
Profile profile = (Profile) def.toProfile(); Profile profile = (Profile) def.toProfile("http://foo.org/fhir");
ourLog.info(ctx.newXmlParser().encodeResourceToString(profile)); ourLog.info(ctx.newXmlParser().encodeResourceToString(profile));
@ -41,7 +42,7 @@ public class RuntimeResourceDefinitionTest {
FhirContext ctx = new FhirContext(ValueSet.class, Profile.class); FhirContext ctx = new FhirContext(ValueSet.class, Profile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(ValueSet.class); RuntimeResourceDefinition def = ctx.getResourceDefinition(ValueSet.class);
Profile profile = (Profile) def.toProfile(); Profile profile = (Profile) def.toProfile("http://foo.org/fhir");
String encoded = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(profile); String encoded = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(profile);
ourLog.info(encoded); ourLog.info(encoded);
@ -56,9 +57,9 @@ public class RuntimeResourceDefinitionTest {
FhirContext ctx = new FhirContext(ResourceWithExtensionsA.class, Profile.class); FhirContext ctx = new FhirContext(ResourceWithExtensionsA.class, Profile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(ResourceWithExtensionsA.class); RuntimeResourceDefinition def = ctx.getResourceDefinition(ResourceWithExtensionsA.class);
Profile profile = (Profile) def.toProfile(); Profile profile = (Profile) def.toProfile("http://foo.org/fhir");
ourLog.info(ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(profile)); ourLog.info(ctx.newXmlParser().encodeResourceToString(profile));
List<StructureElement> element = profile.getStructure().get(0).getElement(); List<StructureElement> element = profile.getStructure().get(0).getElement();
assertEquals(1, element.get(0).getDefinition().getType().size()); assertEquals(1, element.get(0).getDefinition().getType().size());
@ -97,9 +98,53 @@ public class RuntimeResourceDefinitionTest {
FhirContext ctx = new FhirContext(CustomObservation.class); FhirContext ctx = new FhirContext(CustomObservation.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(CustomObservation.class); RuntimeResourceDefinition def = ctx.getResourceDefinition(CustomObservation.class);
Profile profile = (Profile) def.toProfile(); Profile profile = (Profile) def.toProfile("http://foo.org/fhir");
assertEquals("customobservation", profile.getId().toString()); assertEquals("customobservation", profile.getId().toString());
} }
@Test
public void whenResourceProfileNotSet_ProfileShouldBeConstructedFromServerBaseAndId() {
FhirContext ctx = new FhirContext(PatientSansProfile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(PatientSansProfile.class);
assertEquals("http://foo.org/fhir/Profile/PatientSansProfile", def.getResourceProfile("http://foo.org/fhir"));
}
@ResourceDef(name = "Patient", id = "PatientSansProfile")
class PatientSansProfile extends Patient {
}
@Test
public void whenResourceProfileHasNoUrl_ProfileShouldBeConstructedFromServerBaseAndProfile() {
FhirContext ctx = new FhirContext(PatientWithShortProfile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(PatientWithShortProfile.class);
assertEquals("http://foo.org/fhir/Profile/PatientWithShortProfile", def.getResourceProfile("http://foo.org/fhir"));
}
@ResourceDef(name = "Patient", id = "PatientWithShortProfileId", profile="PatientWithShortProfile")
class PatientWithShortProfile extends Patient {
}
@Test
public void whenResourceProfileHasUrl_ProfileShouldUseThat() {
FhirContext ctx = new FhirContext(PatientWithFullProfile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(PatientWithFullProfile.class);
assertEquals("http://bar.org/Profile/PatientWithFullProfile", def.getResourceProfile("http://foo.org/fhir"));
}
@ResourceDef(name = "Patient", id = "PatientWithFullProfileId", profile="http://bar.org/Profile/PatientWithFullProfile")
class PatientWithFullProfile extends Patient {
}
@Test
public void whenProfileAndIdAreBlank_ProfileShouldBeBlank() {
FhirContext ctx = new FhirContext(PatientWithNoIdOrProfile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(PatientWithNoIdOrProfile.class);
assertEquals("", def.getResourceProfile("http://foo.org/fhir"));
}
@ResourceDef(name = "Patient")
class PatientWithNoIdOrProfile extends Patient {
}
} }

View File

@ -147,6 +147,7 @@ public class ClientTest {
HttpPost post = (HttpPost) capt.getValue(); HttpPost post = (HttpPost) capt.getValue();
assertThat(IOUtils.toString(post.getEntity().getContent()), StringContains.containsString("<Patient")); assertThat(IOUtils.toString(post.getEntity().getContent()), StringContains.containsString("<Patient"));
assertEquals("http://example.com/fhir/Patient/100/_history/200", response.getId().getValue()); assertEquals("http://example.com/fhir/Patient/100/_history/200", response.getId().getValue());
assertEquals(EncodingEnum.XML.getResourceContentType()+Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(0).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
assertEquals("200", response.getId().getVersionIdPart()); assertEquals("200", response.getId().getVersionIdPart());
} }
@ -1048,6 +1049,7 @@ public class ClientTest {
assertThat(IOUtils.toString(post.getEntity().getContent()), StringContains.containsString("<Patient")); assertThat(IOUtils.toString(post.getEntity().getContent()), StringContains.containsString("<Patient"));
assertEquals("http://example.com/fhir/Patient/100/_history/200", response.getId().getValue()); assertEquals("http://example.com/fhir/Patient/100/_history/200", response.getId().getValue());
assertEquals("200", response.getId().getVersionIdPart()); assertEquals("200", response.getId().getVersionIdPart());
assertEquals(EncodingEnum.XML.getResourceContentType()+Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(0).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
} }
/** /**

View File

@ -118,8 +118,7 @@ public class GenericClientTest {
//@formatter:on //@formatter:on
return msg; return msg;
} }
@Test @Test
public void testCreateWithStringAutoDetectsEncoding() throws Exception { public void testCreateWithStringAutoDetectsEncoding() throws Exception {
@ -139,29 +138,29 @@ public class GenericClientTest {
int count = 0; int count = 0;
client.create().resource(myCtx.newXmlParser().encodeResourceToString(p1)).execute(); client.create().resource(myCtx.newXmlParser().encodeResourceToString(p1)).execute();
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.XML.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
assertThat(extractBody(capt, count), containsString("value=\"John\"")); assertThat(extractBody(capt, count), containsString("value=\"John\""));
count++; count++;
client.create().resource(myCtx.newJsonParser().encodeResourceToString(p1)).execute(); client.create().resource(myCtx.newJsonParser().encodeResourceToString(p1)).execute();
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.JSON.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.JSON.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
assertThat(extractBody(capt, count), containsString("[\"John\"]")); assertThat(extractBody(capt, count), containsString("[\"John\"]"));
count++; count++;
/* /*
* e.g. Now try with reversed encoding (provide a string that's in JSON and ask the client to use XML) * e.g. Now try with reversed encoding (provide a string that's in JSON and ask the client to use XML)
*/ */
client.create().resource(myCtx.newXmlParser().encodeResourceToString(p1)).encodedJson().execute(); client.create().resource(myCtx.newXmlParser().encodeResourceToString(p1)).encodedJson().execute();
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.JSON.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.JSON.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
assertThat(extractBody(capt, count), containsString("[\"John\"]")); assertThat(extractBody(capt, count), containsString("[\"John\"]"));
count++; count++;
client.create().resource(myCtx.newJsonParser().encodeResourceToString(p1)).encodedXml().execute(); client.create().resource(myCtx.newJsonParser().encodeResourceToString(p1)).encodedXml().execute();
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.XML.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
assertThat(extractBody(capt, count), containsString("value=\"John\"")); assertThat(extractBody(capt, count), containsString("value=\"John\""));
count++; count++;
@ -191,16 +190,16 @@ public class GenericClientTest {
assertEquals("22", outcome.getId().getVersionIdPart()); assertEquals("22", outcome.getId().getVersionIdPart());
int count = 0; int count = 0;
assertEquals("http://example.com/fhir/Patient", capt.getValue().getURI().toString()); assertEquals("http://example.com/fhir/Patient", capt.getValue().getURI().toString());
assertEquals("POST", capt.getValue().getMethod()); assertEquals("POST", capt.getValue().getMethod());
Header catH = capt.getValue().getFirstHeader("Category"); Header catH = capt.getValue().getFirstHeader("Category");
assertNotNull(Arrays.asList(capt.getValue().getAllHeaders()).toString(), catH); assertNotNull(Arrays.asList(capt.getValue().getAllHeaders()).toString(), catH);
assertEquals("urn:happytag; label=\"This is a happy resource\"; scheme=\"http://hl7.org/fhir/tag\"", catH.getValue()); assertEquals("urn:happytag; label=\"This is a happy resource\"; scheme=\"http://hl7.org/fhir/tag\"", catH.getValue());
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.XML.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
count++; count++;
/* /*
* Try fluent options * Try fluent options
*/ */
@ -208,16 +207,16 @@ public class GenericClientTest {
client.create().resource(p1).withId("123").execute(); client.create().resource(p1).withId("123").execute();
assertEquals("http://example.com/fhir/Patient/123", capt.getAllValues().get(1).getURI().toString()); assertEquals("http://example.com/fhir/Patient/123", capt.getAllValues().get(1).getURI().toString());
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.XML.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
count++; count++;
String resourceText = "<Patient xmlns=\"http://hl7.org/fhir\"> </Patient>"; String resourceText = "<Patient xmlns=\"http://hl7.org/fhir\"> </Patient>";
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8"))); when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
client.create().resource(resourceText).withId("123").execute(); client.create().resource(resourceText).withId("123").execute();
assertEquals("http://example.com/fhir/Patient/123", capt.getAllValues().get(2).getURI().toString()); assertEquals("http://example.com/fhir/Patient/123", capt.getAllValues().get(2).getURI().toString());
assertEquals(resourceText, IOUtils.toString(((HttpPost) capt.getAllValues().get(2)).getEntity().getContent())); assertEquals(resourceText, IOUtils.toString(((HttpPost) capt.getAllValues().get(2)).getEntity().getContent()));
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.XML.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
count++; count++;
} }
@ -977,6 +976,8 @@ public class GenericClientTest {
assertEquals("http://example.com/fhir", capt.getValue().getURI().toString()); assertEquals("http://example.com/fhir", capt.getValue().getURI().toString());
assertEquals(bundle.getEntries().get(0).getId(), response.getEntries().get(0).getId()); assertEquals(bundle.getEntries().get(0).getId(), response.getEntries().get(0).getId());
assertEquals(EncodingEnum.XML.getBundleContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(0).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
} }
@Test @Test
@ -1042,25 +1043,25 @@ public class GenericClientTest {
client.update().resource(p1).execute(); client.update().resource(p1).execute();
int count = 0; int count = 0;
assertEquals(1, capt.getAllValues().size()); assertEquals(1, capt.getAllValues().size());
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.XML.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.XML.getResourceContentType()+Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
count++; count++;
MethodOutcome outcome = client.update().resource(p1).execute(); MethodOutcome outcome = client.update().resource(p1).execute();
assertEquals("44", outcome.getId().getIdPart()); assertEquals("44", outcome.getId().getIdPart());
assertEquals("22", outcome.getId().getVersionIdPart()); assertEquals("22", outcome.getId().getVersionIdPart());
assertEquals(2, capt.getAllValues().size()); assertEquals(2, capt.getAllValues().size());
assertEquals("http://example.com/fhir/Patient/44", capt.getValue().getURI().toString()); assertEquals("http://example.com/fhir/Patient/44", capt.getValue().getURI().toString());
assertEquals("PUT", capt.getValue().getMethod()); assertEquals("PUT", capt.getValue().getMethod());
Header catH = capt.getValue().getFirstHeader("Category"); Header catH = capt.getValue().getFirstHeader("Category");
assertNotNull(Arrays.asList(capt.getValue().getAllHeaders()).toString(), catH); assertNotNull(Arrays.asList(capt.getValue().getAllHeaders()).toString(), catH);
assertEquals("urn:happytag; label=\"This is a happy resource\"; scheme=\"http://hl7.org/fhir/tag\"", catH.getValue()); assertEquals("urn:happytag; label=\"This is a happy resource\"; scheme=\"http://hl7.org/fhir/tag\"", catH.getValue());
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.XML.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.XML.getResourceContentType()+Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
/* /*
* Try fluent options * Try fluent options
@ -1098,29 +1099,29 @@ public class GenericClientTest {
int count = 0; int count = 0;
client.update().resource(myCtx.newXmlParser().encodeResourceToString(p1)).withId("1").execute(); client.update().resource(myCtx.newXmlParser().encodeResourceToString(p1)).withId("1").execute();
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.XML.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
assertThat(extractBody(capt, count), containsString("value=\"John\"")); assertThat(extractBody(capt, count), containsString("value=\"John\""));
count++; count++;
client.update().resource(myCtx.newJsonParser().encodeResourceToString(p1)).withId("1").execute(); client.update().resource(myCtx.newJsonParser().encodeResourceToString(p1)).withId("1").execute();
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.JSON.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.JSON.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
assertThat(extractBody(capt, count), containsString("[\"John\"]")); assertThat(extractBody(capt, count), containsString("[\"John\"]"));
count++; count++;
/* /*
* e.g. Now try with reversed encoding (provide a string that's in JSON and ask the client to use XML) * e.g. Now try with reversed encoding (provide a string that's in JSON and ask the client to use XML)
*/ */
client.update().resource(myCtx.newXmlParser().encodeResourceToString(p1)).withId("1").encodedJson().execute(); client.update().resource(myCtx.newXmlParser().encodeResourceToString(p1)).withId("1").encodedJson().execute();
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.JSON.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.JSON.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
assertThat(extractBody(capt, count), containsString("[\"John\"]")); assertThat(extractBody(capt, count), containsString("[\"John\"]"));
count++; count++;
client.update().resource(myCtx.newJsonParser().encodeResourceToString(p1)).withId("1").encodedXml().execute(); client.update().resource(myCtx.newJsonParser().encodeResourceToString(p1)).withId("1").encodedXml().execute();
assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length); assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
assertEquals(EncodingEnum.XML.getResourceContentType(), capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()); assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
assertThat(extractBody(capt, count), containsString("value=\"John\"")); assertThat(extractBody(capt, count), containsString("value=\"John\""));
count++; count++;
} }

View File

@ -3,6 +3,8 @@ package ca.uhn.fhir.rest.server;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -72,6 +74,8 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.rest.server.provider.ServerProfileProvider; import ca.uhn.fhir.rest.server.provider.ServerProfileProvider;
import ca.uhn.fhir.util.PortUtil; import ca.uhn.fhir.util.PortUtil;
import javax.servlet.http.HttpServletRequest;
/** /**
* Created by dsotnikov on 2/25/2014. * Created by dsotnikov on 2/25/2014.
*/ */
@ -997,10 +1001,19 @@ public class RestfulServerMethodTest {
public void testServerProfileProviderFindsProfiles() { public void testServerProfileProviderFindsProfiles() {
ServerProfileProvider profileProvider = (ServerProfileProvider)ourRestfulServer.getServerProfilesProvider(); ServerProfileProvider profileProvider = (ServerProfileProvider)ourRestfulServer.getServerProfilesProvider();
IdDt id = new IdDt("Profile", "observation"); IdDt id = new IdDt("Profile", "observation");
Profile profile = profileProvider.getProfileById(id); Profile profile = profileProvider.getProfileById(createHttpServletRequest(), id);
assertNotNull(profile); assertNotNull(profile);
} }
private HttpServletRequest createHttpServletRequest() {
HttpServletRequest req = mock(HttpServletRequest.class);
when(req.getRequestURI()).thenReturn("/FhirStorm/fhir/Patient/_search");
when(req.getServletPath()).thenReturn("/fhir");
when(req.getRequestURL()).thenReturn(new StringBuffer().append("http://fhirstorm.dyndns.org:8080/FhirStorm/fhir/Patient/_search"));
when(req.getContextPath()).thenReturn("/FhirStorm");
return req;
}
@AfterClass @AfterClass
public static void afterClass() throws Exception { public static void afterClass() throws Exception {
ourServer.stop(); ourServer.stop();
@ -1013,12 +1026,14 @@ public class RestfulServerMethodTest {
ourCtx = new FhirContext(Patient.class); ourCtx = new FhirContext(Patient.class);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServerProfileProvider profProvider = new ServerProfileProvider(ourCtx);
ourReportProvider = new DummyDiagnosticReportResourceProvider(); ourReportProvider = new DummyDiagnosticReportResourceProvider();
DummyAdverseReactionResourceProvider adv = new DummyAdverseReactionResourceProvider(); DummyAdverseReactionResourceProvider adv = new DummyAdverseReactionResourceProvider();
ServletHandler proxyHandler = new ServletHandler(); ServletHandler proxyHandler = new ServletHandler();
ourRestfulServer =new DummyRestfulServer(patientProvider, profProvider, ourReportProvider, adv); DummyRestfulServer dummyServer = new DummyRestfulServer(patientProvider, ourReportProvider, adv);
ourRestfulServer = dummyServer;
ServerProfileProvider profProvider = new ServerProfileProvider(ourRestfulServer);
dummyServer.addResourceProvider(profProvider);
ServletHolder servletHolder = new ServletHolder(ourRestfulServer); ServletHolder servletHolder = new ServletHolder(ourRestfulServer);
proxyHandler.addServletWithMapping(servletHolder, "/*"); proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler); ourServer.setHandler(proxyHandler);
@ -1370,7 +1385,11 @@ public class RestfulServerMethodTest {
private Collection<IResourceProvider> myResourceProviders; private Collection<IResourceProvider> myResourceProviders;
public DummyRestfulServer(IResourceProvider... theResourceProviders) { public DummyRestfulServer(IResourceProvider... theResourceProviders) {
myResourceProviders = Arrays.asList(theResourceProviders); myResourceProviders = new ArrayList<IResourceProvider>(Arrays.asList(theResourceProviders));
}
public void addResourceProvider(IResourceProvider theResourceProvider) {
myResourceProviders.add(theResourceProvider);
} }
@Override @Override

View File

@ -106,10 +106,10 @@ public class RestfulServerSelfReferenceTest {
Server hServer = new Server(port); Server hServer = new Server(port);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServerProfileProvider profProvider = new ServerProfileProvider(ourCtx);
ServletHandler proxyHandler = new ServletHandler(); ServletHandler proxyHandler = new ServletHandler();
RestfulServer server = new RestfulServer(); RestfulServer server = new RestfulServer();
ServerProfileProvider profProvider = new ServerProfileProvider(server);
server.setFhirContext(ourCtx); server.setFhirContext(ourCtx);
server.setResourceProviders(patientProvider, profProvider); server.setResourceProviders(patientProvider, profProvider);
ServletHolder servletHolder = new ServletHolder(server); ServletHolder servletHolder = new ServletHolder(server);

View File

@ -4,6 +4,8 @@ import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -33,6 +35,9 @@ import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.param.TokenOrListParam;
import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider; import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
public class ServerConformanceProviderTest { public class ServerConformanceProviderTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerConformanceProviderTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerConformanceProviderTest.class);
@ -47,7 +52,7 @@ public class ServerConformanceProviderTest {
ServerConformanceProvider sc = new ServerConformanceProvider(rs); ServerConformanceProvider sc = new ServerConformanceProvider(rs);
rs.setServerConformanceProvider(sc); rs.setServerConformanceProvider(sc);
rs.init(null); rs.init(createServletConfig());
boolean found=false; boolean found=false;
Collection<ResourceBinding> resourceBindings = rs.getResourceBindings(); Collection<ResourceBinding> resourceBindings = rs.getResourceBindings();
@ -61,7 +66,7 @@ public class ServerConformanceProviderTest {
} }
} }
assertTrue(found); assertTrue(found);
Conformance conformance = sc.getServerConformance(); Conformance conformance = sc.getServerConformance(createHttpServletRequest());
String conf = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance); String conf = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf); ourLog.info(conf);
@ -81,9 +86,9 @@ public class ServerConformanceProviderTest {
ServerConformanceProvider sc = new ServerConformanceProvider(rs); ServerConformanceProvider sc = new ServerConformanceProvider(rs);
rs.setServerConformanceProvider(sc); rs.setServerConformanceProvider(sc);
rs.init(null); rs.init(createServletConfig());
Conformance conformance = sc.getServerConformance(); Conformance conformance = sc.getServerConformance(createHttpServletRequest());
myCtx.newValidator().validate(conformance); myCtx.newValidator().validate(conformance);
} }
@ -99,7 +104,7 @@ public class ServerConformanceProviderTest {
ServerConformanceProvider sc = new ServerConformanceProvider(rs); ServerConformanceProvider sc = new ServerConformanceProvider(rs);
rs.setServerConformanceProvider(sc); rs.setServerConformanceProvider(sc);
rs.init(null); rs.init(createServletConfig());
boolean found=false; boolean found=false;
Collection<ResourceBinding> resourceBindings = rs.getResourceBindings(); Collection<ResourceBinding> resourceBindings = rs.getResourceBindings();
@ -113,7 +118,7 @@ public class ServerConformanceProviderTest {
} }
} }
assertTrue(found); assertTrue(found);
Conformance conformance = sc.getServerConformance(); Conformance conformance = sc.getServerConformance(createHttpServletRequest());
String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance); String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf); ourLog.info(conf);
@ -131,9 +136,9 @@ public class ServerConformanceProviderTest {
ServerConformanceProvider sc = new ServerConformanceProvider(rs); ServerConformanceProvider sc = new ServerConformanceProvider(rs);
rs.setServerConformanceProvider(sc); rs.setServerConformanceProvider(sc);
rs.init(null); rs.init(createServletConfig());
Conformance conformance = sc.getServerConformance(); Conformance conformance = sc.getServerConformance(createHttpServletRequest());
String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance); String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf); ourLog.info(conf);
@ -147,8 +152,22 @@ public class ServerConformanceProviderTest {
assertEquals(1,res.getSearchInclude().size()); assertEquals(1,res.getSearchInclude().size());
assertEquals("DiagnosticReport.result", res.getSearchIncludeFirstRep().getValue()); assertEquals("DiagnosticReport.result", res.getSearchIncludeFirstRep().getValue());
} }
private HttpServletRequest createHttpServletRequest() {
HttpServletRequest req = mock(HttpServletRequest.class);
when(req.getRequestURI()).thenReturn("/FhirStorm/fhir/Patient/_search");
when(req.getServletPath()).thenReturn("/fhir");
when(req.getRequestURL()).thenReturn(new StringBuffer().append("http://fhirstorm.dyndns.org:8080/FhirStorm/fhir/Patient/_search"));
when(req.getContextPath()).thenReturn("/FhirStorm");
return req;
}
private ServletConfig createServletConfig() {
ServletConfig sc = mock(ServletConfig.class);
when (sc.getServletContext()).thenReturn(null);
return sc;
}
/** /**
* Created by dsotnikov on 2/25/2014. * Created by dsotnikov on 2/25/2014.
*/ */

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -27,12 +27,12 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</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-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.thymeleaf</groupId> <groupId>org.thymeleaf</groupId>
@ -55,7 +55,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-test</artifactId> <artifactId>hapi-fhir-jpaserver-test</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -19,7 +19,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<!-- <!--
<dependency> <dependency>

View File

@ -10,6 +10,8 @@ import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.RestfulServer;
import javax.servlet.http.HttpServletRequest;
public class FhirDstu1 implements IFhirVersion { public class FhirDstu1 implements IFhirVersion {
@Override @Override
@ -23,7 +25,7 @@ public class FhirDstu1 implements IFhirVersion {
} }
@Override @Override
public IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition) { public IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -73,7 +73,10 @@ public class ${className}ResourceProvider extends JpaResourceProvider<${classNam
Set<Include> theIncludes, Set<Include> theIncludes,
@Sort @Sort
SortSpec theSort SortSpec theSort,
@Count
Integer theCount
) { ) {
startRequest(theServletRequest); startRequest(theServletRequest);
try { try {
@ -86,7 +89,8 @@ public class ${className}ResourceProvider extends JpaResourceProvider<${classNam
paramMap.setIncludes(theIncludes); paramMap.setIncludes(theIncludes);
paramMap.setSort(theSort); paramMap.setSort(theSort);
paramMap.setCount(theCount);
ca.uhn.fhir.rest.server.IBundleProvider retVal = getDao().search(paramMap); ca.uhn.fhir.rest.server.IBundleProvider retVal = getDao().search(paramMap);
return retVal; return retVal;
} finally { } finally {

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -17,12 +17,12 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</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-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<dependency> <dependency>
@ -45,7 +45,7 @@
<plugin> <plugin>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId> <artifactId>hapi-tinder-plugin</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<executions> <executions>
<execution> <execution>
<id>custom-structs</id> <id>custom-structs</id>
@ -104,7 +104,7 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId> <artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>

View File

@ -12,7 +12,7 @@
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<name>HAPI-FHIR</name> <name>HAPI-FHIR</name>
<url>http://hl7api.sourceforge.net/hapi-fhir/</url> <url>http://hl7api.sourceforge.net/hapi-fhir/</url>
@ -677,6 +677,7 @@
<module>restful-server-example-test</module> <module>restful-server-example-test</module>
<module>hapi-fhir-testpage-overlay</module> <module>hapi-fhir-testpage-overlay</module>
<module>hapi-fhir-jpaserver-uhnfhirtest</module> <module>hapi-fhir-jpaserver-uhnfhirtest</module>
<module>hapi-fhir-dist</module>
</modules> </modules>
</profile> </profile>
</profiles> </profiles>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -17,12 +17,12 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</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-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -35,20 +35,20 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId> <artifactId>hapi-fhir-base</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<!-- At least one "structures" JAR must also be included --> <!-- At least one "structures" JAR must also be included -->
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId> <artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
</dependency> </dependency>
<!-- This dependency is used for the "FHIR Tester" web app overlay --> <!-- This dependency is used for the "FHIR Tester" web app overlay -->
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId> <artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.8</version>
<type>war</type> <type>war</type>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -6,7 +6,7 @@
<title>HAPI FHIR Changelog</title> <title>HAPI FHIR Changelog</title>
</properties> </properties>
<body> <body>
<release version="0.8" date="TBD"> <release version="0.8" date="2014-Dec-17">
<action type="add"> <action type="add">
<![CDATA[<b>API CHANGE:</b>]]> The "FHIR structures" for DSTU1 (the classes which model the <![CDATA[<b>API CHANGE:</b>]]> The "FHIR structures" for DSTU1 (the classes which model the
resources and composite datatypes) have been moved out of the core JAR into their resources and composite datatypes) have been moved out of the core JAR into their
@ -201,6 +201,12 @@
header, leading to servers incorrectly assuming ISO-8859/1. Thanks to header, leading to servers incorrectly assuming ISO-8859/1. Thanks to
shvoidlee for reporting! shvoidlee for reporting!
</action> </action>
<action type="fix" issue="59" dev="wdebeau1">
Clean up the way that Profile resources are automatically exported
by the server for custom resource profile classes. See the
<![CDATA[<a href="http://jamesagnew.github.io/hapi-fhir/apidocs/ca/uhn/fhir/model/api/annotation/ResourceDef.html">@ResourceDef</a>]]>
JavaDoc for information on how this works.
</action>
</release> </release>
<release version="0.7" date="2014-Oct-23"> <release version="0.7" date="2014-Oct-23">
<action type="add" issue="30"> <action type="add" issue="30">

View File

@ -13,20 +13,9 @@
<macro name="toc"> <macro name="toc">
</macro> </macro>
<subsection name="Tinder Plugin">
<p>
If you are using the "Tinder" Maven plugin to generate structure code,
you will need to add a structure dependency to the plugin configuration
itself in your project pom.xml. See the
<a href="./doc_tinder.html">Tinder Page</a> for an example of
how to do this.
</p>
</subsection>
</section> </section>
<section name="Upgrading to HAPI FHIR 0.5"> <section name="Upgrading to HAPI FHIR 0.8">
<p> <p>
@ -57,8 +46,9 @@
resources, or both depending on your needs. Note that using DEV resources may introduce resources, or both depending on your needs. Note that using DEV resources may introduce
incompatibilities with other frameworks however. If you are including this JAR, incompatibilities with other frameworks however. If you are including this JAR,
<b>you must also include hapi-fhir-structures-dstu-[version].jar</b>. <b>you must also include hapi-fhir-structures-dstu-[version].jar</b>.
Hopefully by the time 0.8 is final this requirement will be relaxed, but for now it We are planning on removing the requirement to include
is mandatory. the DSTU structures in your application (so you can include only the
DEV ones) for HAPI-FHIR 0.9.
</li> </li>
</ul> </ul>

View File

@ -39,6 +39,50 @@
<section name="Announcements"> <section name="Announcements">
<p>
<b>Dec 17, 2014 - HAPI FHIR 0.8 Released</b> - HAPI 0.8 has been released!
As always, thanks to everyone who contributed on this; this release includes
a lot of bug fixes and new features from around the world.
</p>
<p>
See the <a href="http://jamesagnew.github.io/hapi-fhir/changes-report.html">changelog</a>
for a complete list of what's new!
</p>
<p>
In particular, this release marks the beginning of our push to separate the model
classes (e.g. Patient, Encounter, etc.) from the core API, so that you can use any
version of the structures you want in your application, or even combine versions if
you need to. As is the case with HAPI's HL7 v2 library, you now need to include at least
one new separate "structures" JAR with your application as of HAPI-FHIR 0.8. See the
<a href="http://jamesagnew.github.io/hapi-fhir/doc_upgrading.html">Upgrading</a>
and
<a href="http://jamesagnew.github.io/hapi-fhir/download.html">Download</a>
pages for more information.
</p>
<p>
With the newly separated "structures" dependencies, we have also introduced
a separate "dev" version of the structures, which contains the current development
structure definitions, which are now close to being in their final DSTU2 state
(DSTU2 should be released in mid 2015 by HL7 although the date is not yet finalized).
DSTU2 contains a number of new and updated resource definitions, but it also makes
several infrastructure changes including a new Bundle format and a new encoding style
for extensions in JSON. These changes are not yet supported in HAPI-FHIR 0.8, but
will be included in HAPI-FHIR 0.9. We expect to deploy a working snapshot build of
HAPI-FHIR 0.9 within the next day or so, including all of these changes.
</p>
<p>
One further note: We are currently working with Grahame Grieve on an initiative
to harmonize HAPI's model objects with the FHIR Java Reference Implementation. This
means that developers should in the future be able to use either the HAPI built-in
resource definitions or the ones shipped by HL7. The advantage to this is that
it will allow users of HAPI's API to take advantage of other tooling produced
by HL7 (such as profile validators). Please get in touch (either by email or
on the Google Group) if you would like to help test this.
</p>
<p>
- <a href="mailto:jamesagnew@users.sourceforge.net">James Agnew</a>
</p>
<p> <p>
<b>Oct 23, 2014 - HAPI FHIR 0.7 Released</b> - HAPI 0.7 has been released! <b>Oct 23, 2014 - HAPI FHIR 0.7 Released</b> - HAPI 0.7 has been released!
This release contains a number of contributions and bugfixes from all over This release contains a number of contributions and bugfixes from all over
@ -68,6 +112,7 @@
- <a href="mailto:jamesagnew@users.sourceforge.net">James Agnew</a> - <a href="mailto:jamesagnew@users.sourceforge.net">James Agnew</a>
</p> </p>
<!--
<p> <p>
<b>Sep 8, 2014 - HAPI FHIR 0.6 Released</b> - A new build has been uploaded, <b>Sep 8, 2014 - HAPI FHIR 0.6 Released</b> - A new build has been uploaded,
containing a number of new features and bug fixes. See the changelog containing a number of new features and bug fixes. See the changelog
@ -104,7 +149,7 @@
<br/> <br/>
- <a href="mailto:jamesagnew@users.sourceforge.net">James Agnew</a> - <a href="mailto:jamesagnew@users.sourceforge.net">James Agnew</a>
</p> </p>
-->
</section> </section>
<section name="What is HAPI FHIR?"> <section name="What is HAPI FHIR?">