@Override public String toString() { return getClass().getSimpleName()+"[" + getName() + ", " + getImplementingClass().getSimpleName() + "]"; }
public static String createExtensionChildName(BaseRuntimeElementDefinition<?> next) { String attrName = "value" + WordUtils.capitalize(next.getName()); return attrName; }
/** * Invoked prior to use to perform any initialization and make object * mutable. * @param theContext TODO */ void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { for (BaseRuntimeChildDefinition next : myExtensions) { next.sealAndInitialize(theContext, theClassToElementDefinitions); } for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) { String extUrl = next.getExtensionUrl(); if (myUrlToExtension.containsKey(extUrl)) { throw new ConfigurationException("Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]"); } myUrlToExtension.put(extUrl, next); if (next.isModifier()) { myExtensionsModifier.add(next); } else { myExtensionsNonModifier.add(next); } } myExtensions = Collections.unmodifiableList(myExtensions); }
for (BaseRuntimeElementDefinition<?> next : classToElementDefinition.values()) { if (next instanceof RuntimeResourceDefinition) { if ("Bundle".equals(next.getName())) { if (!IBaseBundle.class.isAssignableFrom(next.getImplementingClass())) { throw new ConfigurationException("Resource type declares resource name Bundle but does not implement IBaseBundle");
Class<? extends IBaseDatatype> profileType = nextDefDatatype.getProfileOf(); BaseRuntimeElementDefinition<?> elementDef = theClassToElementDefinitions.get(profileType); elementName = getElementName() + StringUtils.capitalize(elementDef.getName()); elementName = getElementName() + StringUtils.capitalize(nextDefForChoice.getName());
myParamType = "code"; } else if (IBase.class.isAssignableFrom(myParameterType) && typeIsConcrete) { myParamType = myContext.getElementDefinition((Class<? extends IBase>) myParameterType).getName(); } else if (isSearchParam) { myParamType = "string";
myParamType = "code"; } else if (IBase.class.isAssignableFrom(myParameterType) && typeIsConcrete) { myParamType = myContext.getElementDefinition((Class<? extends IBase>) myParameterType).getName(); } else if (isSearchParam) { myParamType = "string";
if (elementDef.getName().equals("code")) { Class<? extends IBase> type2 = myContext.getElementDefinition("code").getImplementingClass(); childDef = theChild.getChildElementDefinitionByDatatype(type2);
throw new IllegalStateException("state should not happen: " + childDef.getName());
String childName = extDef.getChildNameByDatatype(value.getClass()); if (childName == null) { childName = "value" + WordUtils.capitalize(myContext.getElementDefinition(value.getClass()).getName());
throw new ConfigurationException("Invalid value for @OperationParam.type(): " + next.type().getName()); type.setType(theContext.getElementDefinition(next.type()).getName());
throw new ConfigurationException("Invalid value for @OperationParam.type(): " + next.type().getName()); type.setType(theContext.getElementDefinition(next.type()).getName());
@SuppressWarnings("unchecked") private void addParam(String theName, IBase theValue) { BaseRuntimeChildDefinition parameterChild = myParametersDef.getChildByName("parameter"); BaseRuntimeElementCompositeDefinition<?> parameterElem = (BaseRuntimeElementCompositeDefinition<?>) parameterChild.getChildByName("parameter"); IBase parameter = parameterElem.newInstance(); parameterChild.getMutator().addValue(myParameters, parameter); IPrimitiveType<String> name = (IPrimitiveType<String>) myContext.getElementDefinition("string").newInstance(); name.setValue(theName); parameterElem.getChildByName("name").getMutator().setValue(parameter, name); if (theValue instanceof IBaseDatatype) { BaseRuntimeElementDefinition<?> datatypeDef = myContext.getElementDefinition(theValue.getClass()); if (datatypeDef instanceof IRuntimeDatatypeDefinition) { Class<? extends IBaseDatatype> profileOf = ((IRuntimeDatatypeDefinition) datatypeDef).getProfileOf(); if (profileOf != null) { datatypeDef = myContext.getElementDefinition(profileOf); } } String childElementName = "value" + StringUtils.capitalize(datatypeDef.getName()); BaseRuntimeChildDefinition childByName = parameterElem.getChildByName(childElementName); childByName.getMutator().setValue(parameter, theValue); } else if (theValue instanceof IBaseResource) { parameterElem.getChildByName("resource").getMutator().setValue(parameter, theValue); } else { throw new IllegalArgumentException("Don't know how to handle parameter of type " + theValue.getClass()); } }
return; } else if (myContext.getElementDefinition((Class<? extends IBase>) nextObject.getClass()).getName().equals("uri")) { return; } else if (theResourceType.equals("Consent") && nextPathAndRef.getPath().equals("Consent.source")) {
@Override public String toString() { return getClass().getSimpleName()+"[" + getName() + ", " + getImplementingClass().getSimpleName() + "]"; }
public static String createExtensionChildName(BaseRuntimeElementDefinition<?> next) { String attrName = "value" + WordUtils.capitalize(next.getName()); return attrName; }
private void fillBasics(StructureElement theElement, BaseRuntimeElementDefinition<?> def, LinkedList<String> path, BaseRuntimeDeclaredChildDefinition theChild) { if (path.isEmpty()) { path.add(def.getName()); theElement.setName(def.getName()); } else { path.add(WordUtils.uncapitalize(theChild.getElementName())); theElement.setName(theChild.getElementName()); } theElement.setPath(StringUtils.join(path, '.')); }
/** * Invoked prior to use to perform any initialization and make object * mutable. * @param theContext TODO */ void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { for (BaseRuntimeChildDefinition next : myExtensions) { next.sealAndInitialize(theContext, theClassToElementDefinitions); } for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) { String extUrl = next.getExtensionUrl(); if (myUrlToExtension.containsKey(extUrl)) { throw new ConfigurationException("Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]"); } myUrlToExtension.put(extUrl, next); if (next.isModifier()) { myExtensionsModifier.add(next); } else { myExtensionsNonModifier.add(next); } } myExtensions = Collections.unmodifiableList(myExtensions); }
private void fillName(StructureElement elem, BaseRuntimeElementDefinition<?> nextDef, String theServerBase) { assert nextDef != null; StructureElementDefinitionType type = elem.getDefinition().addType(); String name = nextDef.getName(); DataTypeEnum fromCodeString = DataTypeEnum.VALUESET_BINDER.fromCodeString(name); if (fromCodeString == null) { throw new ConfigurationException("Unknown type: " + name); } type.setCode(fromCodeString); }
@SuppressWarnings("unchecked") private void addParam(String theName, IBase theValue) { BaseRuntimeChildDefinition parameterChild = myParametersDef.getChildByName("parameter"); BaseRuntimeElementCompositeDefinition<?> parameterElem = (BaseRuntimeElementCompositeDefinition<?>) parameterChild.getChildByName("parameter"); IBase parameter = parameterElem.newInstance(); parameterChild.getMutator().addValue(myParameters, parameter); IPrimitiveType<String> name = (IPrimitiveType<String>) myContext.getElementDefinition("string").newInstance(); name.setValue(theName); parameterElem.getChildByName("name").getMutator().setValue(parameter, name); if (theValue instanceof IBaseDatatype) { BaseRuntimeElementDefinition<?> datatypeDef = myContext.getElementDefinition(theValue.getClass()); if (datatypeDef instanceof IRuntimeDatatypeDefinition) { Class<? extends IBaseDatatype> profileOf = ((IRuntimeDatatypeDefinition) datatypeDef).getProfileOf(); if (profileOf != null) { datatypeDef = myContext.getElementDefinition(profileOf); } } String childElementName = "value" + StringUtils.capitalize(datatypeDef.getName()); BaseRuntimeChildDefinition childByName = parameterElem.getChildByName(childElementName); childByName.getMutator().setValue(parameter, theValue); } else if (theValue instanceof IBaseResource) { parameterElem.getChildByName("resource").getMutator().setValue(parameter, theValue); } else { throw new IllegalArgumentException("Don't know how to handle parameter of type " + theValue.getClass()); } }