Still not parsing

This commit is contained in:
jamesagnew 2014-02-18 18:10:50 -05:00
parent 87d4eb7c90
commit 5e97109f4c
50 changed files with 401 additions and 204 deletions

View File

@ -1,54 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
<classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar" sourcepath="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar" sourcepath="M2_REPO/commons-io/commons-io/1.3.2/commons-io-1.3.2-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/commons-io/commons-io/1.3.2/commons-io-1.3.2-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar" sourcepath="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.2.4/gson-2.2.4-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4-javadoc.jar!/" name="javadoc_location"/>
<attribute value="jar:file:/home/t3903uhn/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar">
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0.jar" sourcepath="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/" name="javadoc_location"/>
<attribute value="jar:file:/home/t3903uhn/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar" sourcepath="M2_REPO/junit/junit/4.11/junit-4.11-sources.jar">
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1.jar" sourcepath="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar" sourcepath="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/junit/junit/4.11/junit-4.11-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-javadoc.jar!/" name="javadoc_location"/>
<attribute value="jar:file:/home/t3903uhn/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-javadoc.jar!/" name="javadoc_location"/>
<attribute value="jar:file:/home/t3903uhn/.m2/repository/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1.jar" sourcepath="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0.jar" sourcepath="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-sources.jar">
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-sources.jar">
<attributes>
<attribute value="jar:file:/Users/james/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-javadoc.jar!/" name="javadoc_location"/>
<attribute value="jar:file:/home/t3903uhn/.m2/repository/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-sources.jar">
<attributes>
<attribute value="jar:file:/home/t3903uhn/.m2/repository/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar" sourcepath="M2_REPO/junit/junit/4.11/junit-4.11-sources.jar">
<attributes>
<attribute value="jar:file:/home/t3903uhn/.m2/repository/junit/junit/4.11/junit-4.11-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar">
<attributes>
<attribute value="jar:file:/home/t3903uhn/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar" sourcepath="M2_REPO/commons-io/commons-io/1.3.2/commons-io-1.3.2-sources.jar">
<attributes>
<attribute value="jar:file:/home/t3903uhn/.m2/repository/commons-io/commons-io/1.3.2/commons-io-1.3.2-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
</classpath>

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hapi-fhir-base</name>
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>

View File

@ -1,21 +1,57 @@
package ca.uhn.fhir.context;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.IDatatype;
import ca.uhn.fhir.model.api.IElement;
public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeChildDefinition {
private Class<? extends ICodeEnum> myCodeType;
private Class<? extends IDatatype> myDatatype;
private BaseRuntimeElementDefinition<?> myElementDefinition;
public BaseRuntimeChildDatatypeDefinition(Field theField, String theElementName, int theMin, int theMax, Class<? extends IDatatype> theDatatype) {
super(theField, theMin, theMax, theElementName);
myDatatype = theDatatype;
}
@Override
public BaseRuntimeElementDefinition<?> getChildByName(String theName) {
if (getElementName().equals(theName)) {
return myElementDefinition;
}
return null;
}
public Class<? extends ICodeEnum> getCodeType() {
return myCodeType;
}
public Class<? extends IDatatype> getDatatype() {
return myDatatype;
}
@Override
public Set<String> getValidChildNames() {
return Collections.singleton(getElementName());
}
@Override
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
myElementDefinition = theClassToElementDefinitions.get(getDatatype());
}
public void setCodeType(Class<? extends ICodeEnum> theType) {
if (myElementDefinition != null) {
throw new IllegalStateException("Can not set code type at runtime");
}
myCodeType = theType;
}
}

View File

