..and still...
This commit is contained in:
parent
9aa5e52911
commit
5296e8121c
|
@ -3,8 +3,10 @@ package ca.uhn.fhir.context;
|
|||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -67,7 +69,7 @@ class ModelScanner {
|
|||
toScan.clear();
|
||||
toScan.addAll(myScanAlso);
|
||||
myScanAlso.clear();
|
||||
} while (!myScanAlso.isEmpty());
|
||||
} while (!toScan.isEmpty());
|
||||
|
||||
for (BaseRuntimeElementDefinition<?> next : myClassToElementDefinitions.values()) {
|
||||
next.sealAndInitialize(myClassToElementDefinitions);
|
||||
|
@ -130,17 +132,10 @@ class ModelScanner {
|
|||
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
||||
}
|
||||
|
||||
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);
|
||||
myClassToElementDefinitions.put(theClass, resourceDef);
|
||||
|
||||
scanCompositeElementForChildren(theClass, resourceDef);
|
||||
scanCompositeElementForChildren(theClass, resourceDef, null);
|
||||
|
||||
return resourceName;
|
||||
}
|
||||
|
@ -153,13 +148,6 @@ class ModelScanner {
|
|||
throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
||||
}
|
||||
|
||||
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);
|
||||
myClassToElementDefinitions.put(theClass, resourceDef);
|
||||
|
||||
|
@ -185,13 +173,13 @@ class ModelScanner {
|
|||
myClassToElementDefinitions.put(theClass, resourceDef);
|
||||
myNameToResourceDefinitions.put(resourceName, resourceDef);
|
||||
|
||||
scanCompositeElementForChildren(theClass, resourceDef);
|
||||
scanCompositeElementForChildren(theClass, resourceDef, resourceDefinition.identifierOrder());
|
||||
|
||||
return resourceName;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, BaseRuntimeElementCompositeDefinition<?> theDefinition) {
|
||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, BaseRuntimeElementCompositeDefinition<?> theDefinition, Integer theIdentifierOrder) {
|
||||
Set<String> elementNames = new HashSet<String>();
|
||||
TreeMap<Integer, BaseRuntimeChildDefinition> orderToElementDef = new TreeMap<Integer, BaseRuntimeChildDefinition>();
|
||||
|
||||
|
@ -210,7 +198,14 @@ class ModelScanner {
|
|||
scanCompositeElementForChildren(next, theDefinition, elementNames, orderToElementDef);
|
||||
}
|
||||
|
||||
dealwithnegative
|
||||
while (orderToElementDef.firstKey() < 0) {
|
||||
BaseRuntimeChildDefinition elementDef = orderToElementDef.remove(orderToElementDef.firstKey());
|
||||
if (elementDef.getElementName().equals("identifier")) {
|
||||
orderToElementDef.put(theIdentifierOrder, elementDef);
|
||||
}else {
|
||||
throw new ConfigurationException("Don't know how to handle element: " + elementDef.getElementName());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < orderToElementDef.size(); i++) {
|
||||
if (!orderToElementDef.containsKey(i)) {
|
||||
|
@ -222,6 +217,7 @@ class ModelScanner {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, BaseRuntimeElementCompositeDefinition<?> theDefinition, Set<String> elementNames, TreeMap<Integer, BaseRuntimeChildDefinition> orderToElementDef) {
|
||||
for (Field next : theClass.getDeclaredFields()) {
|
||||
|
||||
|
@ -292,12 +288,25 @@ class ModelScanner {
|
|||
if (resRefAnnotation != null) {
|
||||
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());
|
||||
|
||||
Class<? extends IDatatype> nextDatatype;
|
||||
|
||||
if (IDatatype.class.isAssignableFrom(next.getType())) {
|
||||
nextDatatype = (Class<? extends IDatatype>) next.getType();
|
||||
} else {
|
||||
if (Collection.class.isAssignableFrom(next.getType())) {
|
||||
Class<?> type = (Class<?>) ((ParameterizedType) next.getType().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
if (IDatatype.class.isAssignableFrom(type)) {
|
||||
nextDatatype=(Class<? extends IDatatype>) type;
|
||||
}else {
|
||||
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference and is not an instance of type " + IDatatype.class.getName());
|
||||
}
|
||||
}else {
|
||||
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();
|
||||
|
||||
myScanAlso.add(nextDatatype);
|
||||
|
||||
BaseRuntimeChildDatatypeDefinition def;
|
||||
|
|
|
@ -32,4 +32,53 @@ public class IdentifierDt extends BaseCompositeDatatype {
|
|||
@ChildResource(types= {Organization.class})
|
||||
private ResourceReference myAssigner;
|
||||
|
||||
public CodeDt<IdentifierUseEnum> getUse() {
|
||||
return myUse;
|
||||
}
|
||||
|
||||
public void setUse(CodeDt<IdentifierUseEnum> theUse) {
|
||||
myUse = theUse;
|
||||
}
|
||||
|
||||
public StringDt getLabel() {
|
||||
return myLabel;
|
||||
}
|
||||
|
||||
public void setLabel(StringDt theLabel) {
|
||||
myLabel = theLabel;
|
||||
}
|
||||
|
||||
public UriDt getSystem() {
|
||||
return mySystem;
|
||||
}
|
||||
|
||||
public void setSystem(UriDt theSystem) {
|
||||
mySystem = theSystem;
|
||||
}
|
||||
|
||||
public StringDt getValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
public void setValue(StringDt theValue) {
|
||||
myValue = theValue;
|
||||
}
|
||||
|
||||
public PeriodDt getPeriod() {
|
||||
return myPeriod;
|
||||
}
|
||||
|
||||
public void setPeriod(PeriodDt thePeriod) {
|
||||
myPeriod = thePeriod;
|
||||
}
|
||||
|
||||
public ResourceReference getAssigner() {
|
||||
return myAssigner;
|
||||
}
|
||||
|
||||
public void setAssigner(ResourceReference theAssigner) {
|
||||
myAssigner = theAssigner;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,4 +16,21 @@ public class PeriodDt extends BaseCompositeDatatype {
|
|||
@Constraint(greaterThan= {"start"})
|
||||
private DateTimeDt myEnd;
|
||||
|
||||
public DateTimeDt getStart() {
|
||||
return myStart;
|
||||
}
|
||||
|
||||
public void setStart(DateTimeDt theStart) {
|
||||
myStart = theStart;
|
||||
}
|
||||
|
||||
public DateTimeDt getEnd() {
|
||||
return myEnd;
|
||||
}
|
||||
|
||||
public void setEnd(DateTimeDt theEnd) {
|
||||
myEnd = theEnd;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ 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.DatatypeDef;
|
||||
import ca.uhn.fhir.model.enm.QuantityComparator;
|
||||
import ca.uhn.fhir.model.enm.QuantityComparatorEnum;
|
||||
|
||||
@DatatypeDef(name="Quantity")
|
||||
public class QuantityDt extends BaseCompositeDatatype {
|
||||
|
@ -13,7 +13,7 @@ public class QuantityDt extends BaseCompositeDatatype {
|
|||
private DecimalDt myValue;
|
||||
|
||||
@Child(name="comparator",order=1, min=0, max=1)
|
||||
private QuantityComparator myComparator;
|
||||
private CodeDt<QuantityComparatorEnum> myComparator;
|
||||
|
||||
@Child(name="units",order=2, min=0, max=1)
|
||||
private StringDt myUnits;
|
||||
|
@ -24,6 +24,46 @@ public class QuantityDt extends BaseCompositeDatatype {
|
|||
|
||||
@Child(name="code",order=4, min=0, max=1)
|
||||
@Constraint(coRequirements= {"system"})
|
||||
private CodeDt myCode;
|
||||
private CodeDt<?> myCode;
|
||||
|
||||
public DecimalDt getValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
public void setValue(DecimalDt theValue) {
|
||||
myValue = theValue;
|
||||
}
|
||||
|
||||
public CodeDt<QuantityComparatorEnum> getComparator() {
|
||||
return myComparator;
|
||||
}
|
||||
|
||||
public void setComparator(CodeDt<QuantityComparatorEnum> theComparator) {
|
||||
myComparator = theComparator;
|
||||
}
|
||||
|
||||
public StringDt getUnits() {
|
||||
return myUnits;
|
||||
}
|
||||
|
||||
public void setUnits(StringDt theUnits) {
|
||||
myUnits = theUnits;
|
||||
}
|
||||
|
||||
public UriDt getSystem() {
|
||||
return mySystem;
|
||||
}
|
||||
|
||||
public void setSystem(UriDt theSystem) {
|
||||
mySystem = theSystem;
|
||||
}
|
||||
|
||||
public CodeDt<?> getCode() {
|
||||
return myCode;
|
||||
}
|
||||
|
||||
public void setCode(CodeDt<?> theCode) {
|
||||
myCode = theCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import ca.uhn.fhir.model.api.annotation.EnumeratedCodeValue;
|
|||
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
|
||||
|
||||
@CodeTableDef(tableId=14, name="quantity-comparator")
|
||||
public enum QuantityComparator implements ICodeEnum {
|
||||
public enum QuantityComparatorEnum implements ICodeEnum {
|
||||
|
||||
@EnumeratedCodeValue("<")
|
||||
@Description("The actual value is less than the given value.")
|
|
@ -1,5 +1,8 @@
|
|||
package ca.uhn.fhir.model.resource;
|
||||
|
||||
public class Group extends BaseResource {
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
||||
@ResourceDef(name="Group", identifierOrder=0)
|
||||
public class Group extends BaseResourceWithIdentifier {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ca.uhn.fhir.model.resource;
|
||||
|
||||
public class Organization extends BaseResource {
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
||||
@ResourceDef(name="Organization", identifierOrder=0)
|
||||
public class Organization extends BaseResourceWithIdentifier {
|
||||
//TODO: fill in
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ca.uhn.fhir.model.resource;
|
||||
|
||||
public class Patient extends BaseResource {
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
||||
@ResourceDef(name="Patient", identifierOrder=0)
|
||||
public class Patient extends BaseResourceWithIdentifier {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ca.uhn.fhir.model.resource;
|
||||
|
||||
public class ValueSet extends BaseResource {
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
||||
@ResourceDef(name="ValueSet", identifierOrder=0)
|
||||
public class ValueSet extends BaseResourceWithIdentifier {
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue