Work on JPA example

This commit is contained in:
James Agnew 2015-02-03 17:53:22 -05:00
parent 309ba79c6f
commit a474870a1e
10 changed files with 86 additions and 16 deletions

View File

@ -109,7 +109,7 @@ public class FhirContext {
private FhirContext(FhirVersionEnum theVersion, Collection<Class<? extends IBaseResource>> theResourceTypes) {
if (theVersion != null) {
if (!theVersion.isPresentOnClasspath()) {
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructuresForSpecifiedVersion"));
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructuresForSpecifiedVersion", theVersion.name()));
}
myVersion = theVersion.getVersionImplementation();
} else if (FhirVersionEnum.DSTU1.isPresentOnClasspath()) {

View File

@ -36,7 +36,7 @@ public enum FhirVersionEnum {
DSTU1("ca.uhn.fhir.model.dstu.FhirDstu1", null),
DSTU2("ca.uhn.fhir.model.dstu.FhirDev", null),
DSTU2("ca.uhn.fhir.model.dev.FhirDev", null),
DEV("ca.uhn.fhir.model.dev.FhirDev", DSTU2);

View File

@ -22,7 +22,10 @@ package ca.uhn.fhir.model.api;
import static org.apache.commons.lang3.StringUtils.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
@ -78,6 +81,28 @@ public abstract class ResourceMetadataKeyEnum<T> {
}
};
/**
* The value for this key represents a {@link List} of profile IDs that this
* resource claims to conform to.
*
* <p>
* Values for this key are of type <b>List&lt;IdDt&gt;</b>. Note that the returned list is
* <i>unmodifiable</i>, so you need to create a new list and call <code>put</code> to
* change its value.
* </p>
*/
public static final ResourceMetadataKeyEnum<List<IdDt>> PROFILES = new ResourceMetadataKeyEnum<List<IdDt>>("PROFILES") {
@Override
public List<IdDt> get(IResource theResource) {
return getIdListFromMetadataOrNullIfNone(theResource.getResourceMetadata(), PROFILES);
}
@Override
public void put(IResource theResource, List<IdDt> theObject) {
theResource.getResourceMetadata().put(PROFILES, theObject);
}
};
/**
* The value for this key represents a previous ID used to identify this resource. This key is currently only used internally during transaction method processing.
* <p>
@ -361,7 +386,31 @@ public abstract class ResourceMetadataKeyEnum<T> {
}
private static IdDt getIdFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<?> theKey) {
return toId(theKey, theResourceMetadata.get(theKey));
}
private static List<IdDt> getIdListFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<?> theKey) {
Object retValObj = theResourceMetadata.get(theKey);
if (retValObj instanceof List) {
List<?> retValList = (List<?>)retValObj;
for (Object next : retValList) {
if (!(next instanceof IdDt)) {
List<IdDt> retVal = new ArrayList<IdDt>();
for (Object nextVal : retValList) {
retVal.add(toId(theKey, nextVal));
}
return Collections.unmodifiableList(retVal);
}
}
@SuppressWarnings("unchecked")
List<IdDt> retVal = (List<IdDt>) retValList;
return Collections.unmodifiableList(retVal);
} else {
return Collections.singletonList(toId(theKey, retValObj));
}
}
private static IdDt toId(ResourceMetadataKeyEnum<?> theKey, Object retValObj) {
if (retValObj == null) {
return null;
} else if (retValObj instanceof String) {

View File

@ -4,9 +4,9 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<artifactId>hapi-deployable-pom</artifactId>
<version>0.9-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
<repositories>
@ -20,10 +20,6 @@
</releases>
<url>https://maven.java.net/service/local/repositories/snapshots/content/</url>
</repository>
<!-- <repository> <id>UOM</id> <url>https://github.com/unitsofmeasurement/repository</url>
<releases> <enabled>true</enabled> </releases> </repository> <repository>
<id>maven-geotoolkit.org</id> <name>GeoToolkit Repository for Maven</name>
<url>http://maven.geotoolkit.org/</url> </repository> -->
</repositories>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
@ -253,7 +249,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<skip>true</skip>
<skipDeploy>true</skipDeploy>
</configuration>
</plugin>
@ -391,6 +386,16 @@
</resources>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>${maven_jxr_plugin_version}</version>
</plugin>
</plugins>
</reporting>
<profiles>
<profile>
<id>JENKINS</id>

View File

@ -12,7 +12,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>

View File

@ -21,12 +21,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>

View File

@ -165,7 +165,7 @@
<!--
Tells Maven to name the generated WAR file as
restful-server-example.war
hapi-fhir-jpaserver-example.war
-->
<finalName>hapi-fhir-jpaserver-example</finalName>
@ -180,6 +180,11 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.1.1.v20140108</version>
<configuration>
<webApp>
<contextPath>/hapi-fhir-jpaserver-example</contextPath>
</webApp>
</configuration>
</plugin>
</plugins>
</pluginManagement>

View File

@ -61,9 +61,11 @@ public class JpaServerDemo extends RestfulServer {
/*
* This tells the server to use "incorrect" MIME types if it detects that the request is coming from a browser
* in the hopes that the browser won't just treat the content as a binary payload and try to download it (which
* is what generally happens if you load a FHIR URL in a browser)
* This tells the server to use "incorrect" MIME types if it detects
* that the request is coming from a browser in the hopes that the
* browser won't just treat the content as a binary payload and try
* to download it (which is what generally happens if you load a
* FHIR URL in a browser)
*/
setUseBrowserFriendlyContentTypes(true);

View File

@ -340,6 +340,7 @@ public class Controller {
switch (theRequest.getFhirVersion(myConfig)) {
case DEV:
case DSTU2:
haveSearchParams = extractSearchParamsDev(conformance, resourceName, includes, sortParams, queries, haveSearchParams, queryIncludes);
break;
case DSTU1:

View File

@ -164,6 +164,7 @@
<logback_version>1.1.2</logback_version>
<maven_assembly_plugin_version>2.4.1</maven_assembly_plugin_version>
<maven_javadoc_plugin_version>2.10.1</maven_javadoc_plugin_version>
<maven_jxr_plugin_version>2.5</maven_jxr_plugin_version>
<maven_license_plugin_version>1.7</maven_license_plugin_version>
<maven_surefire_plugin_version>2.18.1</maven_surefire_plugin_version>
<maven_site_plugin_version>3.4</maven_site_plugin_version>
@ -357,6 +358,12 @@
<copy todir="target/site/apidocs-dev">
<fileset dir="hapi-fhir-structures-dev/target/site/apidocs"/>
</copy>
<copy todir="target/site/apidocs-jpaserver">
<fileset dir="hapi-fhir-jpaserver-base/target/site/apidocs"/>
</copy>
<copy todir="target/site/xref-jpaserver">
<fileset dir="hapi-fhir-jpaserver-base/target/site/xref"/>
</copy>
</target>
</configuration>
</execution>
@ -672,6 +679,7 @@
<module>hapi-fhir-base</module>
<module>hapi-fhir-structures-dstu</module>
<module>hapi-fhir-structures-dev</module>
<module>hapi-fhir-jpaserver-base</module>
<module>examples</module>
</modules>
</profile>