@ -1,16 +1,19 @@
package ca.uhn.fhir.context;
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Set;
import ca.uhn.fhir.model.api.IElement;
public abstract class BaseRuntimeChildDefinition {
private Field myField;
private int myMin;
private int myMax;
private String myElementName;
private final Field myField;
private final int myMin;
private final int myMax;
private final String myElementName;
BaseRuntimeChildDefinition(Field theField, int theMin, int theMax, String theElementName) throws ConfigurationException {
super();
@ -53,4 +56,7 @@ public abstract class BaseRuntimeChildDefinition {
public abstract BaseRuntimeElementDefinition<?> getChildByName(String theName);
abstract void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions);
}

View File

@ -1,16 +1,19 @@
package ca.uhn.fhir.context;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ca.uhn.fhir.model.api.ICompositeElement;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.parser.DataFormatException;
public class BaseRuntimeElementCompositeDefinition<T extends ICompositeElement> extends BaseRuntimeElementDefinition<T> {
public abstract class BaseRuntimeElementCompositeDefinition<T extends ICompositeElement> extends BaseRuntimeElementDefinition<T> {
private ArrayList<BaseRuntimeChildDefinition> myChildren = new ArrayList<BaseRuntimeChildDefinition>();
private Map<String, BaseRuntimeChildDefinition> myNameToChild=new HashMap<String, BaseRuntimeChildDefinition>();
private List<BaseRuntimeChildDefinition> myChildren = new ArrayList<BaseRuntimeChildDefinition>();
private Map<String, BaseRuntimeChildDefinition> myNameToChild = new HashMap<String, BaseRuntimeChildDefinition>();
public BaseRuntimeElementCompositeDefinition(String theName, Class<? extends T> theImplementingClass) {
super(theName, theImplementingClass);
@ -18,14 +21,34 @@ public class BaseRuntimeElementCompositeDefinition<T extends ICompositeElement>
public void addChild(BaseRuntimeChildDefinition theNext) {
myChildren.add(theNext);
myNameToChild.put(theNext.getElementName(), theNext);
}
public BaseRuntimeChildDefinition getChildByNameOrThrowDataFormatException(String theName) throws DataFormatException {
BaseRuntimeChildDefinition retVal = myNameToChild.get(theName);
if (retVal==null) {
public BaseRuntimeElementDefinition<?> getChildByNameOrThrowDataFormatException(String theName) throws DataFormatException {
BaseRuntimeElementDefinition<?> retVal = myNameToChild.get(theName);
if (retVal == null) {
throw new DataFormatException("Unknown child name: " + theName);
}
return retVal;
}
@Override
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
for (BaseRuntimeChildDefinition next : myChildren) {
next.sealAndInitialize(theClassToElementDefinitions);
}
myNameToChild = new HashMap<String, BaseRuntimeElementDefinition<?>>();
for (BaseRuntimeChildDefinition next : myChildren) {
for (String nextName : next.getValidChildNames()) {
if (myNameToChild.containsKey(nextName)) {
throw new ConfigurationException("Duplicate child name: " + nextName);
} else {
myNameToChild.put(nextName, next);
}
}
}
myChildren = Collections.unmodifiableList(myChildren);
myNameToChild = Collections.unmodifiableMap(myNameToChild);
}
}

View File

@ -1,5 +1,7 @@
package ca.uhn.fhir.context;
import java.util.Map;
import ca.uhn.fhir.model.api.IElement;
public abstract class BaseRuntimeElementDefinition<T extends IElement> {
@ -24,4 +26,16 @@ public abstract class BaseRuntimeElementDefinition<T extends IElement> {
return myImplementingClass;
}
/**
* Invoked prior to use to perform any initialization and make object mutable
*/
abstract void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions);
public abstract ChildTypeEnum getChildType();
public enum ChildTypeEnum {
COMPOSITE_DATATYPE, PRIMITIVE_DATATYPE, RESOURCE
}
}

View File

@ -7,14 +7,14 @@ import ca.uhn.fhir.model.api.IResource;
public class FhirContext {
private final Map<String, BaseRuntimeElementDefinition<?>> myNameToElementDefinition;
private final Map<String, RuntimeResourceDefinition> myNameToElementDefinition;
public FhirContext(Class<? extends IResource>... theResourceTypes) {
ModelScanner scanner = new ModelScanner(theResourceTypes);
myNameToElementDefinition = Collections.unmodifiableMap(scanner.getNameToElementDefinitions());
myNameToElementDefinition = Collections.unmodifiableMap(scanner.getNameToResourceDefinitions());
}
public Map<String, BaseRuntimeElementDefinition<?>> getNameToElementDefinition() {
public Map<String, RuntimeResourceDefinition> getNameToResourceDefinition() {
return myNameToElementDefinition;
}

View File

@ -1,13 +1,13 @@
package ca.uhn.fhir.context;
import static org.apache.commons.lang3.StringUtils.*;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -23,15 +23,17 @@ import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceReference;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.ChildResource;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.Choice;
import ca.uhn.fhir.model.resource.ResourceDefinition;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.datatype.ICodedDatatype;
class ModelScanner {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelScanner.class);
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myClassToResourceDefinitions = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
private Map<String, RuntimeResourceDefinition> myNameToElementDefinitions = new HashMap<String, RuntimeResourceDefinition>();
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myClassToElementDefinitions = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
private Map<String, RuntimeResourceDefinition> myNameToResourceDefinitions = new HashMap<String, RuntimeResourceDefinition>();
private Set<Class<? extends IElement>> myScanAlso = new HashSet<Class<? extends IElement>>();
// private Map<String, RuntimeResourceDefinition>
@ -39,32 +41,50 @@ class ModelScanner {
// RuntimeDatatypeDefinition>();
public Map<String, RuntimeResourceDefinition> getNameToResourceDefinitions() {
return (myNameToElementDefinitions);
return (myNameToResourceDefinitions);
}
ModelScanner(Class<? extends IResource>... theResourceTypes) throws ConfigurationException {
for (Class<? extends IResource> nextClass : theResourceTypes) {
Set<Class<? extends IElement>> toScan = new HashSet<Class<? extends IElement>>(Arrays.asList(theResourceTypes));
do {
for (Class<? extends IElement> nextClass : toScan) {
scan(nextClass);
}
for (Iterator<Class<? extends IElement>> iter = myScanAlso.iterator(); iter.hasNext(); ) {
if (myClassToElementDefinitions.containsKey(iter.next())) {
iter.remove();
}
}
toScan.clear();
toScan.addAll(myScanAlso);
myScanAlso.clear();
} while (!myScanAlso.isEmpty());
for (BaseRuntimeElementDefinition<?> next : myClassToElementDefinitions.values()) {
next.sealAndInitialize(myClassToElementDefinitions);
}
}
private String scan(Class<? extends IElement> theClass) throws ConfigurationException {
BaseRuntimeElementDefinition<?> existingDef = myClassToResourceDefinitions.get(theClass);
BaseRuntimeElementDefinition<?> existingDef = myClassToElementDefinitions.get(theClass);
if (existingDef != null) {
return existingDef.getName();
}
ResourceDefinition resourceDefinition = theClass.getAnnotation(ResourceDefinition.class);
ResourceDef resourceDefinition = theClass.getAnnotation(ResourceDef.class);
if (resourceDefinition != null) {
if (!IResource.class.isAssignableFrom(theClass)) {
throw new ConfigurationException("Resource type contains a @" + ResourceDefinition.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")
Class<? extends IResource> resClass = (Class<? extends IResource>) theClass;
return scanResource(resClass, resourceDefinition);
}
Datatype datatypeDefinition = theClass.getAnnotation(Datatype.class);
DatatypeDef datatypeDefinition = theClass.getAnnotation(DatatypeDef.class);
if (datatypeDefinition != null) {
if (ICompositeDatatype.class.isAssignableFrom(theClass)) {
@SuppressWarnings("unchecked")
@ -75,77 +95,92 @@ class ModelScanner {
Class<? extends IPrimitiveDatatype> resClass = (Class<? extends IPrimitiveDatatype>) theClass;
return scanPrimitiveDatatype(resClass, datatypeDefinition);
} else {
throw new ConfigurationException("Resource type contains a @" + Datatype.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());
}
}
throw new ConfigurationException("Resource type does not contain a @" + ResourceDefinition.class.getSimpleName() + " annotation or a @" + Datatype.class.getSimpleName() + " annotation: " + theClass.getCanonicalName());
CodeTableDef codeTableDefinition = theClass.getAnnotation(CodeTableDef.class);
if (codeTableDefinition != null) {
if (ICodeEnum.class.isAssignableFrom(theClass)) {
@SuppressWarnings("unchecked")
Class<? extends ICodeEnum> resClass = (Class<? extends ICodeEnum>) theClass;
return scanCodeTable(resClass, codeTableDefinition);
} else {
throw new ConfigurationException("Resource type contains a @" + CodeTableDef.class.getSimpleName() + " annotation but does not implement " + ICodeEnum.class.getCanonicalName() + ": "
+ theClass.getCanonicalName());
}
}
private String scanCompositeDatatype(Class<? extends ICompositeDatatype> theClass, Datatype theDatatypeDefinition) {
throw new ConfigurationException("Resource type does not contain a @" + ResourceDef.class.getSimpleName() + " annotation or a @" + DatatypeDef.class.getSimpleName() + " annotation: "
+ theClass.getCanonicalName());
}
private String scanCompositeDatatype(Class<? extends ICompositeDatatype> theClass, DatatypeDef theDatatypeDefinition) {
ourLog.debug("Scanning resource class: {}", theClass.getName());
String resourceName = theDatatypeDefinition.name();
if (isBlank(resourceName)) {
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
}
if (myNameToElementDefinitions.containsKey(resourceName)) {
if (!myNameToElementDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToElementDefinitions.get(resourceName).getImplementingClass() + "'");
if (myNameToResourceDefinitions.containsKey(resourceName)) {
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '"
+ myNameToResourceDefinitions.get(resourceName).getImplementingClass() + "'");
}
return resourceName;
}
RuntimeCompositeDatatypeDefinition resourceDef = new RuntimeCompositeDatatypeDefinition(resourceName, theClass);
myClassToResourceDefinitions.put(theClass, resourceDef);
myNameToElementDefinitions.put(resourceName, resourceDef);
myClassToElementDefinitions.put(theClass, resourceDef);
scanCompositeElementForChildren(theClass, resourceDef);
return resourceName;
}
private String scanPrimitiveDatatype(Class<? extends IPrimitiveDatatype> theClass, Datatype theDatatypeDefinition) {
private String scanPrimitiveDatatype(Class<? extends IPrimitiveDatatype> theClass, DatatypeDef theDatatypeDefinition) {
ourLog.debug("Scanning resource class: {}", theClass.getName());
String resourceName = theDatatypeDefinition.name();
if (isBlank(resourceName)) {
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
}
if (myNameToElementDefinitions.containsKey(resourceName)) {
if (!myNameToElementDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToElementDefinitions.get(resourceName).getImplementingClass() + "'");
if (myNameToResourceDefinitions.containsKey(resourceName)) {
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '"
+ myNameToResourceDefinitions.get(resourceName).getImplementingClass() + "'");
}
return resourceName;
}
RuntimePrimitiveDatatypeDefinition resourceDef = new RuntimePrimitiveDatatypeDefinition(resourceName, theClass);
myClassToResourceDefinitions.put(theClass, resourceDef);
myNameToElementDefinitions.put(resourceName, resourceDef);
myClassToElementDefinitions.put(theClass, resourceDef);
return resourceName;
}
private String scanResource(Class<? extends IResource> theClass, ResourceDefinition resourceDefinition) {
private String scanResource(Class<? extends IResource> theClass, ResourceDef resourceDefinition) {
ourLog.debug("Scanning resource class: {}", theClass.getName());
String resourceName = resourceDefinition.name();
if (isBlank(resourceName)) {
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
}
if (myNameToElementDefinitions.containsKey(resourceName)) {
if (!myNameToElementDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToElementDefinitions.get(resourceName).getImplementingClass() + "'");
if (myNameToResourceDefinitions.containsKey(resourceName)) {
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '"
+ myNameToResourceDefinitions.get(resourceName).getImplementingClass() + "'");
}
return resourceName;
}
RuntimeResourceDefinition resourceDef = new RuntimeResourceDefinition(theClass, resourceName);
myClassToResourceDefinitions.put(theClass, resourceDef);
myNameToElementDefinitions.put(resourceName, resourceDef);
myClassToElementDefinitions.put(theClass, resourceDef);
myNameToResourceDefinitions.put(resourceName, resourceDef);
scanCompositeElementForChildren(theClass, resourceDef);
@ -195,7 +230,8 @@ class ModelScanner {
* Child is a resource reference
*/
if (resRefAnnotation == null) {
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is a resource reference but does not have a @" + ChildResource.class.getSimpleName() + " annotation");
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is a resource reference but does not have a @"
+ ChildResource.class.getSimpleName() + " annotation");
}
Class<? extends IResource>[] refType = resRefAnnotation.types();
@ -206,39 +242,51 @@ class ModelScanner {
} else {
if (resRefAnnotation != null) {
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference but has a @" + ChildResource.class.getSimpleName() + " annotation");
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference but has a @"
+ ChildResource.class.getSimpleName() + " annotation");
}
if (!IDatatype.class.isAssignableFrom(next.getType())) {
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference and is not an instance of type " + IDatatype.class.getName());
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference and is not an instance of type "
+ IDatatype.class.getName());
}
@SuppressWarnings("unchecked")
Class<? extends IDatatype> nextDatatype = (Class<? extends IDatatype>) next.getType();
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
if (IPrimitiveDatatype.class.isAssignableFrom(next.getType())) {
myScanAlso.add(nextDatatype);
RuntimeChildPrimitiveDatatypeDefinition def = new RuntimeChildPrimitiveDatatypeDefinition(next, elementName, datatypeName, min, max);
}else {
@SuppressWarnings("unchecked")
String datatypeName = scan(nextDatatype);
RuntimeChildCompositeDatatypeDefinition def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, datatypeName, min, max, datatypeName);
orderToElementDef.put(order, def);
BaseRuntimeChildDatatypeDefinition def;
if (IPrimitiveDatatype.class.isAssignableFrom(next.getType())) {
def = new RuntimeChildPrimitiveDatatypeDefinition(next, elementName, min, max, nextDatatype);
} else {
def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, min, max, nextDatatype);
}
// TODO: handle codes
// if (concept != null) {
// Class<? extends ICodeEnum> codeType = concept.type();
// String codeTableName = scanCodeTable(codeType);
// @SuppressWarnings("unchecked")
// String datatypeName = scan((Class<? extends IDatatype>) next.getType());
// RuntimeChildCompositeDatatypeDefinition def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, datatypeName, min, max, codeTableName);
// orderToElementDef.put(order, def);
// } else {
// @SuppressWarnings("unchecked")
// orderToElementDef.put(order, def);
// }
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
if (concept != null) {
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());
} else {
Class<? extends ICodeEnum> type = concept.type();
myScanAlso.add(type);
def.setCodeType(type);
}
}
orderToElementDef.put(order, def);
// TODO: handle codes
// if (concept != null) {
// Class<? extends ICodeEnum> codeType = concept.type();
// String codeTableName = scanCodeTable(codeType);
// @SuppressWarnings("unchecked")
// String datatypeName = scan((Class<? extends IDatatype>) next.getType());
// RuntimeChildCompositeDatatypeDefinition def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, datatypeName, min, max, codeTableName);
// orderToElementDef.put(order, def);
// } else {
// @SuppressWarnings("unchecked")
// orderToElementDef.put(order, def);
// }
}
elementNames.add(elementName);
@ -246,7 +294,8 @@ class ModelScanner {
for (int i = 0; i < orderToElementDef.size(); i++) {
if (!orderToElementDef.containsKey(i)) {
throw new ConfigurationException("Type '" + theClass.getCanonicalName() + "' does not have a child with order " + i + " (in other words, there are gaps between specified child orders)");
throw new ConfigurationException("Type '" + theClass.getCanonicalName() + "' does not have a child with order " + i
+ " (in other words, there are gaps between specified child orders)");
}
BaseRuntimeChildDefinition next = orderToElementDef.get(i);
theDefinition.addChild(next);
@ -254,9 +303,8 @@ class ModelScanner {
}
private String scanCodeTable(Class<? extends ICodeEnum> theCodeType) {
// TODO Auto-generated method stub
return null;
private String scanCodeTable(Class<? extends ICodeEnum> theCodeType, CodeTableDef theCodeTableDefinition) {
return null; // TODO: implement
}
}

View File

@ -1,23 +1,50 @@
package ca.uhn.fhir.context;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import ca.uhn.fhir.model.api.IElement;
public class RuntimeChildChoiceDefinition extends BaseRuntimeChildDefinition {
private List<Class<? extends IElement>> myChoiceTypes;
private Map<String, BaseRuntimeElementDefinition<?>> myNameToChildDefinition;
public RuntimeChildChoiceDefinition(Field theField, String theElementName, int theMin, int theMax, List<Class<? extends IElement>> theChoiceTypes) {
super(theField, theMin,theMax, theElementName);
myChoiceTypes= theChoiceTypes;
myChoiceTypes= Collections.unmodifiableList(theChoiceTypes);
}
public List<Class<? extends IElement>> getChoices() {
return myChoiceTypes;
}
@Override
public Set<String> getValidChildNames() {
return myNameToChildDefinition.keySet();
}
@Override
public BaseRuntimeElementDefinition<?> getChildByName(String theName) {
assert myNameToChildDefinition.containsKey(theName);
return myNameToChildDefinition.get(theName);
}
@Override
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
myNameToChildDefinition = new HashMap<String, BaseRuntimeElementDefinition<?>>();
for (Class<? extends IElement> next : myChoiceTypes) {
BaseRuntimeElementDefinition<?> nextDef = theClassToElementDefinitions.get(next);
myNameToChildDefinition.put(getElementName() + nextDef.getName(), nextDef);
}
myNameToChildDefinition = Collections.unmodifiableMap(myNameToChildDefinition);
}
}

View File

@ -6,8 +6,10 @@ import ca.uhn.fhir.model.api.IDatatype;
public class RuntimeChildCompositeDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition {
public RuntimeChildCompositeDatatypeDefinition(Field theField, String theElementName, String theDatatypeName, int theMin, int theMax, Class<? extends IDatatype> theDatatype) {
public RuntimeChildCompositeDatatypeDefinition(Field theField, String theElementName, int theMin, int theMax, Class<? extends IDatatype> theDatatype) {
super(theField, theElementName, theMin,theMax,theDatatype);
}
}

View File

@ -3,12 +3,16 @@ package ca.uhn.fhir.context;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IResource;
public class RuntimeChildResourceDefinition extends BaseRuntimeChildDefinition {
private static final String REFERENCE = "reference";
private String myResourceName;
private Set<String> myValidChildNames;
private List<Class<? extends IResource>> myChildTypes;
@ -25,15 +29,22 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeChildDefinition {
@Override
public Set<String> getValidChildNames() {
return myValidChildNames;
return Collections.singleton(REFERENCE);
}
@Override
public BaseRuntimeElementDefinition<?> getChildByName(String theName) {
if (myElementName.equals(theName)) {
if (REFERENCE.equals(theName)) {
return null; // TODO: implement
}
return null;
}
@Override
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
// TODO Auto-generated method stub
}
}

View File

@ -8,5 +8,10 @@ public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompos
super(theName, theImplementingClass);
}
@Override
public ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum getChildType() {
return ChildTypeEnum.COMPOSITE_DATATYPE;
}
}

View File

@ -1,5 +1,8 @@
package ca.uhn.fhir.context;
import java.util.Map;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition<IPrimitiveDatatype>{
@ -8,4 +11,14 @@ public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefini
super(theName, theImplementingClass);
}
@Override
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
// nothing
}
@Override
public ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum getChildType() {
return ChildTypeEnum.PRIMITIVE_DATATYPE;
}
}

View File

@ -18,4 +18,9 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
}
}
@Override
public ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum getChildType() {
return ChildTypeEnum.RESOURCE;
}
}

View File

@ -1,4 +1,4 @@
package ca.uhn.fhir.model.api;
package ca.uhn.fhir.model.api.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@ -7,7 +7,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.TYPE})
public @interface EnumeratedValueSet {
public @interface CodeTableDef {
int tableId();

View File

@ -7,7 +7,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.TYPE})
public @interface Datatype {
public @interface DatatypeDef {
String name();

View File

@ -1,4 +1,4 @@
package ca.uhn.fhir.model.api;
package ca.uhn.fhir.model.api.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -1,4 +1,4 @@
package ca.uhn.fhir.model.api;
package ca.uhn.fhir.model.api.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -1,4 +1,4 @@
package ca.uhn.fhir.model.resource;
package ca.uhn.fhir.model.api.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@ -7,7 +7,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(value= {ElementType.TYPE})
public @interface ResourceDefinition {
public @interface ResourceDef {
int ORDER_NOT_SPECIFIED = -1;

View File

@ -1,11 +1,11 @@
package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
import ca.uhn.fhir.model.api.Description;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description;
@Datatype(name="Attachment")
@DatatypeDef(name="Attachment")
public class AttachmentDt extends BaseCompositeDatatype {
@Child(name="contentType", order=0, min=1)

View File

@ -1,9 +1,9 @@
package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="base64Binary")
@DatatypeDef(name="base64Binary")
public class Base64BinaryDt extends BasePrimitiveDatatype {
private byte[] myValue;

View File

@ -1,9 +1,9 @@
package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="boolean")
@DatatypeDef(name="boolean")
public class BooleanDt extends BasePrimitiveDatatype {
private boolean myValue;

View File

@ -2,9 +2,9 @@ package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="code")
public class CodeDt<T extends ICodeEnum> extends BasePrimitiveDatatype {
@DatatypeDef(name="code")
public class CodeDt<T extends ICodeEnum> extends BasePrimitiveDatatype implements ICodedDatatype {
}

View File

@ -5,10 +5,10 @@ import java.util.List;
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="CodeableConcept")
public class CodeableConceptDt<T extends ICodeEnum> extends BaseCompositeDatatype {
@DatatypeDef(name="CodeableConcept")
public class CodeableConceptDt<T extends ICodeEnum> extends BaseCompositeDatatype implements ICodedDatatype {
@Child(name="coding", order=0)
private List<CodingDt> myCoding;

View File

@ -4,11 +4,11 @@ import ca.uhn.fhir.model.api.BaseCompositeDatatype;
import ca.uhn.fhir.model.api.ResourceReference;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.ChildResource;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.resource.ValueSet;
@Datatype(name="Coding")
@DatatypeDef(name="Coding")
public class CodingDt extends BaseCompositeDatatype {
@Child(name="system", order=0)

View File

@ -4,9 +4,9 @@ import java.util.GregorianCalendar;
import ca.uhn.fhir.model.api.BaseDatatype;
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="date")
@DatatypeDef(name="date")
public class DateDt extends BaseDatatype implements IPrimitiveDatatype {
private GregorianCalendar myValue;

View File

@ -3,9 +3,9 @@ package ca.uhn.fhir.model.datatype;
import java.util.GregorianCalendar;
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="dateTime")
@DatatypeDef(name="dateTime")
public class DateTimeDt extends BasePrimitiveDatatype {
private GregorianCalendar myValue;

View File

@ -3,9 +3,9 @@ package ca.uhn.fhir.model.datatype;
import java.math.BigDecimal;
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="decimal")
@DatatypeDef(name="decimal")
public class DecimalDt extends BasePrimitiveDatatype {
private BigDecimal myValue;

View File

@ -0,0 +1,7 @@
package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.IDatatype;
public interface ICodedDatatype extends IDatatype {
}

View File

@ -5,11 +5,11 @@ import ca.uhn.fhir.model.api.CodeableConceptElement;
import ca.uhn.fhir.model.api.ResourceReference;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.ChildResource;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.enm.IdentifierUseEnum;
import ca.uhn.fhir.model.resource.Organization;
@Datatype(name="identifier")
@DatatypeDef(name="identifier")
public class IdentifierDt extends BaseCompositeDatatype {
@Child(name="use", order=0)

View File

@ -3,9 +3,9 @@ package ca.uhn.fhir.model.datatype;
import java.util.Date;
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="instant")
@DatatypeDef(name="instant")
public class InstantDt extends BasePrimitiveDatatype {
private Date myValue;

View File

@ -1,9 +1,9 @@
package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="integer")
@DatatypeDef(name="integer")
public class IntegerDt extends BasePrimitiveDatatype {
private int myValue;

View File

@ -3,9 +3,9 @@ package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
import ca.uhn.fhir.model.api.annotation.Constraint;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="Period")
@DatatypeDef(name="Period")
public class PeriodDt extends BaseCompositeDatatype {
@Child(name="start", order=0)

View File

@ -3,10 +3,10 @@ package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
import ca.uhn.fhir.model.api.annotation.Constraint;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.enm.QuantityComparator;
@Datatype(name="Quantity")
@DatatypeDef(name="Quantity")
public class QuantityDt extends BaseCompositeDatatype {
@Child(name="value",order=0, min=0, max=1)

View File

@ -3,9 +3,9 @@ package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
import ca.uhn.fhir.model.api.annotation.Constraint;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="Ratio")
@DatatypeDef(name="Ratio")
public class RatioDt extends BaseCompositeDatatype {
@Child(name="numerator", order=0)

View File

@ -1,11 +1,11 @@
package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
import ca.uhn.fhir.model.api.Description;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description;
@Datatype(name="SampledData")
@DatatypeDef(name="SampledData")
public class SampledDataDt extends BaseCompositeDatatype {
@Child(name="origin", order=0, min=1)

View File

@ -1,9 +1,9 @@
package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="string")
@DatatypeDef(name="string")
public class StringDt extends BasePrimitiveDatatype {
private String myValue;

View File

@ -2,9 +2,9 @@ package ca.uhn.fhir.model.datatype;
import ca.uhn.fhir.model.api.BaseDatatype;
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.model.api.annotation.Datatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
@Datatype(name="uri")
@DatatypeDef(name="uri")
public class UriDt extends BaseDatatype implements IPrimitiveDatatype {
private String myValue;

View File

@ -1,9 +1,9 @@
package ca.uhn.fhir.model.enm;
import ca.uhn.fhir.model.api.EnumeratedValueSet;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@EnumeratedValueSet(name="body-site", tableId=62, restrictedToSnomedIsA= {91723000})
@CodeTableDef(name="body-site", tableId=62, restrictedToSnomedIsA= {91723000})
public enum BodySiteEnum implements ICodeEnum {
}

View File

@ -1,11 +1,11 @@
package ca.uhn.fhir.model.enm;
import ca.uhn.fhir.model.api.Description;
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.EnumeratedValueSet;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@EnumeratedValueSet(name="identifier-use", tableId=13)
@CodeTableDef(name="identifier-use", tableId=13)
public enum IdentifierUseEnum implements ICodeEnum {
@EnumeratedCodeValue("usual")
@Description("the identifier recommended for display and use in real-world interactions.")

View File

@ -1,9 +1,9 @@
package ca.uhn.fhir.model.enm;
import ca.uhn.fhir.model.api.EnumeratedValueSet;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@EnumeratedValueSet(name="observation-codes", tableId=115)
@CodeTableDef(name="observation-codes", tableId=115)
public enum ObservationCodesEnum implements ICodeEnum {
}

View File

@ -1,11 +1,11 @@
package ca.uhn.fhir.model.enm;
import ca.uhn.fhir.model.api.Description;
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.EnumeratedValueSet;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@EnumeratedValueSet(tableId = 117, name = "observation-interpretation")
@CodeTableDef(tableId = 117, name = "observation-interpretation")
public enum ObservationInterpretationEnum implements ICodeEnum {
@EnumeratedCodeValue(value = "<", system = "http://hl7.org/fhir/v2/0078")

View File

@ -1,9 +1,9 @@
package ca.uhn.fhir.model.enm;
import ca.uhn.fhir.model.api.EnumeratedValueSet;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@EnumeratedValueSet(tableId=114, name="observation-method")
@CodeTableDef(tableId=114, name="observation-method")
public enum ObservationMethodEnum implements ICodeEnum {

View File

@ -1,11 +1,11 @@
package ca.uhn.fhir.model.enm;
import ca.uhn.fhir.model.api.Description;
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.EnumeratedValueSet;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@EnumeratedValueSet(tableId=118, name="observation-reliability")
@CodeTableDef(tableId=118, name="observation-reliability")
public enum ObservationReliabilityEnum implements ICodeEnum {
@Description("The result has no reliability concerns.")

View File

@ -1,11 +1,11 @@
package ca.uhn.fhir.model.enm;
import ca.uhn.fhir.model.api.Description;
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.EnumeratedValueSet;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@EnumeratedValueSet(tableId=7, name="observation-status")
@CodeTableDef(tableId=7, name="observation-status")
public enum ObservationStatusEnum implements ICodeEnum {
@Description("The existence of the observation is registered, but there is no result yet available")

View File

@ -1,11 +1,11 @@
package ca.uhn.fhir.model.enm;
import ca.uhn.fhir.model.api.Description;
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.EnumeratedValueSet;
import ca.uhn.fhir.model.api.ICodeEnum;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.EnumeratedCodeValue;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@EnumeratedValueSet(tableId=14, name="quantity-comparator")
@CodeTableDef(tableId=14, name="quantity-comparator")
public enum QuantityComparator implements ICodeEnum {
@EnumeratedCodeValue("<")

View File

@ -6,6 +6,7 @@ import ca.uhn.fhir.model.api.ResourceReference;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.ChildResource;
import ca.uhn.fhir.model.api.annotation.Choice;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.datatype.AttachmentDt;
import ca.uhn.fhir.model.datatype.CodeableConceptDt;
import ca.uhn.fhir.model.datatype.DateTimeDt;
@ -21,7 +22,7 @@ import ca.uhn.fhir.model.enm.ObservationInterpretationEnum;
import ca.uhn.fhir.model.enm.ObservationMethodEnum;
import ca.uhn.fhir.model.enm.ObservationStatusEnum;
@ResourceDefinition(name="Observation", identifierOrder=10)
@ResourceDef(name="Observation", identifierOrder=10)
public class Observation extends BaseResourceWithIdentifier {
@Child(name="name", order=0, min=1, max=1)

View File

@ -16,7 +16,7 @@ class ParserState {
}
public static ParserState getResourceInstance(FhirContext theContext, String theLocalPart) throws DataFormatException {
BaseRuntimeElementDefinition<?> definition = theContext.getNameToElementDefinition().get(theLocalPart);
BaseRuntimeElementDefinition<?> definition = theContext.getNameToResourceDefinition().get(theLocalPart);
if (!(definition instanceof RuntimeResourceDefinition)) {
throw new DataFormatException("Element '" + theLocalPart + "' is not a resource, expected a resource at this position");
}
@ -55,20 +55,17 @@ class ParserState {
@Override
public void enteringNewElement(String theChildName) throws DataFormatException {
// BaseRuntimeChildDefinition child = myResourceDefinition.getChildByNameOrThrowDataFormatException(theChildName);
// switch (child.getChildType()) {
// case CHOICE:
// break;
// case COMPOSITE:
// break;
// case PRIMITIVE:
// break;
// case RESOURCE:
// break;
// default:
// break;
//
// }
BaseRuntimeElementDefinition<?> child = myResourceDefinition.getChildByNameOrThrowDataFormatException(theChildName);
switch (child.getChildType()) {
case COMPOSITE_DATATYPE:
break;
case PRIMITIVE_DATATYPE:
break;
case RESOURCE:
default:
throw new DataFormatException("Illegal resource position");
}
}
}