...more work on HL7 structs
This commit is contained in:
parent
2f92e3515b
commit
d8e14e4213
|
@ -25,27 +25,28 @@ import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.ICodeEnum;
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
|
||||||
public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDeclaredChildDefinition {
|
public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||||
|
|
||||||
private Class<? extends ICodeEnum> myCodeType;
|
private Class<? extends ICodeEnum> myCodeType;
|
||||||
private Class<? extends IDatatype> myDatatype;
|
private Class<? extends IBase> myDatatype;
|
||||||
|
|
||||||
private BaseRuntimeElementDefinition<?> myElementDefinition;
|
private BaseRuntimeElementDefinition<?> myElementDefinition;
|
||||||
|
|
||||||
public BaseRuntimeChildDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype) {
|
public BaseRuntimeChildDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype) {
|
||||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||||
assert theDatatype != IDatatype.class; // should use RuntimeChildAny
|
assert theDatatype != IDatatype.class; // should use RuntimeChildAny
|
||||||
myDatatype = theDatatype;
|
myDatatype = theDatatype;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
if (myDatatype.equals(theDatatype)) {
|
if (myDatatype.equals(theDatatype)) {
|
||||||
return getElementName();
|
return getElementName();
|
||||||
}
|
}
|
||||||
|
@ -53,8 +54,8 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) {
|
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
Class<? extends IElement> datatype = theDatatype;
|
Class<? extends IBase> datatype = theDatatype;
|
||||||
if (myDatatype.equals(datatype)) {
|
if (myDatatype.equals(datatype)) {
|
||||||
return myElementDefinition;
|
return myElementDefinition;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +74,7 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
|
||||||
return myCodeType;
|
return myCodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends IDatatype> getDatatype() {
|
public Class<? extends IBase> getDatatype() {
|
||||||
return myDatatype;
|
return myDatatype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
myElementDefinition = theClassToElementDefinitions.get(getDatatype());
|
myElementDefinition = theClassToElementDefinitions.get(getDatatype());
|
||||||
assert myElementDefinition != null : "Unknown type: " + getDatatype();
|
assert myElementDefinition != null : "Unknown type: " + getDatatype();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
public abstract class BaseRuntimeChildDefinition {
|
public abstract class BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
|
@ -37,18 +37,18 @@ public abstract class BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
public abstract BaseRuntimeElementDefinition<?> getChildByName(String theName);
|
public abstract BaseRuntimeElementDefinition<?> getChildByName(String theName);
|
||||||
|
|
||||||
public abstract BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theType);
|
public abstract BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType);
|
||||||
|
|
||||||
public abstract String getChildNameByDatatype(Class<? extends IElement> theDatatype);
|
public abstract String getChildNameByDatatype(Class<? extends IBase> theDatatype);
|
||||||
|
|
||||||
public abstract IMutator getMutator();
|
public abstract IMutator getMutator();
|
||||||
|
|
||||||
public abstract Set<String> getValidChildNames();
|
public abstract Set<String> getValidChildNames();
|
||||||
|
|
||||||
abstract void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions);
|
abstract void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions);
|
||||||
|
|
||||||
public interface IAccessor {
|
public interface IAccessor {
|
||||||
List<? extends IElement> getValues(Object theTarget);
|
List<? extends IBase> getValues(Object theTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getElementName();
|
public abstract String getElementName();
|
||||||
|
@ -58,7 +58,7 @@ public abstract class BaseRuntimeChildDefinition {
|
||||||
public abstract int getMin();
|
public abstract int getMin();
|
||||||
|
|
||||||
public interface IMutator {
|
public interface IMutator {
|
||||||
void addValue(Object theTarget, IElement theValue);
|
void addValue(Object theTarget, IBase theValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExtensionUrl() {
|
public String getExtensionUrl() {
|
||||||
|
|
|
@ -27,11 +27,11 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.ICompositeElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
|
||||||
public abstract class BaseRuntimeElementCompositeDefinition<T extends ICompositeElement> extends BaseRuntimeElementDefinition<T> {
|
public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> extends BaseRuntimeElementDefinition<T> {
|
||||||
|
|
||||||
private List<BaseRuntimeChildDefinition> myChildren = new ArrayList<BaseRuntimeChildDefinition>();
|
private List<BaseRuntimeChildDefinition> myChildren = new ArrayList<BaseRuntimeChildDefinition>();
|
||||||
private List<BaseRuntimeChildDefinition> myChildrenAndExtensions;
|
private List<BaseRuntimeChildDefinition> myChildrenAndExtensions;
|
||||||
|
@ -76,7 +76,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IComposite
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
public void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
super.sealAndInitialize(theClassToElementDefinitions);
|
super.sealAndInitialize(theClassToElementDefinitions);
|
||||||
|
|
||||||
for (BaseRuntimeChildDefinition next : myChildren) {
|
for (BaseRuntimeChildDefinition next : myChildren) {
|
||||||
|
|
|
@ -28,11 +28,11 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
|
||||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||||
|
|
||||||
public abstract class BaseRuntimeElementDefinition<T extends IElement> {
|
public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
||||||
|
|
||||||
private String myName;
|
private String myName;
|
||||||
private Class<? extends T> myImplementingClass;
|
private Class<? extends T> myImplementingClass;
|
||||||
|
@ -129,7 +129,7 @@ public abstract class BaseRuntimeElementDefinition<T extends IElement> {
|
||||||
* Invoked prior to use to perform any initialization and make object
|
* Invoked prior to use to perform any initialization and make object
|
||||||
* mutable
|
* mutable
|
||||||
*/
|
*/
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
for (BaseRuntimeChildDefinition next : myExtensions) {
|
for (BaseRuntimeChildDefinition next : myExtensions) {
|
||||||
next.sealAndInitialize(theClassToElementDefinitions);
|
next.sealAndInitialize(theClassToElementDefinitions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ import ca.uhn.fhir.validation.FhirValidator;
|
||||||
*/
|
*/
|
||||||
public class FhirContext {
|
public class FhirContext {
|
||||||
|
|
||||||
private static final List<Class<? extends IResource>> EMPTY_LIST = Collections.emptyList();
|
private static final List<Class<? extends IBaseResource>> EMPTY_LIST = Collections.emptyList();
|
||||||
private volatile Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> myClassToElementDefinition = Collections.emptyMap();
|
private volatile Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> myClassToElementDefinition = Collections.emptyMap();
|
||||||
private volatile Map<String, RuntimeResourceDefinition> myIdToResourceDefinition = Collections.emptyMap();
|
private volatile Map<String, RuntimeResourceDefinition> myIdToResourceDefinition = Collections.emptyMap();
|
||||||
private HapiLocalizer myLocalizer = new HapiLocalizer();
|
private HapiLocalizer myLocalizer = new HapiLocalizer();
|
||||||
|
@ -85,7 +85,7 @@ public class FhirContext {
|
||||||
this(EMPTY_LIST);
|
this(EMPTY_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FhirContext(Class<? extends IResource> theResourceType) {
|
public FhirContext(Class<? extends IBaseResource> theResourceType) {
|
||||||
this(toCollection(theResourceType));
|
this(toCollection(theResourceType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class FhirContext {
|
||||||
this(toCollection(theResourceTypes));
|
this(toCollection(theResourceTypes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FhirContext(Collection<Class<? extends IResource>> theResourceTypes) {
|
public FhirContext(Collection<Class<? extends IBaseResource>> theResourceTypes) {
|
||||||
scanResourceTypes(theResourceTypes);
|
scanResourceTypes(theResourceTypes);
|
||||||
|
|
||||||
if (FhirVersionEnum.DSTU1.isPresentOnClasspath()) {
|
if (FhirVersionEnum.DSTU1.isPresentOnClasspath()) {
|
||||||
|
@ -295,8 +295,8 @@ public class FhirContext {
|
||||||
return new XmlParser(this);
|
return new XmlParser(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RuntimeResourceDefinition scanResourceType(Class<? extends IResource> theResourceType) {
|
private RuntimeResourceDefinition scanResourceType(Class<? extends IBaseResource> theResourceType) {
|
||||||
ArrayList<Class<? extends IResource>> resourceTypes = new ArrayList<Class<? extends IResource>>();
|
ArrayList<Class<? extends IBaseResource>> resourceTypes = new ArrayList<Class<? extends IBaseResource>>();
|
||||||
resourceTypes.add(theResourceType);
|
resourceTypes.add(theResourceType);
|
||||||
Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> defs = scanResourceTypes(resourceTypes);
|
Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> defs = scanResourceTypes(resourceTypes);
|
||||||
return (RuntimeResourceDefinition) defs.get(theResourceType);
|
return (RuntimeResourceDefinition) defs.get(theResourceType);
|
||||||
|
@ -340,15 +340,15 @@ public class FhirContext {
|
||||||
myNarrativeGenerator = theNarrativeGenerator;
|
myNarrativeGenerator = theNarrativeGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<Class<? extends IResource>> toCollection(Class<? extends IResource> theResourceType) {
|
private static Collection<Class<? extends IBaseResource>> toCollection(Class<? extends IBaseResource> theResourceType) {
|
||||||
ArrayList<Class<? extends IResource>> retVal = new ArrayList<Class<? extends IResource>>(1);
|
ArrayList<Class<? extends IBaseResource>> retVal = new ArrayList<Class<? extends IBaseResource>>(1);
|
||||||
retVal.add(theResourceType);
|
retVal.add(theResourceType);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static List<Class<? extends IResource>> toCollection(Class<?>[] theResourceTypes) {
|
private static List<Class<? extends IBaseResource>> toCollection(Class<?>[] theResourceTypes) {
|
||||||
ArrayList<Class<? extends IResource>> retVal = new ArrayList<Class<? extends IResource>>(1);
|
ArrayList<Class<? extends IBaseResource>> retVal = new ArrayList<Class<? extends IBaseResource>>(1);
|
||||||
for (Class<?> clazz : theResourceTypes) {
|
for (Class<?> clazz : theResourceTypes) {
|
||||||
if (!IResource.class.isAssignableFrom(clazz)) {
|
if (!IResource.class.isAssignableFrom(clazz)) {
|
||||||
throw new IllegalArgumentException(clazz.getCanonicalName() + " is not an instance of " + IResource.class.getSimpleName());
|
throw new IllegalArgumentException(clazz.getCanonicalName() + " is not an instance of " + IResource.class.getSimpleName());
|
||||||
|
|
|
@ -24,9 +24,14 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.AnnotatedElement;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationHandler;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Proxy;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -43,15 +48,19 @@ import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.hl7.fhir.instance.model.BackboneElement;
|
||||||
|
import org.hl7.fhir.instance.model.DomainResource;
|
||||||
import org.hl7.fhir.instance.model.IBase;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
import org.hl7.fhir.instance.model.IBaseResource;
|
import org.hl7.fhir.instance.model.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.ICompositeType;
|
import org.hl7.fhir.instance.model.ICompositeType;
|
||||||
|
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||||
|
import org.hl7.fhir.instance.model.Narrative;
|
||||||
|
import org.hl7.fhir.instance.model.Reference;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
||||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||||
import ca.uhn.fhir.model.api.IBoundCodeableConcept;
|
import ca.uhn.fhir.model.api.IBoundCodeableConcept;
|
||||||
import ca.uhn.fhir.model.api.ICodeEnum;
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
|
||||||
import ca.uhn.fhir.model.api.ICompositeElement;
|
import ca.uhn.fhir.model.api.ICompositeElement;
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
|
@ -108,7 +117,7 @@ class ModelScanner {
|
||||||
init(null, new HashSet<Class<? extends IBase>>(theResourceTypes));
|
init(null, new HashSet<Class<? extends IBase>>(theResourceTypes));
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelScanner(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theExistingDefinitions, Collection<Class<? extends IBase>> theResourceTypes) throws ConfigurationException {
|
ModelScanner(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theExistingDefinitions, Collection<Class<? extends IBaseResource>> theResourceTypes) throws ConfigurationException {
|
||||||
myContext=theContext;
|
myContext=theContext;
|
||||||
init(theExistingDefinitions, new HashSet<Class<? extends IBase>>(theResourceTypes));
|
init(theExistingDefinitions, new HashSet<Class<? extends IBase>>(theResourceTypes));
|
||||||
}
|
}
|
||||||
|
@ -133,7 +142,7 @@ class ModelScanner {
|
||||||
return myRuntimeChildUndeclaredExtensionDefinition;
|
return myRuntimeChildUndeclaredExtensionDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addScanAlso(Class<? extends IElement> theType) {
|
private void addScanAlso(Class<? extends IBase> theType) {
|
||||||
if (theType.isInterface()) {
|
if (theType.isInterface()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -261,17 +270,17 @@ class ModelScanner {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceDef resourceDefinition = theClass.getAnnotation(ResourceDef.class);
|
ResourceDef resourceDefinition = pullAnnotation(theClass,ResourceDef.class);
|
||||||
if (resourceDefinition != null) {
|
if (resourceDefinition != null) {
|
||||||
if (!IResource.class.isAssignableFrom(theClass)) {
|
if (!IResource.class.isAssignableFrom(theClass)) {
|
||||||
throw new ConfigurationException("Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
throw new ConfigurationException("Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends IResource> resClass = (Class<? extends IResource>) theClass;
|
Class<? extends IBaseResource> resClass = (Class<? extends IBaseResource>) theClass;
|
||||||
scanResource(resClass, resourceDefinition);
|
scanResource(resClass, resourceDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
DatatypeDef datatypeDefinition = theClass.getAnnotation(DatatypeDef.class);
|
DatatypeDef datatypeDefinition = pullAnnotation(theClass,DatatypeDef.class);
|
||||||
if (datatypeDefinition != null) {
|
if (datatypeDefinition != null) {
|
||||||
if (ICompositeType.class.isAssignableFrom(theClass)) {
|
if (ICompositeType.class.isAssignableFrom(theClass)) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -279,14 +288,14 @@ class ModelScanner {
|
||||||
scanCompositeDatatype(resClass, datatypeDefinition);
|
scanCompositeDatatype(resClass, datatypeDefinition);
|
||||||
} else if (IPrimitiveType.class.isAssignableFrom(theClass)) {
|
} else if (IPrimitiveType.class.isAssignableFrom(theClass)) {
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
Class<? extends IPrimitiveType) resClass = (Class<? extends IPrimitiveType>) theClass;
|
Class<? extends IPrimitiveType> resClass = (Class<? extends IPrimitiveType>) theClass;
|
||||||
scanPrimitiveDatatype(resClass, datatypeDefinition);
|
scanPrimitiveDatatype(resClass, datatypeDefinition);
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationException("Resource type contains a @" + DatatypeDef.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
throw new ConfigurationException("Resource type contains a @" + DatatypeDef.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Block blockDefinition = theClass.getAnnotation(Block.class);
|
Block blockDefinition = pullAnnotation(theClass,Block.class);
|
||||||
if (blockDefinition != null) {
|
if (blockDefinition != null) {
|
||||||
if (IResourceBlock.class.isAssignableFrom(theClass)) {
|
if (IResourceBlock.class.isAssignableFrom(theClass)) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -316,7 +325,7 @@ class ModelScanner {
|
||||||
scanCompositeElementForChildren(theClass, resourceDef);
|
scanCompositeElementForChildren(theClass, resourceDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanCompositeDatatype(Class<? extends ICompositeDatatype> theClass, DatatypeDef theDatatypeDefinition) {
|
private void scanCompositeDatatype(Class<? extends ICompositeType> theClass, DatatypeDef theDatatypeDefinition) {
|
||||||
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||||
|
|
||||||
RuntimeCompositeDatatypeDefinition resourceDef;
|
RuntimeCompositeDatatypeDefinition resourceDef;
|
||||||
|
@ -330,27 +339,27 @@ class ModelScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, BaseRuntimeElementCompositeDefinition<?> theDefinition) {
|
private void scanCompositeElementForChildren(Class<? extends IBase> theClass, BaseRuntimeElementCompositeDefinition<?> theDefinition) {
|
||||||
Set<String> elementNames = new HashSet<String>();
|
Set<String> elementNames = new HashSet<String>();
|
||||||
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderToElementDef = new TreeMap<Integer, BaseRuntimeDeclaredChildDefinition>();
|
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderToElementDef = new TreeMap<Integer, BaseRuntimeDeclaredChildDefinition>();
|
||||||
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderToExtensionDef = new TreeMap<Integer, BaseRuntimeDeclaredChildDefinition>();
|
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderToExtensionDef = new TreeMap<Integer, BaseRuntimeDeclaredChildDefinition>();
|
||||||
|
|
||||||
LinkedList<Class<? extends ICompositeElement>> classes = new LinkedList<Class<? extends ICompositeElement>>();
|
LinkedList<Class<? extends IBase>> classes = new LinkedList<Class<? extends IBase>>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We scan classes for annotated fields in the class but also all of its superclasses
|
* We scan classes for annotated fields in the class but also all of its superclasses
|
||||||
*/
|
*/
|
||||||
Class<? extends ICompositeElement> current = theClass;
|
Class<? extends IBase> current = theClass;
|
||||||
do {
|
do {
|
||||||
classes.push(current);
|
classes.push(current);
|
||||||
if (ICompositeElement.class.isAssignableFrom(current.getSuperclass())) {
|
if (ICompositeElement.class.isAssignableFrom(current.getSuperclass())) {
|
||||||
current = (Class<? extends ICompositeElement>) current.getSuperclass();
|
current = (Class<? extends IBase>) current.getSuperclass();
|
||||||
} else {
|
} else {
|
||||||
current = null;
|
current = null;
|
||||||
}
|
}
|
||||||
} while (current != null);
|
} while (current != null);
|
||||||
|
|
||||||
for (Class<? extends ICompositeElement> next : classes) {
|
for (Class<? extends IBase> next : classes) {
|
||||||
scanCompositeElementForChildren(next, elementNames, orderToElementDef, orderToExtensionDef);
|
scanCompositeElementForChildren(next, elementNames, orderToElementDef, orderToExtensionDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +393,7 @@ class ModelScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, Set<String> elementNames, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToElementDef, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToExtensionDef) {
|
private void scanCompositeElementForChildren(Class<? extends IBase> theClass, Set<String> elementNames, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToElementDef, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToExtensionDef) {
|
||||||
int baseElementOrder = theOrderToElementDef.isEmpty() ? 0 : theOrderToElementDef.lastEntry().getKey() + 1;
|
int baseElementOrder = theOrderToElementDef.isEmpty() ? 0 : theOrderToElementDef.lastEntry().getKey() + 1;
|
||||||
|
|
||||||
for (Field next : theClass.getDeclaredFields()) {
|
for (Field next : theClass.getDeclaredFields()) {
|
||||||
|
@ -394,16 +403,16 @@ class ModelScanner {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Child childAnnotation = next.getAnnotation(Child.class);
|
Child childAnnotation = pullAnnotation(next, Child.class);
|
||||||
if (childAnnotation == null) {
|
if (childAnnotation == null) {
|
||||||
ourLog.trace("Ignoring non @Child field {} on target type {}",next.getName() , theClass);
|
ourLog.trace("Ignoring non @Child field {} on target type {}",next.getName() , theClass);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Description descriptionAnnotation = next.getAnnotation(Description.class);
|
Description descriptionAnnotation = pullAnnotation(next,Description.class);
|
||||||
|
|
||||||
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderMap = theOrderToElementDef;
|
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderMap = theOrderToElementDef;
|
||||||
Extension extensionAttr = next.getAnnotation(Extension.class);
|
Extension extensionAttr = pullAnnotation(next,Extension.class);
|
||||||
if (extensionAttr != null) {
|
if (extensionAttr != null) {
|
||||||
orderMap = theOrderToExtensionDef;
|
orderMap = theOrderToExtensionDef;
|
||||||
}
|
}
|
||||||
|
@ -465,8 +474,8 @@ class ModelScanner {
|
||||||
order--;
|
order--;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Class<? extends IElement>> choiceTypes = new ArrayList<Class<? extends IElement>>();
|
List<Class<? extends IBase>> choiceTypes = new ArrayList<Class<? extends IBase>>();
|
||||||
for (Class<? extends IElement> nextChoiceType : childAnnotation.type()) {
|
for (Class<? extends IBase> nextChoiceType : childAnnotation.type()) {
|
||||||
choiceTypes.add(nextChoiceType);
|
choiceTypes.add(nextChoiceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,18 +489,18 @@ class ModelScanner {
|
||||||
|
|
||||||
Class<?> nextElementType = determineElementType(next);
|
Class<?> nextElementType = determineElementType(next);
|
||||||
|
|
||||||
if (nextElementType.equals(ContainedDt.class)) {
|
if (nextElementType.equals(ContainedDt.class) || (childAnnotation.name().equals("contained") && DomainResource.class.isAssignableFrom(theClass))) {
|
||||||
/*
|
/*
|
||||||
* Child is contained resources
|
* Child is contained resources
|
||||||
*/
|
*/
|
||||||
RuntimeChildContainedResources def = new RuntimeChildContainedResources(next, childAnnotation, descriptionAnnotation, elementName);
|
RuntimeChildContainedResources def = new RuntimeChildContainedResources(next, childAnnotation, descriptionAnnotation, elementName);
|
||||||
orderMap.put(order, def);
|
orderMap.put(order, def);
|
||||||
|
|
||||||
} else if (choiceTypes.size() > 1 && !BaseResourceReferenceDt.class.isAssignableFrom(nextElementType)) {
|
} else if (choiceTypes.size() > 1 && !BaseResourceReferenceDt.class.isAssignableFrom(nextElementType) && !Reference.class.isAssignableFrom(nextElementType)) {
|
||||||
/*
|
/*
|
||||||
* Child is a choice element
|
* Child is a choice element
|
||||||
*/
|
*/
|
||||||
for (Class<? extends IElement> nextType : choiceTypes) {
|
for (Class<? extends IBase> nextType : choiceTypes) {
|
||||||
addScanAlso(nextType);
|
addScanAlso(nextType);
|
||||||
}
|
}
|
||||||
RuntimeChildChoiceDefinition def = new RuntimeChildChoiceDefinition(next, elementName, childAnnotation, descriptionAnnotation, choiceTypes);
|
RuntimeChildChoiceDefinition def = new RuntimeChildChoiceDefinition(next, elementName, childAnnotation, descriptionAnnotation, choiceTypes);
|
||||||
|
@ -509,34 +518,34 @@ class ModelScanner {
|
||||||
/*
|
/*
|
||||||
* Child is an extension
|
* Child is an extension
|
||||||
*/
|
*/
|
||||||
Class<? extends IElement> et = (Class<? extends IElement>) nextElementType;
|
Class<? extends IBase> et = (Class<? extends IBase>) nextElementType;
|
||||||
RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et);
|
RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et);
|
||||||
orderMap.put(order, def);
|
orderMap.put(order, def);
|
||||||
if (IElement.class.isAssignableFrom(nextElementType)) {
|
if (IElement.class.isAssignableFrom(nextElementType)) {
|
||||||
addScanAlso((Class<? extends IElement>) nextElementType);
|
addScanAlso((Class<? extends IElement>) nextElementType);
|
||||||
}
|
}
|
||||||
} else if (BaseResourceReferenceDt.class.isAssignableFrom(nextElementType)) {
|
} else if (BaseResourceReferenceDt.class.isAssignableFrom(nextElementType) || Reference.class.isAssignableFrom(nextElementType)) {
|
||||||
/*
|
/*
|
||||||
* Child is a resource reference
|
* Child is a resource reference
|
||||||
*/
|
*/
|
||||||
List<Class<? extends IResource>> refTypesList = new ArrayList<Class<? extends IResource>>();
|
List<Class<? extends IBaseResource>> refTypesList = new ArrayList<Class<? extends IBaseResource>>();
|
||||||
for (Class<? extends IElement> nextType : childAnnotation.type()) {
|
for (Class<? extends IElement> nextType : childAnnotation.type()) {
|
||||||
if (IResource.class.isAssignableFrom(nextType) == false) {
|
if (IBaseResource.class.isAssignableFrom(nextType) == false) {
|
||||||
throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + BaseResourceReferenceDt.class + " but contains a non-resource type: " + nextType.getCanonicalName());
|
throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + BaseResourceReferenceDt.class + " but contains a non-resource type: " + nextType.getCanonicalName());
|
||||||
}
|
}
|
||||||
refTypesList.add((Class<? extends IResource>) nextType);
|
refTypesList.add((Class<? extends IBaseResource>) nextType);
|
||||||
addScanAlso(nextType);
|
addScanAlso(nextType);
|
||||||
}
|
}
|
||||||
RuntimeChildResourceDefinition def = new RuntimeChildResourceDefinition(next, elementName, childAnnotation, descriptionAnnotation, refTypesList);
|
RuntimeChildResourceDefinition def = new RuntimeChildResourceDefinition(next, elementName, childAnnotation, descriptionAnnotation, refTypesList);
|
||||||
orderMap.put(order, def);
|
orderMap.put(order, def);
|
||||||
|
|
||||||
} else if (IResourceBlock.class.isAssignableFrom(nextElementType)) {
|
} else if (IResourceBlock.class.isAssignableFrom(nextElementType) || BackboneElement.class.isAssignableFrom(nextElementType)) {
|
||||||
/*
|
/*
|
||||||
* Child is a resource block (i.e. a sub-tag within a resource) TODO: do these have a better name
|
* Child is a resource block (i.e. a sub-tag within a resource) TODO: do these have a better name
|
||||||
* according to HL7?
|
* according to HL7?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Class<? extends IResourceBlock> blockDef = (Class<? extends IResourceBlock>) nextElementType;
|
Class<? extends IBase> blockDef = (Class<? extends IBase>) nextElementType;
|
||||||
addScanAlso(blockDef);
|
addScanAlso(blockDef);
|
||||||
RuntimeChildResourceBlockDefinition def = new RuntimeChildResourceBlockDefinition(next, childAnnotation, descriptionAnnotation, elementName, blockDef);
|
RuntimeChildResourceBlockDefinition def = new RuntimeChildResourceBlockDefinition(next, childAnnotation, descriptionAnnotation, elementName, blockDef);
|
||||||
orderMap.put(order, def);
|
orderMap.put(order, def);
|
||||||
|
@ -546,8 +555,8 @@ class ModelScanner {
|
||||||
RuntimeChildAny def = new RuntimeChildAny(next, elementName, childAnnotation, descriptionAnnotation);
|
RuntimeChildAny def = new RuntimeChildAny(next, elementName, childAnnotation, descriptionAnnotation);
|
||||||
orderMap.put(order, def);
|
orderMap.put(order, def);
|
||||||
|
|
||||||
} else if (IDatatype.class.isAssignableFrom(nextElementType)) {
|
} else if (IDatatype.class.isAssignableFrom(nextElementType) || IPrimitiveType.class.isAssignableFrom(nextElementType) || ICompositeType.class.isAssignableFrom(nextElementType)) {
|
||||||
Class<? extends IDatatype> nextDatatype = (Class<? extends IDatatype>) nextElementType;
|
Class<? extends IBase> nextDatatype = (Class<? extends IBase>) nextElementType;
|
||||||
|
|
||||||
addScanAlso(nextDatatype);
|
addScanAlso(nextDatatype);
|
||||||
BaseRuntimeChildDatatypeDefinition def;
|
BaseRuntimeChildDatatypeDefinition def;
|
||||||
|
@ -562,14 +571,14 @@ class ModelScanner {
|
||||||
if (IBoundCodeableConcept.class.isAssignableFrom(nextElementType)) {
|
if (IBoundCodeableConcept.class.isAssignableFrom(nextElementType)) {
|
||||||
IValueSetEnumBinder<Enum<?>> binder = getBoundCodeBinder(next);
|
IValueSetEnumBinder<Enum<?>> binder = getBoundCodeBinder(next);
|
||||||
def = new RuntimeChildCompositeBoundDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype, binder);
|
def = new RuntimeChildCompositeBoundDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype, binder);
|
||||||
} else if (NarrativeDt.class.getSimpleName().equals(nextElementType.getSimpleName())) {
|
} else if (NarrativeDt.class.getSimpleName().equals(nextElementType.getSimpleName()) || Narrative.class.getName().equals(nextElementType.getClass().getName())) {
|
||||||
def = new RuntimeChildNarrativeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
|
def = new RuntimeChildNarrativeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
|
||||||
} else {
|
} else {
|
||||||
def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
|
def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
|
CodeableConceptElement concept = pullAnnotation(next,CodeableConceptElement.class);
|
||||||
if (concept != null) {
|
if (concept != null) {
|
||||||
if (!ICodedDatatype.class.isAssignableFrom(nextDatatype)) {
|
if (!ICodedDatatype.class.isAssignableFrom(nextDatatype)) {
|
||||||
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is marked as @" + CodeableConceptElement.class.getCanonicalName() + " but type is not a subtype of " + ICodedDatatype.class.getName());
|
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is marked as @" + CodeableConceptElement.class.getCanonicalName() + " but type is not a subtype of " + ICodedDatatype.class.getName());
|
||||||
|
@ -590,7 +599,47 @@ class ModelScanner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String scanPrimitiveDatatype(Class<? extends IPrimitiveDatatype<?>> theClass, DatatypeDef theDatatypeDefinition) {
|
/**
|
||||||
|
* There are two implementations of all of the annotations (e.g. {@link Child} and {@link org.hl7.fhir.instance.model.annotations.Child})
|
||||||
|
* since the HL7.org ones will eventually replace the HAPI ones. Annotations can't extend each other or implement interfaces or anything
|
||||||
|
* like that, so rather than duplicate all of the annotation processing code this method just creates an interface Proxy to simulate the
|
||||||
|
* HAPI annotations if the HL7.org ones are found instead.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T extends Annotation> T pullAnnotation(AnnotatedElement theTarget, Class<T> theAnnotationType) {
|
||||||
|
T retVal = theTarget.getAnnotation(theAnnotationType);
|
||||||
|
if (retVal == null) {
|
||||||
|
String sourceClassName = theAnnotationType.getClass().getName();
|
||||||
|
String candidateAltClassName = sourceClassName.replace("ca.uhn.fhir.model.api.annotation", "org.hl7.fhir.instance.model.annotations");
|
||||||
|
|
||||||
|
if (!sourceClassName.equals(candidateAltClassName)) {
|
||||||
|
try {
|
||||||
|
final Class<? extends Annotation> altAnnotationClass = (Class<? extends Annotation>) Class.forName(candidateAltClassName);
|
||||||
|
final Annotation altAnnotation = theTarget.getAnnotation(altAnnotationClass);
|
||||||
|
if (altAnnotation == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ourLog.debug("Forwarding annotation request for [{}] to class [{}]", sourceClassName, candidateAltClassName);
|
||||||
|
|
||||||
|
InvocationHandler h = new InvocationHandler() {
|
||||||
|
@Override
|
||||||
|
public Object invoke(Object theProxy, Method theMethod, Object[] theArgs) throws Throwable {
|
||||||
|
Method altMethod = altAnnotationClass.getMethod(theMethod.getName(), theMethod.getParameterTypes());
|
||||||
|
return altMethod.invoke(altAnnotation, theArgs);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
retVal = (T) Proxy.newProxyInstance(theAnnotationType.getClassLoader(), new Class<?>[]{theAnnotationType}, h);
|
||||||
|
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String scanPrimitiveDatatype(Class<? extends IPrimitiveType> theClass, DatatypeDef theDatatypeDefinition) {
|
||||||
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||||
|
|
||||||
String resourceName = theDatatypeDefinition.name();
|
String resourceName = theDatatypeDefinition.name();
|
||||||
|
@ -611,7 +660,7 @@ class ModelScanner {
|
||||||
return resourceName;
|
return resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String scanResource(Class<? extends IResource> theClass, ResourceDef resourceDefinition) {
|
private String scanResource(Class<? extends IBaseResource> theClass, ResourceDef resourceDefinition) {
|
||||||
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||||
|
|
||||||
boolean primaryNameProvider = true;
|
boolean primaryNameProvider = true;
|
||||||
|
@ -620,7 +669,7 @@ class ModelScanner {
|
||||||
Class<?> parent = theClass.getSuperclass();
|
Class<?> parent = theClass.getSuperclass();
|
||||||
primaryNameProvider = false;
|
primaryNameProvider = false;
|
||||||
while (parent.equals(Object.class) == false && isBlank(resourceName)) {
|
while (parent.equals(Object.class) == false && isBlank(resourceName)) {
|
||||||
ResourceDef nextDef = parent.getAnnotation(ResourceDef.class);
|
ResourceDef nextDef = pullAnnotation(parent,ResourceDef.class);
|
||||||
if (nextDef != null) {
|
if (nextDef != null) {
|
||||||
resourceName = nextDef.name();
|
resourceName = nextDef.name();
|
||||||
}
|
}
|
||||||
|
@ -671,13 +720,13 @@ class ModelScanner {
|
||||||
return resourceName;
|
return resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanResourceForSearchParams(Class<? extends IResource> theClass, RuntimeResourceDefinition theResourceDef) {
|
private void scanResourceForSearchParams(Class<? extends IBaseResource> theClass, RuntimeResourceDefinition theResourceDef) {
|
||||||
|
|
||||||
Map<String, RuntimeSearchParam> nameToParam = new HashMap<String, RuntimeSearchParam>();
|
Map<String, RuntimeSearchParam> nameToParam = new HashMap<String, RuntimeSearchParam>();
|
||||||
Map<Field, SearchParamDefinition> compositeFields = new LinkedHashMap<Field, SearchParamDefinition>();
|
Map<Field, SearchParamDefinition> compositeFields = new LinkedHashMap<Field, SearchParamDefinition>();
|
||||||
|
|
||||||
for (Field nextField : theClass.getFields()) {
|
for (Field nextField : theClass.getFields()) {
|
||||||
SearchParamDefinition searchParam = nextField.getAnnotation(SearchParamDefinition.class);
|
SearchParamDefinition searchParam = pullAnnotation(nextField,SearchParamDefinition.class);
|
||||||
if (searchParam != null) {
|
if (searchParam != null) {
|
||||||
SearchParamTypeEnum paramType = SearchParamTypeEnum.valueOf(searchParam.type().toUpperCase());
|
SearchParamTypeEnum paramType = SearchParamTypeEnum.valueOf(searchParam.type().toUpperCase());
|
||||||
if (paramType == null) {
|
if (paramType == null) {
|
||||||
|
|
|
@ -27,8 +27,9 @@ import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
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.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
@ -41,10 +42,10 @@ public class RuntimeChildAny extends RuntimeChildChoiceDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
List<Class<? extends IElement>> choiceTypes = new ArrayList<Class<? extends IElement>>();
|
List<Class<? extends IBase>> choiceTypes = new ArrayList<Class<? extends IBase>>();
|
||||||
|
|
||||||
for (Class<? extends IElement> next : theClassToElementDefinitions.keySet()) {
|
for (Class<? extends IBase> next : theClassToElementDefinitions.keySet()) {
|
||||||
if (next.equals(XhtmlDt.class)) {
|
if (next.equals(XhtmlDt.class)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
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.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
@ -38,12 +38,12 @@ import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||||
|
|
||||||
public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||||
|
|
||||||
private List<Class<? extends IElement>> myChoiceTypes;
|
private List<Class<? extends IBase>> myChoiceTypes;
|
||||||
private Map<String, BaseRuntimeElementDefinition<?>> myNameToChildDefinition;
|
private Map<String, BaseRuntimeElementDefinition<?>> myNameToChildDefinition;
|
||||||
private Map<Class<? extends IElement>, String> myDatatypeToElementName;
|
private Map<Class<? extends IBase>, String> myDatatypeToElementName;
|
||||||
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myDatatypeToElementDefinition;
|
private Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> myDatatypeToElementDefinition;
|
||||||
|
|
||||||
public RuntimeChildChoiceDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, List<Class<? extends IElement>> theChoiceTypes) {
|
public RuntimeChildChoiceDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, List<Class<? extends IBase>> theChoiceTypes) {
|
||||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||||
|
|
||||||
myChoiceTypes = Collections.unmodifiableList(theChoiceTypes);
|
myChoiceTypes = Collections.unmodifiableList(theChoiceTypes);
|
||||||
|
@ -56,11 +56,11 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
||||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChoiceTypes(List<Class<? extends IElement>> theChoiceTypes) {
|
void setChoiceTypes(List<Class<? extends IBase>> theChoiceTypes) {
|
||||||
myChoiceTypes = Collections.unmodifiableList(theChoiceTypes);
|
myChoiceTypes = Collections.unmodifiableList(theChoiceTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Class<? extends IElement>> getChoices() {
|
public List<Class<? extends IBase>> getChoices() {
|
||||||
return myChoiceTypes;
|
return myChoiceTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,12 +78,12 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
myNameToChildDefinition = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
myNameToChildDefinition = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
||||||
myDatatypeToElementName = new HashMap<Class<? extends IElement>, String>();
|
myDatatypeToElementName = new HashMap<Class<? extends IBase>, String>();
|
||||||
myDatatypeToElementDefinition = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
|
myDatatypeToElementDefinition = new HashMap<Class<? extends IBase>, BaseRuntimeElementDefinition<?>>();
|
||||||
|
|
||||||
for (Class<? extends IElement> next : myChoiceTypes) {
|
for (Class<? extends IBase> next : myChoiceTypes) {
|
||||||
|
|
||||||
String elementName;
|
String elementName;
|
||||||
String alternateElementName = null;
|
String alternateElementName = null;
|
||||||
|
@ -122,16 +122,16 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
return myDatatypeToElementName.get(theDatatype);
|
return myDatatypeToElementName.get(theDatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) {
|
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
return myDatatypeToElementDefinition.get(theDatatype);
|
return myDatatypeToElementDefinition.get(theDatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Class<? extends IElement>> getValidChildTypes() {
|
public Set<Class<? extends IBase>> getValidChildTypes() {
|
||||||
return Collections.unmodifiableSet((myDatatypeToElementDefinition.keySet()));
|
return Collections.unmodifiableSet((myDatatypeToElementDefinition.keySet()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@ package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
@ -31,7 +32,7 @@ public class RuntimeChildCompositeBoundDatatypeDefinition extends RuntimeChildCo
|
||||||
|
|
||||||
private IValueSetEnumBinder<Enum<?>> myBinder;
|
private IValueSetEnumBinder<Enum<?>> myBinder;
|
||||||
|
|
||||||
public RuntimeChildCompositeBoundDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype, IValueSetEnumBinder<Enum<?>> theBinder) {
|
public RuntimeChildCompositeBoundDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype, IValueSetEnumBinder<Enum<?>> theBinder) {
|
||||||
super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation, theDatatype);
|
super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation, theDatatype);
|
||||||
myBinder = theBinder;
|
myBinder = theBinder;
|
||||||
if (theBinder==null) {
|
if (theBinder==null) {
|
||||||
|
|
|
@ -22,13 +22,14 @@ package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
|
||||||
public class RuntimeChildCompositeDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition {
|
public class RuntimeChildCompositeDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition {
|
||||||
|
|
||||||
public RuntimeChildCompositeDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype) {
|
public RuntimeChildCompositeDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype) {
|
||||||
super(theField, theElementName, theChildAnnotation,theDescriptionAnnotation, theDatatype);
|
super(theField, theElementName, theChildAnnotation,theDescriptionAnnotation, theDatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@ import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
|
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
|
||||||
|
@ -45,13 +46,13 @@ public class RuntimeChildContainedResources extends BaseRuntimeDeclaredChildDefi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theType) {
|
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType) {
|
||||||
assert theType.equals(ContainedDt.class);
|
assert theType.equals(ContainedDt.class);
|
||||||
return myElem;
|
return myElem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
assert theDatatype.equals(ContainedDt.class);
|
assert theDatatype.equals(ContainedDt.class);
|
||||||
return getElementName();
|
return getElementName();
|
||||||
}
|
}
|
||||||
|
@ -62,7 +63,7 @@ public class RuntimeChildContainedResources extends BaseRuntimeDeclaredChildDefi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
myElem = new RuntimeElemContainedResources();
|
myElem = new RuntimeElemContainedResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -30,7 +30,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
@ -39,7 +40,7 @@ import ca.uhn.fhir.model.api.annotation.Extension;
|
||||||
public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclaredChildDefinition {
|
public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||||
|
|
||||||
private BaseRuntimeElementDefinition<?> myChildDef;
|
private BaseRuntimeElementDefinition<?> myChildDef;
|
||||||
private Class<? extends IElement> myChildType;
|
private Class<? extends IBase> myChildType;
|
||||||
private String myDatatypeChildName;
|
private String myDatatypeChildName;
|
||||||
private boolean myDefinedLocally;
|
private boolean myDefinedLocally;
|
||||||
private String myExtensionUrl;
|
private String myExtensionUrl;
|
||||||
|
@ -49,7 +50,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
||||||
/**
|
/**
|
||||||
* @param theDefinedLocally See {@link Extension#definedLocally()}
|
* @param theDefinedLocally See {@link Extension#definedLocally()}
|
||||||
*/
|
*/
|
||||||
RuntimeChildDeclaredExtensionDefinition(Field theField, Child theChild, Description theDescriptionAnnotation, Extension theExtension, String theElementName, String theExtensionUrl, Class<? extends IElement> theChildType) throws ConfigurationException {
|
RuntimeChildDeclaredExtensionDefinition(Field theField, Child theChild, Description theDescriptionAnnotation, Extension theExtension, String theElementName, String theExtensionUrl, Class<? extends IBase> theChildType) throws ConfigurationException {
|
||||||
super(theField, theChild, theDescriptionAnnotation, theElementName);
|
super(theField, theChild, theDescriptionAnnotation, theElementName);
|
||||||
assert isNotBlank(theExtensionUrl);
|
assert isNotBlank(theExtensionUrl);
|
||||||
myExtensionUrl = theExtensionUrl;
|
myExtensionUrl = theExtensionUrl;
|
||||||
|
@ -72,7 +73,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theType) {
|
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType) {
|
||||||
if (myChildType.equals(theType)) {
|
if (myChildType.equals(theType)) {
|
||||||
return myChildDef;
|
return myChildDef;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +85,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
if (myChildType.equals(theDatatype) && myDatatypeChildName != null) {
|
if (myChildType.equals(theDatatype) && myDatatypeChildName != null) {
|
||||||
return myDatatypeChildName;
|
return myDatatypeChildName;
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,7 +93,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends IElement> getChildType() {
|
public Class<? extends IBase> getChildType() {
|
||||||
return myChildType;
|
return myChildType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
||||||
return myModifier;
|
return myModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IElement newInstance() {
|
public IBase newInstance() {
|
||||||
try {
|
try {
|
||||||
return myChildType.newInstance();
|
return myChildType.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
|
@ -130,7 +131,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
myUrlToChildExtension = new HashMap<String, RuntimeChildDeclaredExtensionDefinition>();
|
myUrlToChildExtension = new HashMap<String, RuntimeChildDeclaredExtensionDefinition>();
|
||||||
|
|
||||||
BaseRuntimeElementDefinition<?> elementDef = theClassToElementDefinitions.get(myChildType);
|
BaseRuntimeElementDefinition<?> elementDef = theClassToElementDefinitions.get(myChildType);
|
||||||
|
|
|
@ -22,13 +22,14 @@ package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
|
||||||
public class RuntimeChildNarrativeDefinition extends RuntimeChildCompositeDatatypeDefinition {
|
public class RuntimeChildNarrativeDefinition extends RuntimeChildCompositeDatatypeDefinition {
|
||||||
|
|
||||||
public RuntimeChildNarrativeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype) {
|
public RuntimeChildNarrativeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype) {
|
||||||
super(theField, theElementName, theChildAnnotation,theDescriptionAnnotation, theDatatype);
|
super(theField, theElementName, theChildAnnotation,theDescriptionAnnotation, theDatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
@ -31,7 +33,7 @@ public class RuntimeChildPrimitiveBoundCodeDatatypeDefinition extends RuntimeChi
|
||||||
|
|
||||||
private IValueSetEnumBinder<Enum<?>> myBinder;
|
private IValueSetEnumBinder<Enum<?>> myBinder;
|
||||||
|
|
||||||
public RuntimeChildPrimitiveBoundCodeDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype, IValueSetEnumBinder<Enum<?>> theBinder) {
|
public RuntimeChildPrimitiveBoundCodeDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype, IValueSetEnumBinder<Enum<?>> theBinder) {
|
||||||
super(theField, theElementName, theDescriptionAnnotation, theChildAnnotation, theDatatype);
|
super(theField, theElementName, theDescriptionAnnotation, theChildAnnotation, theDatatype);
|
||||||
|
|
||||||
myBinder = theBinder;
|
myBinder = theBinder;
|
||||||
|
|
|
@ -22,13 +22,14 @@ package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
|
||||||
public class RuntimeChildPrimitiveDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition {
|
public class RuntimeChildPrimitiveDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition {
|
||||||
|
|
||||||
public RuntimeChildPrimitiveDatatypeDefinition(Field theField, String theElementName, Description theDescriptionAnnotation, Child theChildAnnotation, Class<? extends IDatatype> theDatatype) {
|
public RuntimeChildPrimitiveDatatypeDefinition(Field theField, String theElementName, Description theDescriptionAnnotation, Child theChildAnnotation, Class<? extends IBase> theDatatype) {
|
||||||
super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation, theDatatype);
|
super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation, theDatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,17 +25,17 @@ import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
import ca.uhn.fhir.model.api.IResourceBlock;
|
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
|
||||||
public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChildDefinition {
|
public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||||
|
|
||||||
private RuntimeResourceBlockDefinition myElementDef;
|
private RuntimeResourceBlockDefinition myElementDef;
|
||||||
private Class<? extends IResourceBlock> myResourceBlockType;
|
private Class<? extends IBase> myResourceBlockType;
|
||||||
|
|
||||||
public RuntimeChildResourceBlockDefinition(Field theField, Child theChildAnnotation, Description theDescriptionAnnotation, String theElementName, Class<? extends IResourceBlock> theResourceBlockType) throws ConfigurationException {
|
public RuntimeChildResourceBlockDefinition(Field theField, Child theChildAnnotation, Description theDescriptionAnnotation, String theElementName, Class<? extends IBase> theResourceBlockType) throws ConfigurationException {
|
||||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||||
myResourceBlockType = theResourceBlockType;
|
myResourceBlockType = theResourceBlockType;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChil
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
if (myResourceBlockType.equals(theDatatype)) {
|
if (myResourceBlockType.equals(theDatatype)) {
|
||||||
return getElementName();
|
return getElementName();
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChil
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) {
|
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
if (myResourceBlockType.equals(theDatatype)) {
|
if (myResourceBlockType.equals(theDatatype)) {
|
||||||
return myElementDef;
|
return myElementDef;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChil
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
myElementDef = (RuntimeResourceBlockDefinition) theClassToElementDefinitions.get(myResourceBlockType);
|
myElementDef = (RuntimeResourceBlockDefinition) theClassToElementDefinitions.get(myResourceBlockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,9 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.IBaseResource;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.annotation.Child;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
|
@ -37,10 +39,10 @@ import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||||
public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||||
|
|
||||||
private BaseRuntimeElementDefinition<?> myRuntimeDef;
|
private BaseRuntimeElementDefinition<?> myRuntimeDef;
|
||||||
private List<Class<? extends IResource>> myResourceTypes;
|
private List<Class<? extends IBaseResource>> myResourceTypes;
|
||||||
private Set<String> myValidChildNames;
|
private Set<String> myValidChildNames;
|
||||||
|
|
||||||
public RuntimeChildResourceDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, List<Class<? extends IResource>> theResourceTypes) {
|
public RuntimeChildResourceDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, List<Class<? extends IBaseResource>> theResourceTypes) {
|
||||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||||
myResourceTypes = theResourceTypes;
|
myResourceTypes = theResourceTypes;
|
||||||
|
|
||||||
|
@ -50,7 +52,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
if (BaseResourceReferenceDt.class.isAssignableFrom(theDatatype)) {
|
if (BaseResourceReferenceDt.class.isAssignableFrom(theDatatype)) {
|
||||||
return getElementName();
|
return getElementName();
|
||||||
}
|
}
|
||||||
|
@ -58,7 +60,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) {
|
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
if (BaseResourceReferenceDt.class.isAssignableFrom(theDatatype)) {
|
if (BaseResourceReferenceDt.class.isAssignableFrom(theDatatype)) {
|
||||||
return myRuntimeDef;
|
return myRuntimeDef;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +78,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
myRuntimeDef = new RuntimeResourceReferenceDefinition(getElementName(), myResourceTypes);
|
myRuntimeDef = new RuntimeResourceReferenceDefinition(getElementName(), myResourceTypes);
|
||||||
myRuntimeDef.sealAndInitialize(theClassToElementDefinitions);
|
myRuntimeDef.sealAndInitialize(theClassToElementDefinitions);
|
||||||
|
|
||||||
|
@ -84,9 +86,9 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
||||||
myValidChildNames.add(getElementName());
|
myValidChildNames.add(getElementName());
|
||||||
myValidChildNames.add(getElementName() + "Resource");
|
myValidChildNames.add(getElementName() + "Resource");
|
||||||
|
|
||||||
for (Class<? extends IResource> next : myResourceTypes) {
|
for (Class<? extends IBaseResource> next : myResourceTypes) {
|
||||||
if (next == IResource.class) {
|
if (next == IResource.class) {
|
||||||
for (Entry<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> nextEntry : theClassToElementDefinitions.entrySet()) {
|
for (Entry<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> nextEntry : theClassToElementDefinitions.entrySet()) {
|
||||||
if (IResource.class.isAssignableFrom(nextEntry.getKey())) {
|
if (IResource.class.isAssignableFrom(nextEntry.getKey())) {
|
||||||
RuntimeResourceDefinition nextDef = (RuntimeResourceDefinition) nextEntry.getValue();
|
RuntimeResourceDefinition nextDef = (RuntimeResourceDefinition) nextEntry.getValue();
|
||||||
myValidChildNames.add(getElementName() + nextDef.getName());
|
myValidChildNames.add(getElementName() + nextDef.getName());
|
||||||
|
@ -105,7 +107,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
||||||
myValidChildNames = Collections.unmodifiableSet(myValidChildNames);
|
myValidChildNames = Collections.unmodifiableSet(myValidChildNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Class<? extends IResource>> getResourceTypes() {
|
public List<Class<? extends IBaseResource>> getResourceTypes() {
|
||||||
return myResourceTypes;
|
return myResourceTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,10 @@ import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
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.base.composite.BaseResourceReferenceDt;
|
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||||
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||||
|
@ -40,8 +40,8 @@ import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||||
public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildDefinition {
|
public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
private Map<String, BaseRuntimeElementDefinition<?>> myAttributeNameToDefinition;
|
private Map<String, BaseRuntimeElementDefinition<?>> myAttributeNameToDefinition;
|
||||||
private Map<Class<? extends IElement>, String> myDatatypeToAttributeName;
|
private Map<Class<? extends IBase>, String> myDatatypeToAttributeName;
|
||||||
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myDatatypeToDefinition;
|
private Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> myDatatypeToDefinition;
|
||||||
|
|
||||||
public RuntimeChildUndeclaredExtensionDefinition() {
|
public RuntimeChildUndeclaredExtensionDefinition() {
|
||||||
// nothing
|
// nothing
|
||||||
|
@ -58,19 +58,19 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||||
return myDatatypeToAttributeName.get(theDatatype);
|
return myDatatypeToAttributeName.get(theDatatype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theType) {
|
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType) {
|
||||||
return myDatatypeToDefinition.get(theType);
|
return myDatatypeToDefinition.get(theType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
Map<String, BaseRuntimeElementDefinition<?>> datatypeAttributeNameToDefinition = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
Map<String, BaseRuntimeElementDefinition<?>> datatypeAttributeNameToDefinition = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
||||||
myDatatypeToAttributeName = new HashMap<Class<? extends IElement>, String>();
|
myDatatypeToAttributeName = new HashMap<Class<? extends IBase>, String>();
|
||||||
|
|
||||||
for (BaseRuntimeElementDefinition<?> next : theClassToElementDefinitions.values()) {
|
for (BaseRuntimeElementDefinition<?> next : theClassToElementDefinitions.values()) {
|
||||||
if (next instanceof IRuntimeDatatypeDefinition) {
|
if (next instanceof IRuntimeDatatypeDefinition) {
|
||||||
|
@ -89,7 +89,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
||||||
|
|
||||||
myAttributeNameToDefinition = datatypeAttributeNameToDefinition;
|
myAttributeNameToDefinition = datatypeAttributeNameToDefinition;
|
||||||
|
|
||||||
myDatatypeToDefinition = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
|
myDatatypeToDefinition = new HashMap<Class<? extends IBase>, BaseRuntimeElementDefinition<?>>();
|
||||||
|
|
||||||
for (Entry<String, BaseRuntimeElementDefinition<?>> next : myAttributeNameToDefinition.entrySet()) {
|
for (Entry<String, BaseRuntimeElementDefinition<?>> next : myAttributeNameToDefinition.entrySet()) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -112,7 +112,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
||||||
public IAccessor getAccessor() {
|
public IAccessor getAccessor() {
|
||||||
return new IAccessor() {
|
return new IAccessor() {
|
||||||
@Override
|
@Override
|
||||||
public List<? extends IElement> getValues(Object theTarget) {
|
public List<? extends IBase> getValues(Object theTarget) {
|
||||||
ExtensionDt target = (ExtensionDt) theTarget;
|
ExtensionDt target = (ExtensionDt) theTarget;
|
||||||
if (target.getValue() != null) {
|
if (target.getValue() != null) {
|
||||||
return Collections.singletonList(target.getValue());
|
return Collections.singletonList(target.getValue());
|
||||||
|
@ -126,7 +126,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
||||||
public IMutator getMutator() {
|
public IMutator getMutator() {
|
||||||
return new IMutator() {
|
return new IMutator() {
|
||||||
@Override
|
@Override
|
||||||
public void addValue(Object theTarget, IElement theValue) {
|
public void addValue(Object theTarget, IBase theValue) {
|
||||||
ExtensionDt target = (ExtensionDt) theTarget;
|
ExtensionDt target = (ExtensionDt) theTarget;
|
||||||
if (theValue instanceof IDatatype) {
|
if (theValue instanceof IDatatype) {
|
||||||
target.setValue((IDatatype) theTarget);
|
target.setValue((IDatatype) theTarget);
|
||||||
|
|
|
@ -20,16 +20,18 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
|
||||||
|
import org.hl7.fhir.instance.model.ICompositeType;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
|
|
||||||
public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompositeDefinition<ICompositeDatatype> implements IRuntimeDatatypeDefinition {
|
public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompositeDefinition<ICompositeType> implements IRuntimeDatatypeDefinition {
|
||||||
|
|
||||||
private boolean mySpecialization;
|
private boolean mySpecialization;
|
||||||
|
|
||||||
public RuntimeCompositeDatatypeDefinition(DatatypeDef theDef, Class<? extends ICompositeDatatype> theImplementingClass) {
|
public RuntimeCompositeDatatypeDefinition(DatatypeDef theDef, Class<? extends ICompositeType> theImplementingClass) {
|
||||||
super(theDef.name(), theImplementingClass);
|
super(theDef.name(), theImplementingClass);
|
||||||
|
|
||||||
String resourceName = theDef.name();
|
String resourceName = theDef.name();
|
||||||
|
|
|
@ -25,15 +25,16 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.ICompositeType;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
|
|
||||||
public class RuntimeExtensionDtDefinition extends RuntimeCompositeDatatypeDefinition {
|
public class RuntimeExtensionDtDefinition extends RuntimeCompositeDatatypeDefinition {
|
||||||
|
|
||||||
private List<BaseRuntimeChildDefinition> myChildren;
|
private List<BaseRuntimeChildDefinition> myChildren;
|
||||||
|
|
||||||
public RuntimeExtensionDtDefinition(DatatypeDef theDef, Class<? extends ICompositeDatatype> theImplementingClass) {
|
public RuntimeExtensionDtDefinition(DatatypeDef theDef, Class<? extends ICompositeType> theImplementingClass) {
|
||||||
super(theDef, theImplementingClass);
|
super(theDef, theImplementingClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ public class RuntimeExtensionDtDefinition extends RuntimeCompositeDatatypeDefini
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
public void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
super.sealAndInitialize(theClassToElementDefinitions);
|
super.sealAndInitialize(theClassToElementDefinitions);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -20,20 +20,21 @@ package ca.uhn.fhir.context;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
|
|
||||||
public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition<IPrimitiveDatatype<?>> implements IRuntimeDatatypeDefinition {
|
public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition<IPrimitiveType> implements IRuntimeDatatypeDefinition {
|
||||||
|
|
||||||
private boolean mySpecialization;
|
private boolean mySpecialization;
|
||||||
|
|
||||||
public RuntimePrimitiveDatatypeDefinition(DatatypeDef theDef, Class<? extends IPrimitiveDatatype<?>> theImplementingClass) {
|
public RuntimePrimitiveDatatypeDefinition(DatatypeDef theDef, Class<? extends IPrimitiveType> theImplementingClass) {
|
||||||
super(theDef.name(), theImplementingClass);
|
super(theDef.name(), theImplementingClass);
|
||||||
|
|
||||||
String resourceName = theDef.name();
|
String resourceName = theDef.name();
|
||||||
|
@ -50,7 +51,7 @@ public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefini
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@ package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||||
|
|
||||||
public class RuntimePrimitiveDatatypeNarrativeDefinition extends BaseRuntimeElementDefinition<XhtmlDt> {
|
public class RuntimePrimitiveDatatypeNarrativeDefinition extends BaseRuntimeElementDefinition<XhtmlDt> {
|
||||||
|
@ -37,7 +38,7 @@ public class RuntimePrimitiveDatatypeNarrativeDefinition extends BaseRuntimeEle
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,13 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.IBaseResource;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
|
|
||||||
public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefinition<IResource> {
|
public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefinition<IBaseResource> {
|
||||||
|
|
||||||
private RuntimeResourceDefinition myBaseDefinition;
|
private RuntimeResourceDefinition myBaseDefinition;
|
||||||
private Map<String, RuntimeSearchParam> myNameToSearchParam = new LinkedHashMap<String, RuntimeSearchParam>();
|
private Map<String, RuntimeSearchParam> myNameToSearchParam = new LinkedHashMap<String, RuntimeSearchParam>();
|
||||||
|
@ -41,7 +43,7 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
||||||
private FhirContext myContext;
|
private FhirContext myContext;
|
||||||
private String myId;
|
private String myId;
|
||||||
|
|
||||||
public RuntimeResourceDefinition(FhirContext theContext, String theResourceName, Class<? extends IResource> theClass, ResourceDef theResourceAnnotation) {
|
public RuntimeResourceDefinition(FhirContext theContext, String theResourceName, Class<? extends IBaseResource> theClass, ResourceDef theResourceAnnotation) {
|
||||||
super(theResourceName, theClass);
|
super(theResourceName, theClass);
|
||||||
myContext= theContext;
|
myContext= theContext;
|
||||||
myResourceProfile = theResourceAnnotation.profile();
|
myResourceProfile = theResourceAnnotation.profile();
|
||||||
|
@ -91,7 +93,7 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
public void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
super.sealAndInitialize(theClassToElementDefinitions);
|
super.sealAndInitialize(theClassToElementDefinitions);
|
||||||
|
|
||||||
myNameToSearchParam = Collections.unmodifiableMap(myNameToSearchParam);
|
myNameToSearchParam = Collections.unmodifiableMap(myNameToSearchParam);
|
||||||
|
|
|
@ -24,16 +24,19 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import org.hl7.fhir.instance.model.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.Resource;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||||
|
|
||||||
public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefinition<BaseResourceReferenceDt> {
|
public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefinition<BaseResourceReferenceDt> {
|
||||||
|
|
||||||
private final List<Class<? extends IResource>> myResourceTypes;
|
private final List<Class<? extends IBaseResource>> myResourceTypes;
|
||||||
private HashMap<Class<? extends IResource>, RuntimeResourceDefinition> myResourceTypeToDefinition;
|
private HashMap<Class<? extends IBaseResource>, RuntimeResourceDefinition> myResourceTypeToDefinition;
|
||||||
|
|
||||||
public RuntimeResourceReferenceDefinition(String theName, List<Class<? extends IResource>> theResourceTypes) {
|
public RuntimeResourceReferenceDefinition(String theName, List<Class<? extends IBaseResource>> theResourceTypes) {
|
||||||
super(theName, BaseResourceReferenceDt.class);
|
super(theName, BaseResourceReferenceDt.class);
|
||||||
if (theResourceTypes == null || theResourceTypes.isEmpty()) {
|
if (theResourceTypes == null || theResourceTypes.isEmpty()) {
|
||||||
throw new ConfigurationException("Element '" + theName + "' has no resource types noted");
|
throw new ConfigurationException("Element '" + theName + "' has no resource types noted");
|
||||||
|
@ -41,15 +44,15 @@ public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefini
|
||||||
myResourceTypes = theResourceTypes;
|
myResourceTypes = theResourceTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Class<? extends IResource>> getResourceTypes() {
|
public List<Class<? extends IBaseResource>> getResourceTypes() {
|
||||||
return myResourceTypes;
|
return myResourceTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||||
myResourceTypeToDefinition = new HashMap<Class<? extends IResource>, RuntimeResourceDefinition>();
|
myResourceTypeToDefinition = new HashMap<Class<? extends IBaseResource>, RuntimeResourceDefinition>();
|
||||||
for (Class<? extends IResource> next : myResourceTypes) {
|
for (Class<? extends IBaseResource> next : myResourceTypes) {
|
||||||
if (next.equals(IResource.class)) {
|
if (next.equals(IResource.class) || next.equals(Resource.class)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RuntimeResourceDefinition definition = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next);
|
RuntimeResourceDefinition definition = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next);
|
||||||
|
|
|
@ -20,7 +20,9 @@ package ca.uhn.fhir.parser;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
@ -49,6 +51,7 @@ import javax.json.stream.JsonParsingException;
|
||||||
|
|
||||||
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.hl7.fhir.instance.model.IBaseResource;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
|
@ -835,7 +838,7 @@ public class JsonParser extends BaseParser implements IParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends IResource> T parseResource(Class<T> theResourceType, Reader theReader) {
|
public <T extends IBaseResource> T parseResource(Class<T> theResourceType, Reader theReader) {
|
||||||
JsonReader reader = Json.createReader(theReader);
|
JsonReader reader = Json.createReader(theReader);
|
||||||
JsonObject object = reader.readObject();
|
JsonObject object = reader.readObject();
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,9 @@ package ca.uhn.fhir.parser;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -32,6 +34,7 @@ import javax.xml.stream.events.XMLEvent;
|
||||||
|
|
||||||
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.hl7.fhir.instance.model.IBaseResource;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
|
@ -53,6 +56,7 @@ import ca.uhn.fhir.model.api.ICompositeElement;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
import ca.uhn.fhir.model.api.IIdentifiableElement;
|
import ca.uhn.fhir.model.api.IIdentifiableElement;
|
||||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.IBaseResource;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.IResourceBlock;
|
import ca.uhn.fhir.model.api.IResourceBlock;
|
||||||
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
|
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
|
||||||
|
@ -135,7 +139,7 @@ class ParserState<T> {
|
||||||
if (def == null) {
|
if (def == null) {
|
||||||
throw new DataFormatException("Entry references unknown resource type: " + resourceType);
|
throw new DataFormatException("Entry references unknown resource type: " + resourceType);
|
||||||
}
|
}
|
||||||
resource = def.newInstance();
|
resource = (IResource) def.newInstance();
|
||||||
resource.setId(id);
|
resource.setId(id);
|
||||||
entry.setResource(resource);
|
entry.setResource(resource);
|
||||||
}
|
}
|
||||||
|
@ -164,7 +168,7 @@ class ParserState<T> {
|
||||||
myState.xmlEvent(theNextEvent);
|
myState.xmlEvent(theNextEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ParserState<Bundle> getPreAtomInstance(FhirContext theContext, Class<? extends IResource> theResourceType, boolean theJsonMode) throws DataFormatException {
|
public static ParserState<Bundle> getPreAtomInstance(FhirContext theContext, Class<? extends IBaseResource> theResourceType, boolean theJsonMode) throws DataFormatException {
|
||||||
ParserState<Bundle> retVal = new ParserState<Bundle>(theContext, theJsonMode);
|
ParserState<Bundle> retVal = new ParserState<Bundle>(theContext, theJsonMode);
|
||||||
retVal.push(retVal.new PreAtomState(theResourceType));
|
retVal.push(retVal.new PreAtomState(theResourceType));
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -174,7 +178,7 @@ class ParserState<T> {
|
||||||
* @param theResourceType
|
* @param theResourceType
|
||||||
* May be null
|
* May be null
|
||||||
*/
|
*/
|
||||||
public static <T extends IResource> ParserState<T> getPreResourceInstance(Class<T> theResourceType, FhirContext theContext, boolean theJsonMode) throws DataFormatException {
|
public static <T extends IBaseResource> ParserState<T> getPreResourceInstance(Class<T> theResourceType, FhirContext theContext, boolean theJsonMode) throws DataFormatException {
|
||||||
ParserState<T> retVal = new ParserState<T>(theContext, theJsonMode);
|
ParserState<T> retVal = new ParserState<T>(theContext, theJsonMode);
|
||||||
retVal.push(retVal.new PreResourceState(theResourceType));
|
retVal.push(retVal.new PreResourceState(theResourceType));
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -291,7 +295,7 @@ class ParserState<T> {
|
||||||
|
|
||||||
public class AtomDeletedEntryState extends AtomEntryState {
|
public class AtomDeletedEntryState extends AtomEntryState {
|
||||||
|
|
||||||
public AtomDeletedEntryState(Bundle theInstance, Class<? extends IResource> theResourceType) {
|
public AtomDeletedEntryState(Bundle theInstance, Class<? extends IBaseResource> theResourceType) {
|
||||||
super(theInstance, theResourceType);
|
super(theInstance, theResourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,9 +392,9 @@ class ParserState<T> {
|
||||||
|
|
||||||
private boolean myDeleted;
|
private boolean myDeleted;
|
||||||
private BundleEntry myEntry;
|
private BundleEntry myEntry;
|
||||||
private Class<? extends IResource> myResourceType;
|
private Class<? extends IBaseResource> myResourceType;
|
||||||
|
|
||||||
public AtomEntryState(Bundle theInstance, Class<? extends IResource> theResourceType) {
|
public AtomEntryState(Bundle theInstance, Class<? extends IBaseResource> theResourceType) {
|
||||||
super(null);
|
super(null);
|
||||||
myEntry = new BundleEntry();
|
myEntry = new BundleEntry();
|
||||||
myResourceType = theResourceType;
|
myResourceType = theResourceType;
|
||||||
|
@ -601,9 +605,9 @@ class ParserState<T> {
|
||||||
private class AtomState extends BaseState {
|
private class AtomState extends BaseState {
|
||||||
|
|
||||||
private Bundle myInstance;
|
private Bundle myInstance;
|
||||||
private Class<? extends IResource> myResourceType;
|
private Class<? extends IBaseResource> myResourceType;
|
||||||
|
|
||||||
public AtomState(Bundle theInstance, Class<? extends IResource> theResourceType) {
|
public AtomState(Bundle theInstance, Class<? extends IBaseResource> theResourceType) {
|
||||||
super(null);
|
super(null);
|
||||||
myInstance = theInstance;
|
myInstance = theInstance;
|
||||||
myResourceType = theResourceType;
|
myResourceType = theResourceType;
|
||||||
|
@ -750,8 +754,8 @@ class ParserState<T> {
|
||||||
if ("id".equals(theName)) {
|
if ("id".equals(theName)) {
|
||||||
if (myInstance instanceof IIdentifiableElement) {
|
if (myInstance instanceof IIdentifiableElement) {
|
||||||
((IIdentifiableElement) myInstance).setElementSpecificId((theValue));
|
((IIdentifiableElement) myInstance).setElementSpecificId((theValue));
|
||||||
} else if (myInstance instanceof IResource) {
|
} else if (myInstance instanceof IBaseResource) {
|
||||||
((IResource) myInstance).setId(new IdDt(theValue));
|
((IBaseResource) myInstance).setId(new IdDt(theValue));
|
||||||
}
|
}
|
||||||
} else if ("contentType".equals(theName)) {
|
} else if ("contentType".equals(theName)) {
|
||||||
myInstance.setContentType(theValue);
|
myInstance.setContentType(theValue);
|
||||||
|
@ -822,7 +826,7 @@ class ParserState<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void wereBack() {
|
public void wereBack() {
|
||||||
IResource res = getCurrentElement();
|
IBaseResource res = getCurrentElement();
|
||||||
assert res != null;
|
assert res != null;
|
||||||
if (res.getId() == null || res.getId().isEmpty()) {
|
if (res.getId() == null || res.getId().isEmpty()) {
|
||||||
ourLog.debug("Discarding contained resource with no ID!");
|
ourLog.debug("Discarding contained resource with no ID!");
|
||||||
|
@ -936,8 +940,8 @@ class ParserState<T> {
|
||||||
if ("id".equals(theName)) {
|
if ("id".equals(theName)) {
|
||||||
if (myInstance instanceof IIdentifiableElement) {
|
if (myInstance instanceof IIdentifiableElement) {
|
||||||
((IIdentifiableElement) myInstance).setElementSpecificId((theValue));
|
((IIdentifiableElement) myInstance).setElementSpecificId((theValue));
|
||||||
} else if (myInstance instanceof IResource) {
|
} else if (myInstance instanceof IBaseResource) {
|
||||||
((IResource) myInstance).setId(new IdDt(theValue));
|
((IBaseResource) myInstance).setId(new IdDt(theValue));
|
||||||
}
|
}
|
||||||
} else if ("url".equals(theName) && myInstance instanceof ExtensionDt) {
|
} else if ("url".equals(theName) && myInstance instanceof ExtensionDt) {
|
||||||
((ExtensionDt) myInstance).setUrl(theValue);
|
((ExtensionDt) myInstance).setUrl(theValue);
|
||||||
|
@ -1125,9 +1129,9 @@ class ParserState<T> {
|
||||||
private class PreAtomState extends BaseState {
|
private class PreAtomState extends BaseState {
|
||||||
|
|
||||||
private Bundle myInstance;
|
private Bundle myInstance;
|
||||||
private Class<? extends IResource> myResourceType;
|
private Class<? extends IBaseResource> myResourceType;
|
||||||
|
|
||||||
public PreAtomState(Class<? extends IResource> theResourceType) {
|
public PreAtomState(Class<? extends IBaseResource> theResourceType) {
|
||||||
super(null);
|
super(null);
|
||||||
myResourceType = theResourceType;
|
myResourceType = theResourceType;
|
||||||
}
|
}
|
||||||
|
@ -1162,19 +1166,19 @@ class ParserState<T> {
|
||||||
* Stitch together resource references
|
* Stitch together resource references
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Map<String, IResource> idToResource = new HashMap<String, IResource>();
|
Map<String, IBaseResource> idToResource = new HashMap<String, IBaseResource>();
|
||||||
List<IResource> resources = myInstance.toListOfResources();
|
List<IBaseResource> resources = myInstance.toListOfResources();
|
||||||
for (IResource next : resources) {
|
for (IBaseResource next : resources) {
|
||||||
if (next.getId() != null && next.getId().isEmpty() == false) {
|
if (next.getId() != null && next.getId().isEmpty() == false) {
|
||||||
idToResource.put(next.getId().toUnqualifiedVersionless().getValue(), next);
|
idToResource.put(next.getId().toUnqualifiedVersionless().getValue(), next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IResource next : resources) {
|
for (IBaseResource next : resources) {
|
||||||
List<ResourceReferenceDt> refs = myContext.newTerser().getAllPopulatedChildElementsOfType(next, ResourceReferenceDt.class);
|
List<ResourceReferenceDt> refs = myContext.newTerser().getAllPopulatedChildElementsOfType(next, ResourceReferenceDt.class);
|
||||||
for (ResourceReferenceDt nextRef : refs) {
|
for (ResourceReferenceDt nextRef : refs) {
|
||||||
if (nextRef.isEmpty() == false && nextRef.getReference() != null) {
|
if (nextRef.isEmpty() == false && nextRef.getReference() != null) {
|
||||||
IResource target = idToResource.get(nextRef.getReference().getValue());
|
IBaseResource target = idToResource.get(nextRef.getReference().getValue());
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
nextRef.setResource(target);
|
nextRef.setResource(target);
|
||||||
}
|
}
|
||||||
|
@ -1188,13 +1192,13 @@ class ParserState<T> {
|
||||||
|
|
||||||
private class PreResourceState extends BaseState {
|
private class PreResourceState extends BaseState {
|
||||||
|
|
||||||
private Map<String, IResource> myContainedResources = new HashMap<String, IResource>();
|
private Map<String, IBaseResource> myContainedResources = new HashMap<String, IBaseResource>();
|
||||||
private BundleEntry myEntry;
|
private BundleEntry myEntry;
|
||||||
private IResource myInstance;
|
private IBaseResource myInstance;
|
||||||
private List<ResourceReferenceDt> myResourceReferences = new ArrayList<ResourceReferenceDt>();
|
private List<ResourceReferenceDt> myResourceReferences = new ArrayList<ResourceReferenceDt>();
|
||||||
private Class<? extends IResource> myResourceType;
|
private Class<? extends IBaseResource> myResourceType;
|
||||||
|
|
||||||
public PreResourceState(BundleEntry theEntry, Class<? extends IResource> theResourceType) {
|
public PreResourceState(BundleEntry theEntry, Class<? extends IBaseResource> theResourceType) {
|
||||||
super(null);
|
super(null);
|
||||||
myEntry = theEntry;
|
myEntry = theEntry;
|
||||||
myResourceType = theResourceType;
|
myResourceType = theResourceType;
|
||||||
|
@ -1204,7 +1208,7 @@ class ParserState<T> {
|
||||||
* @param theResourceType
|
* @param theResourceType
|
||||||
* May be null
|
* May be null
|
||||||
*/
|
*/
|
||||||
public PreResourceState(Class<? extends IResource> theResourceType) {
|
public PreResourceState(Class<? extends IBaseResource> theResourceType) {
|
||||||
super(null);
|
super(null);
|
||||||
myResourceType = theResourceType;
|
myResourceType = theResourceType;
|
||||||
}
|
}
|
||||||
|
@ -1249,12 +1253,12 @@ class ParserState<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, IResource> getContainedResources() {
|
public Map<String, IBaseResource> getContainedResources() {
|
||||||
return myContainedResources;
|
return myContainedResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IResource getCurrentElement() {
|
protected IBaseResource getCurrentElement() {
|
||||||
return myInstance;
|
return myInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1297,7 +1301,7 @@ class ParserState<T> {
|
||||||
String ref = nextRef.getReference().getValue();
|
String ref = nextRef.getReference().getValue();
|
||||||
if (isNotBlank(ref)) {
|
if (isNotBlank(ref)) {
|
||||||
if (ref.startsWith("#")) {
|
if (ref.startsWith("#")) {
|
||||||
IResource target = myContainedResources.get(ref.substring(1));
|
IBaseResource target = myContainedResources.get(ref.substring(1));
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
nextRef.setResource(target);
|
nextRef.setResource(target);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1369,8 +1373,8 @@ class ParserState<T> {
|
||||||
} else if ("id".equals(theName)) {
|
} else if ("id".equals(theName)) {
|
||||||
if (myInstance instanceof IIdentifiableElement) {
|
if (myInstance instanceof IIdentifiableElement) {
|
||||||
((IIdentifiableElement) myInstance).setElementSpecificId(theValue);
|
((IIdentifiableElement) myInstance).setElementSpecificId(theValue);
|
||||||
} else if (myInstance instanceof IResource) {
|
} else if (myInstance instanceof IBaseResource) {
|
||||||
((IResource) myInstance).setId(new IdDt(theValue));
|
((IBaseResource) myInstance).setId(new IdDt(theValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
/bin/
|
|
Loading…
Reference in New Issue