More work on structs
This commit is contained in:
parent
496333b5e0
commit
05cccdb6e5
|
@ -3,7 +3,7 @@ package example;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
|
|
|
@ -3,7 +3,7 @@ package example;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
|
|
@ -2,7 +2,7 @@ package example;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.io.FileReader;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
public abstract class BaseRuntimeChildDefinition {
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseEnumFactory;
|
||||
|
||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||
|
|
|
@ -30,8 +30,8 @@ import java.util.Map;
|
|||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.i18n.HapiLocalizer;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
|
|
|
@ -48,18 +48,18 @@ import java.util.Set;
|
|||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IRiResource;
|
||||
import org.hl7.fhir.instance.model.api.IBackboneElement;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IRefImplResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseEnumFactory;
|
||||
import org.hl7.fhir.instance.model.api.IBaseEnumeration;
|
||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||
import org.hl7.fhir.instance.model.api.IBaseXhtml;
|
||||
import org.hl7.fhir.instance.model.api.IDatatypeElement;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.INarrative;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
|
@ -304,7 +304,7 @@ class ModelScanner {
|
|||
Block blockDefinition = pullAnnotation(theClass, Block.class);
|
||||
|
||||
if (blockDefinition != null) {
|
||||
if (IResourceBlock.class.isAssignableFrom(theClass) || IBackboneElement.class.isAssignableFrom(theClass) || IDatatypeElement.class.isAssignableFrom(theClass)) {
|
||||
if (IResourceBlock.class.isAssignableFrom(theClass) || IBaseBackboneElement.class.isAssignableFrom(theClass) || IBaseDatatypeElement.class.isAssignableFrom(theClass)) {
|
||||
scanBlock(theClass);
|
||||
} else {
|
||||
throw new ConfigurationException("Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||
|
@ -510,7 +510,7 @@ class ModelScanner {
|
|||
RuntimeChildContainedResources def = new RuntimeChildContainedResources(next, childAnnotation, descriptionAnnotation, elementName);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (IRiResource.class.isAssignableFrom(nextElementType) || IResource.class.equals(nextElementType)) {
|
||||
} else if (IRefImplResource.class.isAssignableFrom(nextElementType) || IResource.class.equals(nextElementType)) {
|
||||
/*
|
||||
* Child is a resource as a direct child, as in Bundle.entry.resource
|
||||
*/
|
||||
|
@ -571,7 +571,7 @@ class ModelScanner {
|
|||
RuntimeChildResourceDefinition def = new RuntimeChildResourceDefinition(next, elementName, childAnnotation, descriptionAnnotation, refTypesList);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (IResourceBlock.class.isAssignableFrom(nextElementType) || IBackboneElement.class.isAssignableFrom(nextElementType) || IDatatypeElement.class.isAssignableFrom(nextElementType)) {
|
||||
} else if (IResourceBlock.class.isAssignableFrom(nextElementType) || IBaseBackboneElement.class.isAssignableFrom(nextElementType) || IBaseDatatypeElement.class.isAssignableFrom(nextElementType)) {
|
||||
/*
|
||||
* Child is a resource block (i.e. a sub-tag within a resource) TODO: do these have a better name
|
||||
* according to HL7?
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Comparator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -30,9 +30,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseEnumeration;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseEnumFactory;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -29,9 +29,9 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
|
|
|
@ -28,8 +28,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.api.ICompositeType;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
/**
|
||||
* HL7org structures use a List for contained instead of a distinct datatype
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
public class RuntimeElementDirectResource extends BaseRuntimeElementDefinition<IBaseResource> {
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.ICompositeType;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseXhtml;
|
||||
|
||||
public class RuntimePrimitiveDatatypeXhtmlHl7OrgDefinition extends BaseRuntimeElementDefinition<IBaseXhtml> {
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
public class RuntimeResourceBlockDefinition extends BaseRuntimeElementCompositeDefinition<IBase> {
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IRiResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IRefImplResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
@ -58,7 +58,7 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
|
||||
try {
|
||||
IBaseResource instance = theClass.newInstance();
|
||||
if (instance instanceof IRiResource) {
|
||||
if (instance instanceof IRefImplResource) {
|
||||
myStructureVersion = FhirVersionEnum.DSTU2_HL7ORG;
|
||||
} else {
|
||||
myStructureVersion = ((IResource)instance).getStructureFhirVersionEnum();
|
||||
|
|
|
@ -24,9 +24,9 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IRiResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IRefImplResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
|
@ -56,7 +56,7 @@ public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefini
|
|||
void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myResourceTypeToDefinition = new HashMap<Class<? extends IBaseResource>, RuntimeResourceDefinition>();
|
||||
for (Class<? extends IBaseResource> next : myResourceTypes) {
|
||||
if (next.equals(IResource.class) || next.equals(IRiResource.class) || next.equals(IBaseResource.class)) {
|
||||
if (next.equals(IResource.class) || next.equals(IRefImplResource.class) || next.equals(IBaseResource.class)) {
|
||||
continue;
|
||||
}
|
||||
RuntimeResourceDefinition definition = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next);
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.model.api;
|
|||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
|
|
|
@ -32,7 +32,7 @@ import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
|||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
|
||||
@DatatypeDef(name = "Extension")
|
||||
public class ExtensionDt extends BaseIdentifiableElement implements ICompositeDatatype, IBaseExtension<ExtensionDt> {
|
||||
public class ExtensionDt extends BaseIdentifiableElement implements ICompositeDatatype, IBaseExtension<ExtensionDt, IDatatype> {
|
||||
|
||||
private boolean myModifier;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.api.ICompositeType;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
|
|
@ -22,8 +22,8 @@ package ca.uhn.fhir.model.api;
|
|||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ import java.util.Arrays;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
/**
|
||||
* This interface is the parent interface for all FHIR Resource definition
|
||||
* classes. Classes implementing this interface should be annotated
|
||||
|
@ -42,11 +44,10 @@ import java.util.Set;
|
|||
* should not need to implement it directly.
|
||||
* </p>
|
||||
*/
|
||||
public interface IResource extends ICompositeElement, org.hl7.fhir.instance.model.IBaseResource {
|
||||
public interface IResource extends ICompositeElement, org.hl7.fhir.instance.model.api.IBaseResource {
|
||||
public static final Include INCLUDE_ALL = new Include("*");
|
||||
public static final Set<Include> WILDCARD_ALL_SET = new HashSet<Include>(Arrays.asList(INCLUDE_ALL));
|
||||
|
||||
|
||||
/**
|
||||
* Returns the contained resource list for this resource.
|
||||
* <p>
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.LinkedHashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
/**
|
||||
* A collection of tags present on a single resource. TagList is backed by a {@link LinkedHashSet}, so the order of added tags will be consistent, but duplicates will not be preserved.
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
@Target(value=ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
@ -27,9 +27,9 @@ import org.apache.http.HttpResponse;
|
|||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IRiResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IRefImplResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||
|
@ -546,8 +546,8 @@ public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
|||
throw new NullPointerException("theResource can not be null");
|
||||
} else if (theResouce instanceof IResource) {
|
||||
((IResource) theResouce).setId(new IdDt(getValue()));
|
||||
} else if (theResouce instanceof IRiResource) {
|
||||
((IRiResource) theResouce).setId(getValue());
|
||||
} else if (theResouce instanceof IRefImplResource) {
|
||||
((IRefImplResource) theResouce).setId(getValue());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown resource class type, does not implement IResource or extend Resource");
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ package ca.uhn.fhir.model.view;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||
|
|
|
@ -36,7 +36,7 @@ import java.util.Properties;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.io.input.ReaderInputStream;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.thymeleaf.Arguments;
|
||||
import org.thymeleaf.Configuration;
|
||||
import org.thymeleaf.TemplateEngine;
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.narrative;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.base.composite.BaseNarrativeDt;
|
||||
|
|
|
@ -37,10 +37,10 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IRiResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IRefImplResource;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
|
@ -94,8 +94,8 @@ public abstract class BaseParser implements IParser {
|
|||
}
|
||||
}
|
||||
} else if (theTarget instanceof IDomainResource) {
|
||||
List<? extends IRiResource> containedResources = ((IDomainResource) theTarget).getContained();
|
||||
for (IRiResource next : containedResources) {
|
||||
List<? extends IRefImplResource> containedResources = ((IDomainResource) theTarget).getContained();
|
||||
for (IRefImplResource next : containedResources) {
|
||||
String nextId = next.getId().getValue();
|
||||
if (StringUtils.isNotBlank(nextId)) {
|
||||
if (!nextId.startsWith("#")) {
|
||||
|
@ -124,11 +124,11 @@ public abstract class BaseParser implements IParser {
|
|||
}
|
||||
|
||||
containResourcesForEncoding(theContained, resource, theTarget);
|
||||
} else if (next.getReference().isLocal()) {
|
||||
} else if (next.getReferenceElement().isLocal()) {
|
||||
if (existingIdToContainedResource != null) {
|
||||
IBaseResource potentialTarget = existingIdToContainedResource.remove(next.getReference().getValue());
|
||||
IBaseResource potentialTarget = existingIdToContainedResource.remove(next.getReferenceElement().getValue());
|
||||
if (potentialTarget != null) {
|
||||
theContained.addContained(next.getReference(), potentialTarget);
|
||||
theContained.addContained(next.getReferenceElement(), potentialTarget);
|
||||
containResourcesForEncoding(theContained, potentialTarget, theTarget);
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public abstract class BaseParser implements IParser {
|
|||
}
|
||||
|
||||
protected String determineReferenceText(IBaseReference theRef) {
|
||||
IIdType ref = theRef.getReference();
|
||||
IIdType ref = theRef.getReferenceElement();
|
||||
if (isBlank(ref.getIdPart())) {
|
||||
String reference = ref.getValue();
|
||||
if (theRef.getResource() != null) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.io.IOException;
|
|||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
|
|
|
@ -51,10 +51,10 @@ import javax.json.stream.JsonParsingException;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IRiResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IRefImplResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBooleanDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
|
@ -143,7 +143,7 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
myContext = theContext;
|
||||
}
|
||||
|
||||
private void addToHeldExtensions(int valueIdx, List<? extends IBaseExtension<?>> ext, ArrayList<ArrayList<HeldExtension>> list, boolean theIsModifier) {
|
||||
private void addToHeldExtensions(int valueIdx, List<? extends IBaseExtension<?, ?>> ext, ArrayList<ArrayList<HeldExtension>> list, boolean theIsModifier) {
|
||||
if (ext.size() > 0) {
|
||||
list.ensureCapacity(valueIdx);
|
||||
while (list.size() <= valueIdx) {
|
||||
|
@ -152,7 +152,7 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
if (list.get(valueIdx) == null) {
|
||||
list.set(valueIdx, new ArrayList<JsonParser.HeldExtension>());
|
||||
}
|
||||
for (IBaseExtension<?> next : ext) {
|
||||
for (IBaseExtension<?, ?> next : ext) {
|
||||
list.get(valueIdx).add(new HeldExtension(next, theIsModifier));
|
||||
}
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
theWriter.writeStartObject();
|
||||
}
|
||||
if (theNextValue instanceof IBaseExtension) {
|
||||
theWriter.write("url", ((IBaseExtension<?>) theNextValue).getUrl());
|
||||
theWriter.write("url", ((IBaseExtension<?, ?>) theNextValue).getUrl());
|
||||
}
|
||||
encodeCompositeElementToStreamWriter(theResDef, theResource, theNextValue, theWriter, childCompositeDef, theContainedResource);
|
||||
theWriter.writeEnd();
|
||||
|
@ -596,12 +596,12 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
} else {
|
||||
if (nextValue instanceof IBaseHasExtensions) {
|
||||
IBaseHasExtensions element = (IBaseHasExtensions) nextValue;
|
||||
List<? extends IBaseExtension<?>> ext = element.getExtension();
|
||||
List<? extends IBaseExtension<?, ?>> ext = element.getExtension();
|
||||
addToHeldExtensions(valueIdx, ext, extensions, false);
|
||||
}
|
||||
if (nextValue instanceof IBaseHasModifierExtensions) {
|
||||
IBaseHasModifierExtensions element = (IBaseHasModifierExtensions) nextValue;
|
||||
List<? extends IBaseExtension<?>> ext = element.getModifierExtension();
|
||||
List<? extends IBaseExtension<?, ?>> ext = element.getModifierExtension();
|
||||
addToHeldExtensions(valueIdx, ext, extensions, true);
|
||||
}
|
||||
}
|
||||
|
@ -676,8 +676,8 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
resourceId = res.getId().getIdPart();
|
||||
}
|
||||
}
|
||||
} else if (theResource instanceof IRiResource) {
|
||||
IRiResource res = (IRiResource) theResource;
|
||||
} else if (theResource instanceof IRefImplResource) {
|
||||
IRefImplResource res = (IRefImplResource) theResource;
|
||||
if (/*theContainedResource && */ StringUtils.isNotBlank(res.getId().getIdPart())) {
|
||||
resourceId = res.getId().getIdPart();
|
||||
}
|
||||
|
@ -876,8 +876,8 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
} else {
|
||||
if (theElement instanceof IBaseHasExtensions) {
|
||||
IBaseHasExtensions element = (IBaseHasExtensions) theElement;
|
||||
List<? extends IBaseExtension<?>> ext = element.getExtension();
|
||||
for (IBaseExtension<?> next : ext) {
|
||||
List<? extends IBaseExtension<?, ?>> ext = element.getExtension();
|
||||
for (IBaseExtension<?, ?> next : ext) {
|
||||
if (next == null || (ElementUtil.isEmpty(next.getValue()) && next.getExtension().isEmpty())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -886,8 +886,8 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
}
|
||||
if (theElement instanceof IBaseHasModifierExtensions) {
|
||||
IBaseHasModifierExtensions element = (IBaseHasModifierExtensions) theElement;
|
||||
List<? extends IBaseExtension<?>> ext = element.getModifierExtension();
|
||||
for (IBaseExtension<?> next : ext) {
|
||||
List<? extends IBaseExtension<?, ?>> ext = element.getModifierExtension();
|
||||
for (IBaseExtension<?, ?> next : ext) {
|
||||
if (next == null || next.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1384,11 +1384,11 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
private class HeldExtension implements Comparable<HeldExtension> {
|
||||
|
||||
private RuntimeChildDeclaredExtensionDefinition myDef;
|
||||
private IBaseExtension<?> myUndeclaredExtension;
|
||||
private IBaseExtension<?, ?> myUndeclaredExtension;
|
||||
private IBase myValue;
|
||||
private boolean myModifier;
|
||||
|
||||
public HeldExtension(IBaseExtension<?> theUndeclaredExtension, boolean theModifier) {
|
||||
public HeldExtension(IBaseExtension<?, ?> theUndeclaredExtension, boolean theModifier) {
|
||||
assert theUndeclaredExtension != null;
|
||||
myUndeclaredExtension = theUndeclaredExtension;
|
||||
myModifier = theModifier;
|
||||
|
@ -1420,7 +1420,7 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
}
|
||||
}
|
||||
|
||||
private void writeUndeclaredExtInDstu1Format(RuntimeResourceDefinition theResDef, IBaseResource theResource, JsonGenerator theEventWriter, IBaseExtension<?> ext) throws IOException {
|
||||
private void writeUndeclaredExtInDstu1Format(RuntimeResourceDefinition theResDef, IBaseResource theResource, JsonGenerator theEventWriter, IBaseExtension<?, ?> ext) throws IOException {
|
||||
IBaseDatatype value = ext.getValue();
|
||||
String extensionUrl = ext.getUrl();
|
||||
|
||||
|
@ -1439,7 +1439,7 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
}
|
||||
|
||||
for (Object next : ext.getExtension()) {
|
||||
writeUndeclaredExtInDstu1Format(theResDef, theResource, theEventWriter, (IBaseExtension<?>) next);
|
||||
writeUndeclaredExtInDstu1Format(theResDef, theResource, theEventWriter, (IBaseExtension<?, ?>) next);
|
||||
}
|
||||
theEventWriter.writeEnd();
|
||||
} else {
|
||||
|
|
|
@ -32,18 +32,18 @@ import javax.xml.stream.events.XMLEvent;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.hl7.fhir.instance.model.api.IBaseElement;
|
||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||
import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseXhtml;
|
||||
import org.hl7.fhir.instance.model.api.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition.IMutator;
|
||||
|
@ -821,7 +821,7 @@ class ParserState<T> {
|
|||
} else {
|
||||
if (theIsModifier == false) {
|
||||
if (getCurrentElement() instanceof IBaseHasExtensions) {
|
||||
IBaseExtension<?> ext = ((IBaseHasExtensions) getCurrentElement()).addExtension();
|
||||
IBaseExtension<?, ?> ext = ((IBaseHasExtensions) getCurrentElement()).addExtension();
|
||||
ext.setUrl(theUrlAttr);
|
||||
ParserState<T>.ExtensionState newState = new ExtensionState(myPreResourceState, ext);
|
||||
push(newState);
|
||||
|
@ -830,7 +830,7 @@ class ParserState<T> {
|
|||
}
|
||||
} else {
|
||||
if (getCurrentElement() instanceof IBaseHasModifierExtensions) {
|
||||
IBaseExtension<?> ext = ((IBaseHasModifierExtensions) getCurrentElement()).addModifierExtension();
|
||||
IBaseExtension<?, ?> ext = ((IBaseHasModifierExtensions) getCurrentElement()).addModifierExtension();
|
||||
ext.setUrl(theUrlAttr);
|
||||
ParserState<T>.ExtensionState newState = new ExtensionState(myPreResourceState, ext);
|
||||
push(newState);
|
||||
|
@ -1657,9 +1657,9 @@ class ParserState<T> {
|
|||
|
||||
private class ExtensionState extends BaseState {
|
||||
|
||||
private IBaseExtension<?> myExtension;
|
||||
private IBaseExtension<?, ?> myExtension;
|
||||
|
||||
public ExtensionState(PreResourceState thePreResourceState, IBaseExtension<?> theExtension) {
|
||||
public ExtensionState(PreResourceState thePreResourceState, IBaseExtension<?, ?> theExtension) {
|
||||
super(thePreResourceState);
|
||||
myExtension = theExtension;
|
||||
}
|
||||
|
@ -1722,7 +1722,7 @@ class ParserState<T> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IBaseExtension<?> getCurrentElement() {
|
||||
protected IBaseExtension<?, ?> getCurrentElement() {
|
||||
return myExtension;
|
||||
}
|
||||
|
||||
|
@ -2080,7 +2080,7 @@ class ParserState<T> {
|
|||
}
|
||||
}else if (theElement instanceof IBaseReference) {
|
||||
IBaseReference nextRef = (IBaseReference) theElement;
|
||||
String ref = nextRef.getReference().getValue();
|
||||
String ref = nextRef.getReferenceElement().getValue();
|
||||
if (isNotBlank(ref)) {
|
||||
if (ref.startsWith("#")) {
|
||||
IBaseResource target = myContainedResources.get(ref.substring(1));
|
||||
|
@ -2192,7 +2192,7 @@ class ParserState<T> {
|
|||
} else if (myInstance instanceof IBaseElement) {
|
||||
((IBaseElement) myInstance).setId(theValue);
|
||||
} else if (myInstance instanceof IBaseResource) {
|
||||
new IdDt(theValue).applyTo((org.hl7.fhir.instance.model.IBaseResource) myInstance);
|
||||
new IdDt(theValue).applyTo((org.hl7.fhir.instance.model.api.IBaseResource) myInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,10 +47,10 @@ import javax.xml.stream.events.StartElement;
|
|||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IRiResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IRefImplResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||
|
@ -616,7 +616,7 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
|
||||
if (nextValue instanceof IBaseExtension && myContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) {
|
||||
// This is called for the Query resource in DSTU1 only
|
||||
extensionUrl = ((IBaseExtension<?>) nextValue).getUrl();
|
||||
extensionUrl = ((IBaseExtension<?, ?>) nextValue).getUrl();
|
||||
encodeChildElementToStreamWriter(theResource, theEventWriter, nextValue, childName, childDef, extensionUrl, theIncludedResource);
|
||||
|
||||
} else if (extensionUrl != null && childName.equals("extension") == false) {
|
||||
|
@ -664,11 +664,11 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
|
||||
/**
|
||||
* This is just to work around the fact that casting java.util.List<ca.uhn.fhir.model.api.ExtensionDt> to
|
||||
* java.util.List<? extends org.hl7.fhir.instance.model.api.IBaseExtension<?>> seems to be rejected by the compiler
|
||||
* java.util.List<? extends org.hl7.fhir.instance.model.api.IBaseExtension<?, ?>> seems to be rejected by the compiler
|
||||
* some of the time.
|
||||
*/
|
||||
private <Q extends IBaseExtension<?>> List<IBaseExtension<?>> toBaseExtensionList(final List<Q> theList) {
|
||||
List<IBaseExtension<?>> retVal = new ArrayList<IBaseExtension<?>>(theList.size());
|
||||
private <Q extends IBaseExtension<?, ?>> List<IBaseExtension<?, ?>> toBaseExtensionList(final List<Q> theList) {
|
||||
List<IBaseExtension<?, ?>> retVal = new ArrayList<IBaseExtension<?, ?>>(theList.size());
|
||||
retVal.addAll(theList);
|
||||
return retVal;
|
||||
}
|
||||
|
@ -751,7 +751,7 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
}
|
||||
} else {
|
||||
// HL7 structs
|
||||
IRiResource resource = (IRiResource) theResource;
|
||||
IRefImplResource resource = (IRefImplResource) theResource;
|
||||
if (StringUtils.isNotBlank(resource.getId().getIdPart())) {
|
||||
resourceId = resource.getId().getIdPart();
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
theEventWriter.writeStartElement(resDef.getName());
|
||||
theEventWriter.writeDefaultNamespace(FHIR_NS);
|
||||
|
||||
if (theResource instanceof IRiResource) {
|
||||
if (theResource instanceof IRefImplResource) {
|
||||
|
||||
// HL7.org Structures
|
||||
writeOptionalTagWithValue(theEventWriter, "id", theResourceId);
|
||||
|
@ -890,8 +890,8 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
}
|
||||
}
|
||||
|
||||
private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theWriter, List<? extends IBaseExtension<?>> theExtensions, String tagName, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
|
||||
for (IBaseExtension<?> next : theExtensions) {
|
||||
private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theWriter, List<? extends IBaseExtension<?, ?>> theExtensions, String tagName, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
|
||||
for (IBaseExtension<?, ?> next : theExtensions) {
|
||||
if (next == null || (ElementUtil.isEmpty(next.getValue()) && next.getExtension().isEmpty())) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
/**
|
||||
* RESTful method annotation used for a method which provides FHIR "operations".
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
|
@ -37,11 +37,11 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseConformance;
|
||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
|
|
|
@ -23,7 +23,7 @@ package ca.uhn.fhir.rest.client;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
|
|
|
@ -43,8 +43,8 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
|||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.rest.gclient;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
public interface IBaseOn<T> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.rest.gclient;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.rest.gclient;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.rest.gclient;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
public interface IReadExecutable<T extends IBaseResource> extends IClientExecutable<IReadExecutable<T>, T>{
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.rest.gclient;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.NotModifiedException;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.rest.gclient;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ package ca.uhn.fhir.rest.gclient;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.rest.gclient;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.rest.gclient;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
public interface IUpdate {
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.Map;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -33,8 +33,8 @@ import org.apache.http.client.methods.HttpRequestBase;
|
|||
import org.apache.http.entity.AbstractHttpEntity;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.Set;
|
|||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -37,7 +37,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -35,7 +35,8 @@ import java.util.Set;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -1,371 +0,0 @@
|
|||
package ca.uhn.fhir.rest.method;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.client.exceptions.InvalidResponseException;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.IVersionSpecificBundleFactory;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer.NarrativeModeEnum;
|
||||
import ca.uhn.fhir.rest.server.RestfulServerUtils;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.util.ReflectionUtil;
|
||||
|
||||
abstract class BaseResourceReturningMethodBinding extends BaseMethodBinding<Object> {
|
||||
protected static final Set<String> ALLOWED_PARAMS;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseResourceReturningMethodBinding.class);
|
||||
|
||||
static {
|
||||
HashSet<String> set = new HashSet<String>();
|
||||
set.add(Constants.PARAM_FORMAT);
|
||||
set.add(Constants.PARAM_NARRATIVE);
|
||||
set.add(Constants.PARAM_PRETTY);
|
||||
set.add(Constants.PARAM_SORT);
|
||||
set.add(Constants.PARAM_SORT_ASC);
|
||||
set.add(Constants.PARAM_SORT_DESC);
|
||||
set.add(Constants.PARAM_COUNT);
|
||||
ALLOWED_PARAMS = Collections.unmodifiableSet(set);
|
||||
}
|
||||
|
||||
private MethodReturnTypeEnum myMethodReturnType;
|
||||
private Class<?> myResourceListCollectionType;
|
||||
private String myResourceName;
|
||||
private Class<? extends IResource> myResourceType;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseResourceReturningMethodBinding(Class<?> theReturnResourceType, Method theMethod, FhirContext theContext, Object theProvider) {
|
||||
super(theMethod, theContext, theProvider);
|
||||
|
||||
Class<?> methodReturnType = theMethod.getReturnType();
|
||||
if (Collection.class.isAssignableFrom(methodReturnType)) {
|
||||
|
||||
myMethodReturnType = MethodReturnTypeEnum.LIST_OF_RESOURCES;
|
||||
Class<?> collectionType = ReflectionUtil.getGenericCollectionTypeOfMethodReturnType(theMethod);
|
||||
if (collectionType != null) {
|
||||
if (!Object.class.equals(collectionType) && !IResource.class.isAssignableFrom(collectionType)) {
|
||||
throw new ConfigurationException("Method " + theMethod.getDeclaringClass().getSimpleName() + "#" + theMethod.getName() + " returns an invalid collection generic type: " + collectionType);
|
||||
}
|
||||
}
|
||||
myResourceListCollectionType = collectionType;
|
||||
|
||||
} else if (IBaseResource.class.isAssignableFrom(methodReturnType)) {
|
||||
if (Modifier.isAbstract(methodReturnType.getModifiers()) == false && theContext.getResourceDefinition((Class<? extends IBaseResource>) methodReturnType).isBundle()) {
|
||||
myMethodReturnType = MethodReturnTypeEnum.BUNDLE_RESOURCE;
|
||||
} else {
|
||||
myMethodReturnType = MethodReturnTypeEnum.RESOURCE;
|
||||
}
|
||||
} else if (Bundle.class.isAssignableFrom(methodReturnType)) {
|
||||
myMethodReturnType = MethodReturnTypeEnum.BUNDLE;
|
||||
} else if (IBundleProvider.class.isAssignableFrom(methodReturnType)) {
|
||||
myMethodReturnType = MethodReturnTypeEnum.BUNDLE_PROVIDER;
|
||||
} else {
|
||||
throw new ConfigurationException("Invalid return type '" + methodReturnType.getCanonicalName() + "' on method '" + theMethod.getName() + "' on type: " + theMethod.getDeclaringClass().getCanonicalName());
|
||||
}
|
||||
|
||||
if (theReturnResourceType != null) {
|
||||
if (IResource.class.isAssignableFrom(theReturnResourceType)) {
|
||||
ResourceDef resourceDefAnnotation = theReturnResourceType.getAnnotation(ResourceDef.class);
|
||||
if (resourceDefAnnotation == null) {
|
||||
if (Modifier.isAbstract(theReturnResourceType.getModifiers())) {
|
||||
// If we're returning an abstract type, that's ok
|
||||
} else {
|
||||
throw new ConfigurationException(theReturnResourceType.getCanonicalName() + " has no @" + ResourceDef.class.getSimpleName() + " annotation");
|
||||
}
|
||||
} else {
|
||||
myResourceType = (Class<? extends IResource>) theReturnResourceType;
|
||||
myResourceName = resourceDefAnnotation.name();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MethodReturnTypeEnum getMethodReturnType() {
|
||||
return myMethodReturnType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourceName() {
|
||||
return myResourceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the response is a bundle, this type will be placed in the root of the bundle (can be null)
|
||||
*/
|
||||
protected abstract BundleTypeEnum getResponseBundleType();
|
||||
|
||||
public abstract ReturnTypeEnum getReturnType();
|
||||
|
||||
@Override
|
||||
public Object invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException {
|
||||
IParser parser = createAppropriateParserForParsingResponse(theResponseMimeType, theResponseReader, theResponseStatusCode);
|
||||
|
||||
switch (getReturnType()) {
|
||||
case BUNDLE: {
|
||||
Bundle bundle;
|
||||
if (myResourceType != null) {
|
||||
bundle = parser.parseBundle(myResourceType, theResponseReader);
|
||||
} else {
|
||||
bundle = parser.parseBundle(theResponseReader);
|
||||
}
|
||||
switch (getMethodReturnType()) {
|
||||
case BUNDLE:
|
||||
return bundle;
|
||||
case LIST_OF_RESOURCES:
|
||||
List<IResource> listOfResources;
|
||||
if (myResourceListCollectionType != null) {
|
||||
listOfResources = new ArrayList<IResource>();
|
||||
for (IResource next : bundle.toListOfResources()) {
|
||||
if (!myResourceListCollectionType.isAssignableFrom(next.getClass())) {
|
||||
ourLog.debug("Not returning resource of type {} because it is not a subclass or instance of {}", next.getClass(), myResourceListCollectionType);
|
||||
continue;
|
||||
}
|
||||
listOfResources.add(next);
|
||||
}
|
||||
} else {
|
||||
listOfResources = bundle.toListOfResources();
|
||||
}
|
||||
return listOfResources;
|
||||
case RESOURCE:
|
||||
List<IResource> list = bundle.toListOfResources();
|
||||
if (list.size() == 0) {
|
||||
return null;
|
||||
} else if (list.size() == 1) {
|
||||
return list.get(0);
|
||||
} else {
|
||||
throw new InvalidResponseException(theResponseStatusCode, "FHIR server call returned a bundle with multiple resources, but this method is only able to returns one.");
|
||||
}
|
||||
case BUNDLE_PROVIDER:
|
||||
throw new IllegalStateException("Return type of " + IBundleProvider.class.getSimpleName() + " is not supported in clients");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RESOURCE: {
|
||||
IResource resource;
|
||||
if (myResourceType != null) {
|
||||
resource = parser.parseResource(myResourceType, theResponseReader);
|
||||
} else {
|
||||
resource = parser.parseResource(theResponseReader);
|
||||
}
|
||||
|
||||
MethodUtil.parseClientRequestResourceHeaders(null, theHeaders, resource);
|
||||
|
||||
switch (getMethodReturnType()) {
|
||||
case BUNDLE:
|
||||
return Bundle.withSingleResource(resource);
|
||||
case LIST_OF_RESOURCES:
|
||||
return Collections.singletonList(resource);
|
||||
case RESOURCE:
|
||||
return resource;
|
||||
case BUNDLE_PROVIDER:
|
||||
throw new IllegalStateException("Return type of " + IBundleProvider.class.getSimpleName() + " is not supported in clients");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Should not get here!");
|
||||
}
|
||||
|
||||
public abstract Object invokeServer(RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException;
|
||||
|
||||
@Override
|
||||
public void invokeServer(RestfulServer theServer, Request theRequest) throws BaseServerResponseException, IOException {
|
||||
|
||||
// Pretty print
|
||||
boolean prettyPrint = RestfulServerUtils.prettyPrintResponse(theRequest);
|
||||
|
||||
// Narrative mode
|
||||
NarrativeModeEnum narrativeMode = RestfulServerUtils.determineNarrativeMode(theRequest);
|
||||
|
||||
// Determine response encoding
|
||||
EncodingEnum responseEncoding = RestfulServerUtils.determineResponseEncodingNoDefault(theRequest.getServletRequest());
|
||||
|
||||
// Is this request coming from a browser
|
||||
String uaHeader = theRequest.getServletRequest().getHeader("user-agent");
|
||||
boolean requestIsBrowser = false;
|
||||
if (uaHeader != null && uaHeader.contains("Mozilla")) {
|
||||
requestIsBrowser = true;
|
||||
}
|
||||
|
||||
Object requestObject = parseRequestObject(theRequest);
|
||||
|
||||
// Method params
|
||||
Object[] params = new Object[getParameters().size()];
|
||||
for (int i = 0; i < getParameters().size(); i++) {
|
||||
IParameter param = getParameters().get(i);
|
||||
if (param != null) {
|
||||
params[i] = param.translateQueryParametersIntoServerArgument(theRequest, requestObject);
|
||||
}
|
||||
}
|
||||
|
||||
Integer count = RestfulServerUtils.extractCountParameter(theRequest.getServletRequest());
|
||||
|
||||
boolean respondGzip = theRequest.isRespondGzip();
|
||||
|
||||
HttpServletResponse response = theRequest.getServletResponse();
|
||||
Object resultObj = invokeServer(theRequest, params);
|
||||
switch (getReturnType()) {
|
||||
case BUNDLE: {
|
||||
|
||||
if (getMethodReturnType() == MethodReturnTypeEnum.BUNDLE_RESOURCE) {
|
||||
IResource resource;
|
||||
if (resultObj instanceof IBundleProvider) {
|
||||
IBundleProvider result = (IBundleProvider) resultObj;
|
||||
resource = result.getResources(0, 1).get(0);
|
||||
} else {
|
||||
resource = (IResource) resultObj;
|
||||
}
|
||||
|
||||
/*
|
||||
* We assume that the bundle we got back from the handling method may not have everything populated
|
||||
* (e.g. self links, bundle type, etc) so we do that here.
|
||||
*/
|
||||
IVersionSpecificBundleFactory bundleFactory = theServer.getFhirContext().newBundleFactory();
|
||||
bundleFactory.initializeWithBundleResource(resource);
|
||||
bundleFactory.addRootPropertiesToBundle(null, theRequest.getFhirServerBase(), theRequest.getCompleteUrl(), count, getResponseBundleType());
|
||||
|
||||
for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
|
||||
IServerInterceptor next = theServer.getInterceptors().get(i);
|
||||
boolean continueProcessing = next.outgoingResponse(theRequest, resource, theRequest.getServletRequest(), theRequest.getServletResponse());
|
||||
if (!continueProcessing) {
|
||||
ourLog.debug("Interceptor {} returned false, not continuing processing");
|
||||
return;
|
||||
}
|
||||
}
|
||||
RestfulServerUtils.streamResponseAsResource(theServer, response, resource, responseEncoding, prettyPrint, requestIsBrowser, narrativeMode, respondGzip, theRequest.getFhirServerBase());
|
||||
break;
|
||||
} else {
|
||||
Set<Include> includes = getRequestIncludesFromParams(params);
|
||||
|
||||
IBundleProvider result = (IBundleProvider) resultObj;
|
||||
IVersionSpecificBundleFactory bundleFactory = theServer.getFhirContext().newBundleFactory();
|
||||
<<<<<<< HEAD
|
||||
bundleFactory.initializeBundleFromBundleProvider(theServer, result, responseEncoding, theRequest.getFhirServerBase(), theRequest.getCompleteUrl(), prettyPrint, 0, count, null, getResponseBundleType());
|
||||
=======
|
||||
bundleFactory.initializeBundleFromBundleProvider(theServer, result, responseEncoding, theRequest.getFhirServerBase(), theRequest.getCompleteUrl(), prettyPrint, 0, count, null,
|
||||
getResponseBundleType(), includes);
|
||||
>>>>>>> 48880ab6077c7aeee21e23196fb21d1c26851709
|
||||
Bundle bundle = bundleFactory.getDstu1Bundle();
|
||||
if (bundle != null) {
|
||||
for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
|
||||
IServerInterceptor next = theServer.getInterceptors().get(i);
|
||||
boolean continueProcessing = next.outgoingResponse(theRequest, bundle, theRequest.getServletRequest(), theRequest.getServletResponse());
|
||||
if (!continueProcessing) {
|
||||
ourLog.debug("Interceptor {} returned false, not continuing processing");
|
||||
return;
|
||||
}
|
||||
}
|
||||
RestfulServerUtils.streamResponseAsBundle(theServer, response, bundle, responseEncoding, theRequest.getFhirServerBase(), prettyPrint, narrativeMode, respondGzip, requestIsBrowser);
|
||||
} else {
|
||||
IBaseResource resBundle = bundleFactory.getResourceBundle();
|
||||
for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
|
||||
IServerInterceptor next = theServer.getInterceptors().get(i);
|
||||
boolean continueProcessing = next.outgoingResponse(theRequest, resBundle, theRequest.getServletRequest(), theRequest.getServletResponse());
|
||||
if (!continueProcessing) {
|
||||
ourLog.debug("Interceptor {} returned false, not continuing processing");
|
||||
return;
|
||||
}
|
||||
}
|
||||
RestfulServerUtils.streamResponseAsResource(theServer, response, (IResource) resBundle, responseEncoding, prettyPrint, requestIsBrowser, narrativeMode, Constants.STATUS_HTTP_200_OK, theRequest.isRespondGzip(), theRequest.getFhirServerBase());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
case RESOURCE: {
|
||||
IBundleProvider result = (IBundleProvider) resultObj;
|
||||
if (result.size() == 0) {
|
||||
throw new ResourceNotFoundException(theRequest.getId());
|
||||
} else if (result.size() > 1) {
|
||||
throw new InternalErrorException("Method returned multiple resources");
|
||||
}
|
||||
|
||||
IResource resource = result.getResources(0, 1).get(0);
|
||||
|
||||
for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
|
||||
IServerInterceptor next = theServer.getInterceptors().get(i);
|
||||
boolean continueProcessing = next.outgoingResponse(theRequest, resource, theRequest.getServletRequest(), theRequest.getServletResponse());
|
||||
if (!continueProcessing) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RestfulServerUtils.streamResponseAsResource(theServer, response, resource, responseEncoding, prettyPrint, requestIsBrowser, narrativeMode, respondGzip, theRequest.getFhirServerBase());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses may override
|
||||
*
|
||||
* @param theRequest
|
||||
* The incoming request
|
||||
* @throws IOException
|
||||
* Subclasses may throw this in the event of an IO exception
|
||||
*/
|
||||
protected Object parseRequestObject(Request theRequest) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void setResourceName(String theResourceName) {
|
||||
myResourceName = theResourceName;
|
||||
}
|
||||
|
||||
public enum MethodReturnTypeEnum {
|
||||
BUNDLE, BUNDLE_PROVIDER, BUNDLE_RESOURCE, LIST_OF_RESOURCES, RESOURCE
|
||||
}
|
||||
|
||||
public enum ReturnTypeEnum {
|
||||
BUNDLE, RESOURCE
|
||||
}
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.lang.reflect.Method;
|
|||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.Map;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.lang.reflect.Modifier;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
|||
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.AbstractHttpEntity;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
|
|
|
@ -23,7 +23,7 @@ package ca.uhn.fhir.rest.method;
|
|||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.entity.AbstractHttpEntity;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
|
|
@ -24,10 +24,10 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.utils.DateUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IRiResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IRefImplResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IMetaType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseMetaType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -450,8 +450,8 @@ public class MethodUtil {
|
|||
if (resource instanceof IResource) {
|
||||
InstantDt lmValue = new InstantDt(headerDateValue);
|
||||
((IResource) resource).getResourceMetadata().put(ResourceMetadataKeyEnum.UPDATED, lmValue);
|
||||
} else if (resource instanceof IRiResource) {
|
||||
((IRiResource) resource).getMeta().setLastUpdated(headerDateValue);
|
||||
} else if (resource instanceof IRefImplResource) {
|
||||
((IRefImplResource) resource).getMeta().setLastUpdated(headerDateValue);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ourLog.warn("Unable to parse date string '{}'. Error is: {}", headerValue, e.toString());
|
||||
|
@ -495,8 +495,8 @@ public class MethodUtil {
|
|||
}
|
||||
if (resource instanceof IResource) {
|
||||
ResourceMetadataKeyEnum.TAG_LIST.put((IResource) resource, tagList);
|
||||
} else if (resource instanceof IRiResource) {
|
||||
IMetaType meta = ((IRiResource) resource).getMeta();
|
||||
} else if (resource instanceof IRefImplResource) {
|
||||
IBaseMetaType meta = ((IRefImplResource) resource).getMeta();
|
||||
for (Tag next : tagList) {
|
||||
meta.addTag().setSystem(next.getScheme()).setCode(next.getTerm()).setDisplay(next.getLabel());
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
|
|
@ -32,11 +32,11 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -26,10 +26,10 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition.IAccessor;
|
||||
|
|
|
@ -31,8 +31,8 @@ import java.util.Map;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue