Merge remote-tracking branch 'origin/master' into hl7org_structs
This commit is contained in:
commit
463fe249e6
|
@ -223,6 +223,13 @@
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>ANDROID</id>
|
<id>ANDROID</id>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
|
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||||
|
<version>0.8-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -238,6 +245,18 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
<createDependencyReducedPom>true</createDependencyReducedPom>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<!--
|
||||||
|
<include>javax.json:javax.json-api</include>
|
||||||
|
-->
|
||||||
|
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
|
||||||
|
<include>org.glassfish:javax.json</include>
|
||||||
|
<include>org.codehaus.woodstox:woodstox-core-asl</include>
|
||||||
|
<include>javax.xml.stream:stax-api</include>
|
||||||
|
<include>org.codehaus.woodstox:stax2-api</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>javax.xml.stream</pattern>
|
<pattern>javax.xml.stream</pattern>
|
||||||
|
|
|
@ -137,7 +137,7 @@ public abstract class BaseRuntimeElementDefinition<T extends IElement> {
|
||||||
for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
|
for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
|
||||||
String extUrl = next.getExtensionUrl();
|
String extUrl = next.getExtensionUrl();
|
||||||
if (myUrlToExtension.containsKey(extUrl)) {
|
if (myUrlToExtension.containsKey(extUrl)) {
|
||||||
throw new ConfigurationException("Duplicate extension URL: " + extUrl);
|
throw new ConfigurationException("Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]");
|
||||||
} else {
|
} else {
|
||||||
myUrlToExtension.put(extUrl, next);
|
myUrlToExtension.put(extUrl, next);
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,7 +294,7 @@ class ModelScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockDefinition == null && datatypeDefinition == null && resourceDefinition == null) {
|
if (blockDefinition == null && datatypeDefinition == null && resourceDefinition == null) {
|
||||||
throw new ConfigurationException("Resource type does not contain any valid HAPI-FHIR annotations: " + theClass.getCanonicalName());
|
throw new ConfigurationException("Resource class[" + theClass.getName() + "] does not contain any valid HAPI-FHIR annotations");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,28 +102,24 @@ public abstract class BaseHumanNameDt extends BaseIdentifiableElement {
|
||||||
public String getSuffixAsSingleString() {
|
public String getSuffixAsSingleString() {
|
||||||
return ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated(getSuffix());
|
return ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated(getSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value(s) for <b>text</b> (Text representation of the full name).
|
* Gets the value(s) for <b>text</b> (Text representation of the full name). creating it if it does not exist. Will not return <code>null</code>.
|
||||||
* creating it if it does
|
|
||||||
* not exist. Will not return <code>null</code>.
|
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Definition:</b>
|
* <b>Definition:</b> A full text representation of the name
|
||||||
* A full text representation of the name
|
* </p>
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public abstract StringDt getText() ;
|
public abstract StringDt getTextElement();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value(s) for <b>text</b> (Text representation of the full name)
|
* Sets the value(s) for <b>text</b> (Text representation of the full name)
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Definition:</b>
|
* <b>Definition:</b> A full text representation of the name
|
||||||
* A full text representation of the name
|
* </p>
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public abstract BaseHumanNameDt setText(StringDt theValue);
|
public abstract BaseHumanNameDt setText(StringDt theValue);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -132,15 +128,26 @@ public abstract class BaseHumanNameDt extends BaseIdentifiableElement {
|
||||||
b.append("given", getGivenAsSingleString());
|
b.append("given", getGivenAsSingleString());
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNameAsSingleString(){
|
/**
|
||||||
|
* Returns all of the components of the name (prefix, given, family, suffix) as a
|
||||||
|
* single string with a single spaced string separating each part.
|
||||||
|
* <p>
|
||||||
|
* If none of the parts are populated, returns the {@link #getTextElement() text}
|
||||||
|
* element value instead.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public String getNameAsSingleString() {
|
||||||
List<StringDt> nameParts = new ArrayList<StringDt>();
|
List<StringDt> nameParts = new ArrayList<StringDt>();
|
||||||
nameParts.addAll(getPrefix());
|
nameParts.addAll(getPrefix());
|
||||||
nameParts.addAll(getGiven());
|
nameParts.addAll(getGiven());
|
||||||
nameParts.addAll(getFamily());
|
nameParts.addAll(getFamily());
|
||||||
nameParts.addAll(getSuffix());
|
nameParts.addAll(getSuffix());
|
||||||
if(nameParts.size() > 0) return ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated(nameParts);
|
if (nameParts.size() > 0) {
|
||||||
else return getText().getValue();
|
return ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated(nameParts);
|
||||||
|
} else {
|
||||||
|
return getTextElement().getValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||||
import ca.uhn.fhir.util.VersionUtil;
|
import ca.uhn.fhir.util.VersionUtil;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
|
@ -50,6 +51,7 @@ import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
@ -723,16 +725,19 @@ public class RestfulServer extends HttpServlet {
|
||||||
|
|
||||||
Collection<IResourceProvider> resourceProvider = getResourceProviders();
|
Collection<IResourceProvider> resourceProvider = getResourceProviders();
|
||||||
if (resourceProvider != null) {
|
if (resourceProvider != null) {
|
||||||
Map<Class<? extends IResource>, IResourceProvider> typeToProvider = new HashMap<Class<? extends IResource>, IResourceProvider>();
|
Map<String, IResourceProvider> typeToProvider = new HashMap<String, IResourceProvider>();
|
||||||
for (IResourceProvider nextProvider : resourceProvider) {
|
for (IResourceProvider nextProvider : resourceProvider) {
|
||||||
|
|
||||||
Class<? extends IResource> resourceType = nextProvider.getResourceType();
|
Class<? extends IResource> resourceType = nextProvider.getResourceType();
|
||||||
if (resourceType == null) {
|
if (resourceType == null) {
|
||||||
throw new NullPointerException("getResourceType() on class '" + nextProvider.getClass().getCanonicalName() + "' returned null");
|
throw new NullPointerException("getResourceType() on class '" + nextProvider.getClass().getCanonicalName() + "' returned null");
|
||||||
}
|
}
|
||||||
if (typeToProvider.containsKey(resourceType)) {
|
|
||||||
throw new ServletException("Multiple providers for type: " + resourceType.getCanonicalName());
|
String resourceName = myFhirContext.getResourceDefinition(resourceType).getName();
|
||||||
|
if (typeToProvider.containsKey(resourceName)) {
|
||||||
|
throw new ServletException("Multiple resource providers return resource type[" + resourceName + "]: First[" + typeToProvider.get(resourceName).getClass().getCanonicalName() + "] and Second[" + nextProvider.getClass().getCanonicalName() + "]");
|
||||||
}
|
}
|
||||||
typeToProvider.put(resourceType, nextProvider);
|
typeToProvider.put(resourceName, nextProvider);
|
||||||
providedResourceScanner.scanForProvidedResources(nextProvider);
|
providedResourceScanner.scanForProvidedResources(nextProvider);
|
||||||
}
|
}
|
||||||
ourLog.info("Got {} resource providers", typeToProvider.size());
|
ourLog.info("Got {} resource providers", typeToProvider.size());
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.*;
|
import ca.uhn.fhir.context.*;
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ import ca.uhn.fhir.rest.server.provider.ServerProfileProvider;
|
||||||
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);
|
||||||
private Map<RuntimeChildDeclaredExtensionDefinition, String> myExtensionDefToCode = new HashMap<RuntimeChildDeclaredExtensionDefinition, String>();
|
// private Map<RuntimeChildDeclaredExtensionDefinition, String> myExtensionDefToCode = new HashMap<RuntimeChildDeclaredExtensionDefinition, String>();
|
||||||
private String myId;
|
private String myId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -158,7 +159,7 @@ public class FhirDstu1 implements IFhirVersion {
|
||||||
|
|
||||||
String expectedPath = StringUtils.join(path, '.');
|
String expectedPath = StringUtils.join(path, '.');
|
||||||
|
|
||||||
ourLog.info("Filling profile for: {} - Path: {}", expectedPath);
|
ourLog.debug("Filling profile for: {} - Path: {}", expectedPath);
|
||||||
String name = def.getName();
|
String name = def.getName();
|
||||||
if (!expectedPath.equals(name)) {
|
if (!expectedPath.equals(name)) {
|
||||||
path.pollLast();
|
path.pollLast();
|
||||||
|
@ -267,11 +268,12 @@ public class FhirDstu1 implements IFhirVersion {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanForExtensions(Profile theProfile, BaseRuntimeElementDefinition<?> def) {
|
private Map<RuntimeChildDeclaredExtensionDefinition, String> scanForExtensions(Profile theProfile, BaseRuntimeElementDefinition<?> def) {
|
||||||
BaseRuntimeElementCompositeDefinition<?> cdef = ((BaseRuntimeElementCompositeDefinition<?>) def);
|
BaseRuntimeElementCompositeDefinition<?> cdef = ((BaseRuntimeElementCompositeDefinition<?>) def);
|
||||||
|
|
||||||
|
Map<RuntimeChildDeclaredExtensionDefinition, String> extensionDefToCode = new HashMap<RuntimeChildDeclaredExtensionDefinition, String>();
|
||||||
for (RuntimeChildDeclaredExtensionDefinition nextChild : cdef.getExtensions()) {
|
for (RuntimeChildDeclaredExtensionDefinition nextChild : cdef.getExtensions()) {
|
||||||
if (myExtensionDefToCode.containsKey(nextChild)) {
|
if (extensionDefToCode.containsKey(nextChild)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,10 +290,10 @@ public class FhirDstu1 implements IFhirVersion {
|
||||||
}
|
}
|
||||||
|
|
||||||
defn.setCode(code);
|
defn.setCode(code);
|
||||||
if (myExtensionDefToCode.values().contains(code)) {
|
if (extensionDefToCode.values().contains(code)) {
|
||||||
throw new IllegalStateException("Duplicate extension code: " + code);
|
throw new IllegalStateException("Duplicate extension code: " + code);
|
||||||
}
|
}
|
||||||
myExtensionDefToCode.put(nextChild, code);
|
extensionDefToCode.put(nextChild, code);
|
||||||
|
|
||||||
if (nextChild.getChildType() != null && IPrimitiveDatatype.class.isAssignableFrom(nextChild.getChildType())) {
|
if (nextChild.getChildType() != null && IPrimitiveDatatype.class.isAssignableFrom(nextChild.getChildType())) {
|
||||||
RuntimePrimitiveDatatypeDefinition pdef = (RuntimePrimitiveDatatypeDefinition) nextChild.getSingleChildOrThrow();
|
RuntimePrimitiveDatatypeDefinition pdef = (RuntimePrimitiveDatatypeDefinition) nextChild.getSingleChildOrThrow();
|
||||||
|
@ -306,11 +308,13 @@ public class FhirDstu1 implements IFhirVersion {
|
||||||
for (RuntimeChildDeclaredExtensionDefinition nextChildExt : pdef.getExtensions()) {
|
for (RuntimeChildDeclaredExtensionDefinition nextChildExt : pdef.getExtensions()) {
|
||||||
StructureElementDefinitionType type = defn.getDefinition().addType();
|
StructureElementDefinitionType type = defn.getDefinition().addType();
|
||||||
type.setCode(DataTypeEnum.EXTENSION);
|
type.setCode(DataTypeEnum.EXTENSION);
|
||||||
type.setProfile("#" + myExtensionDefToCode.get(nextChildExt));
|
type.setProfile("#" + extensionDefToCode.get(nextChildExt));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return extensionDefToCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Extension;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.ProvidesResources;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
|
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||||
|
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
|
import ca.uhn.fhir.model.dstu.resource.Profile;
|
||||||
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Bill de Beaubien on 12/10/2014.
|
||||||
|
*/
|
||||||
|
public class DuplicateExtensionTest extends TestCase {
|
||||||
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DuplicateExtensionTest.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testScannerShouldAddProvidedResources() {
|
||||||
|
FhirContext ctx = new FhirContext();
|
||||||
|
RuntimeResourceDefinition patientDef = ctx.getResourceDefinition(CustomPatient.class);
|
||||||
|
Profile profile = (Profile) patientDef.toProfile();
|
||||||
|
|
||||||
|
String res = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(profile);
|
||||||
|
ourLog.info(res);
|
||||||
|
|
||||||
|
RuntimeResourceDefinition observationDef = ctx.getResourceDefinition(CustomObservation.class);
|
||||||
|
profile = (Profile) observationDef.toProfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResourceDef(name = "Observation", id = "CustomObservation")
|
||||||
|
class CustomObservation extends Observation {
|
||||||
|
@Child(name = "idExt", order = 0)
|
||||||
|
@Extension(url = "http://foo.org#id", definedLocally = true, isModifier = false)
|
||||||
|
@Description(shortDefinition = "Contains the id of the resource")
|
||||||
|
private StringDt myIdExt;
|
||||||
|
|
||||||
|
public StringDt getIdExt() {
|
||||||
|
if (myIdExt == null) {
|
||||||
|
myIdExt = new StringDt();
|
||||||
|
}
|
||||||
|
return myIdExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdExt(StringDt theIdExt) {
|
||||||
|
myIdExt = theIdExt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ProvidesResources(resources = CustomObservation.class)
|
||||||
|
class CustomObservationProvider {
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResourceDef(name = "Patient", id = "CustomPatient")
|
||||||
|
class CustomPatient extends Patient {
|
||||||
|
@Child(name = "idExt", order = 0)
|
||||||
|
@Extension(url = "http://foo.org#id", definedLocally = true, isModifier = false)
|
||||||
|
@Description(shortDefinition = "Contains the id of the resource")
|
||||||
|
private StringDt myIdExt;
|
||||||
|
|
||||||
|
public StringDt getIdExt() {
|
||||||
|
if (myIdExt == null) {
|
||||||
|
myIdExt = new StringDt();
|
||||||
|
}
|
||||||
|
return myIdExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdExt(StringDt theIdExt) {
|
||||||
|
myIdExt = theIdExt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ProvidesResources(resources = CustomPatient.class)
|
||||||
|
class CustomPatientProvider {
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package ca.uhn.fhir.rest.server;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
|
@ -10,8 +11,13 @@ import org.hamcrest.core.StringContains;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseResource;
|
import ca.uhn.fhir.model.api.BaseResource;
|
||||||
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||||
|
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
|
||||||
|
import ca.uhn.fhir.model.dstu.composite.NarrativeDt;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
|
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||||
import ca.uhn.fhir.rest.annotation.Read;
|
import ca.uhn.fhir.rest.annotation.Read;
|
||||||
|
@ -62,6 +68,21 @@ public class ServerInvalidDefinitionTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMultipleResourceProviderForSameType() {
|
||||||
|
RestfulServer srv = new RestfulServer();
|
||||||
|
srv.setResourceProviders(new PatientResourceProvider1(), new PatientResourceProvider2());
|
||||||
|
|
||||||
|
try {
|
||||||
|
srv.init();
|
||||||
|
fail();
|
||||||
|
} catch (ServletException e) {
|
||||||
|
assertThat(e.getCause().toString(), StringContains.containsString("[Patient]"));
|
||||||
|
assertThat(e.getCause().toString(), StringContains.containsString("PatientResourceProvider1]"));
|
||||||
|
assertThat(e.getCause().toString(), StringContains.containsString("PatientResourceProvider2]"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchWithId() {
|
public void testSearchWithId() {
|
||||||
RestfulServer srv = new RestfulServer();
|
RestfulServer srv = new RestfulServer();
|
||||||
|
@ -76,6 +97,19 @@ public class ServerInvalidDefinitionTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProviderWithNonResourceType() {
|
||||||
|
RestfulServer srv = new RestfulServer();
|
||||||
|
srv.setResourceProviders(new ProviderWithNonResourceType());
|
||||||
|
|
||||||
|
try {
|
||||||
|
srv.init();
|
||||||
|
fail();
|
||||||
|
} catch (ServletException e) {
|
||||||
|
assertThat(e.getCause().toString(), StringContains.containsString("ConfigurationException"));
|
||||||
|
assertThat(e.getCause().toString(), StringContains.containsString("does not contain any valid HAPI-FHIR annotations"));
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Normal, should initialize properly
|
* Normal, should initialize properly
|
||||||
*/
|
*/
|
||||||
|
@ -127,6 +161,74 @@ public class ServerInvalidDefinitionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class ProviderWithNonResourceType implements IResourceProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends IResource> getResourceType() {
|
||||||
|
return new IResource() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setResourceMetadata(Map<ResourceMetadataKeyEnum<?>, Object> theMap) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLanguage(CodeDt theLanguage) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setId(IdDt theId) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NarrativeDt getText() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResourceName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<ResourceMetadataKeyEnum<?>, Object> getResourceMetadata() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodeDt getLanguage() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IdDt getId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContainedDt getContained() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.getClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Search
|
||||||
|
public List<Patient> read(@IdParam IdDt theId, @RequiredParam(name = "aaa") StringParam theParam) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class InvalidSpecialParameterNameResourceProvider implements IResourceProvider {
|
public static class InvalidSpecialParameterNameResourceProvider implements IResourceProvider {
|
||||||
|
|
||||||
|
@ -156,4 +258,32 @@ public class ServerInvalidDefinitionTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class PatientResourceProvider1 implements IResourceProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Patient> getResourceType() {
|
||||||
|
return Patient.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Read
|
||||||
|
public Patient read(@IdParam IdDt theId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PatientResourceProvider2 implements IResourceProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Patient> getResourceType() {
|
||||||
|
return Patient.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Read
|
||||||
|
public Patient read(@IdParam IdDt theId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/bin/
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>hapi-fhir-structures-hl7org-dev</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -566,6 +566,11 @@ public class HumanNameDt
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StringDt getTextElement() {
|
||||||
|
return getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
5
pom.xml
5
pom.xml
|
@ -114,6 +114,11 @@
|
||||||
<name>Tahura Chaudhry</name>
|
<name>Tahura Chaudhry</name>
|
||||||
<organization>University Health Network</organization>
|
<organization>University Health Network</organization>
|
||||||
</developer>
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<id>b.debeaubien</id>
|
||||||
|
<name>Bill de Beaubien</name>
|
||||||
|
<organization>Systems Made Simple</organization>
|
||||||
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
|
|
|
@ -9,7 +9,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=**/**&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&includes=**/**&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=**/**&excludes=META-INF/MANIFEST.MF">
|
<dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&excludes=META-INF/MANIFEST.MF">
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class MyOrganization extends Organization {
|
||||||
* of this file.
|
* of this file.
|
||||||
*/
|
*/
|
||||||
@Description(shortDefinition="Contains emergency contact details")
|
@Description(shortDefinition="Contains emergency contact details")
|
||||||
@Extension(url = "http://foo#billingCode", isModifier = false, definedLocally = true)
|
@Extension(url = "http://foo#emergencyContact", isModifier = false, definedLocally = true)
|
||||||
@Child(name = "emergencyContact", min=0, max=Child.MAX_UNLIMITED)
|
@Child(name = "emergencyContact", min=0, max=Child.MAX_UNLIMITED)
|
||||||
private List<EmergencyContact> myEmergencyContact;
|
private List<EmergencyContact> myEmergencyContact;
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,11 @@
|
||||||
Encoding a Binary resource without a content type set should not result in a NullPointerException. Thanks
|
Encoding a Binary resource without a content type set should not result in a NullPointerException. Thanks
|
||||||
to Alexander Kley for reporting!
|
to Alexander Kley for reporting!
|
||||||
</action>
|
</action>
|
||||||
</release>
|
<action type="add">
|
||||||
|
Server gives a more helpful error message if multiple IResourceProvider implementations
|
||||||
|
are provided for the same resource type. Thanks to wanghaisheng for the idea!
|
||||||
|
</action>
|
||||||
|
</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">
|
||||||
<![CDATA[<b>API CHANGE:</b>]]> The TagList class previously implemented ArrayList semantics,
|
<![CDATA[<b>API CHANGE:</b>]]> The TagList class previously implemented ArrayList semantics,
|
||||||
|
|
Loading…
Reference in New Issue