JsonParser.write(theEventWriter, "url", getExtensionUrl(myDef.getExtensionUrl())); BaseRuntimeElementDefinition<?> def = myDef.getChildElementDefinitionByDatatype(myValue.getClass()); if (def.getChildType() == ChildTypeEnum.RESOURCE_BLOCK) { extractAndWriteExtensionsAsDirectChild(myValue, theEventWriter, def, theResDef, theResource, myChildElem, null); } else { String childName = myDef.getChildNameByDatatype(myValue.getClass()); encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, myValue, def, childName, false, false, myParent, false); managePrimitiveExtension(myValue, theResDef, theResource, theEventWriter, def, childName);
def = new RuntimeChildDeclaredExtensionDefinition(nextField, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et, binder); ((RuntimeChildDeclaredExtensionDefinition)def).setEnumerationType(ReflectionUtil.getGenericCollectionTypeOfFieldWithSecondOrderForList(nextField));
private void addExtension(BaseRuntimeElementCompositeDefinition<?> theSourceDef, IBase theSource, IBase theTarget, RuntimeChildDeclaredExtensionDefinition nextExt, String url) { RuntimeChildDeclaredExtensionDefinition sourceDeclaredExt = theSourceDef.getDeclaredExtension(url, ""); if (sourceDeclaredExt == null) { if (theSource instanceof IBaseHasExtensions) { for (IBaseExtension<?, ?> next : ((IBaseHasExtensions) theSource).getExtension()) { if (next.getUrl().equals(url)) { nextExt.getMutator().addValue(theTarget, next.getValue()); } } } if (theSource instanceof IBaseHasModifierExtensions) { for (IBaseExtension<?, ?> next : ((IBaseHasModifierExtensions) theSource).getModifierExtension()) { if (next.getUrl().equals(url)) { nextExt.getMutator().addValue(theTarget, next.getValue()); } } } } else { List<? extends IBase> values = sourceDeclaredExt.getAccessor().getValues(theSource); for (IBase nextElement : values) { nextExt.getMutator().addValue(theTarget, nextElement); } } } }
/** * 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); }
if (nextChild.isDefinedLocally() == false) { continue; if (nextChild.getExtensionUrl().contains("#") && !nextChild.getExtensionUrl().endsWith("#")) { code = nextChild.getExtensionUrl().substring(nextChild.getExtensionUrl().indexOf('#') + 1); } else { throw new ConfigurationException("Locally defined extension has no '#[code]' part in extension URL: " + nextChild.getExtensionUrl()); if (nextChild.getChildType() != null && IPrimitiveDatatype.class.isAssignableFrom(nextChild.getChildType())) { RuntimePrimitiveDatatypeDefinition pdef = (RuntimePrimitiveDatatypeDefinition) nextChild.getSingleChildOrThrow(); defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName())); } else if (nextChild.getChildType() != null && ICompositeDatatype.class.isAssignableFrom(nextChild.getChildType())) { RuntimeCompositeDatatypeDefinition pdef = (RuntimeCompositeDatatypeDefinition) nextChild.getSingleChildOrThrow(); defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName())); } else { BaseRuntimeElementDefinition<?> singleChildOrThrow = nextChild.getSingleChildOrThrow(); if (singleChildOrThrow instanceof RuntimeResourceBlockDefinition) { RuntimeResourceBlockDefinition pdef = (RuntimeResourceBlockDefinition) singleChildOrThrow;
@Override public int compareTo(HeldExtension theArg0) { String url1 = myDef != null ? myDef.getExtensionUrl() : myUndeclaredExtension.getUrl(); String url2 = theArg0.myDef != null ? theArg0.myDef.getExtensionUrl() : theArg0.myUndeclaredExtension.getUrl(); url1 = defaultString(getExtensionUrl(url1)); url2 = defaultString(getExtensionUrl(url2)); return url1.compareTo(url2); }
StructureElementDefinitionType type = nextProfileExt.getDefinition().addType(); type.setCode(DataTypeEnum.EXTENSION); if (nextExt.isDefinedLocally()) { type.setProfile(nextExt.getExtensionUrl().substring(nextExt.getExtensionUrl().indexOf('#'))); } else { type.setProfile(nextExt.getExtensionUrl());
@Override public BaseRuntimeElementDefinition<?> getChildByName(String theName) { String name = theName; if ("extension".equals(name)||"modifierExtension".equals(name)) { if (myChildResourceBlock != null) { return myChildResourceBlock; } if (myChildDef != null) { return myChildDef; } } if (getValidChildNames().contains(name) == false) { return null; } return super.getChildByName(name); }
private void extractDeclaredExtensions(IBase theResource, BaseRuntimeElementDefinition<?> resDef, List<HeldExtension> extensions, List<HeldExtension> modifierExtensions, CompositeChildElement theChildElem) { for (RuntimeChildDeclaredExtensionDefinition nextDef : resDef.getExtensionsNonModifier()) { for (IBase nextValue : nextDef.getAccessor().getValues(theResource)) { if (nextValue != null) { if (nextValue.isEmpty()) { continue; } extensions.add(new HeldExtension(nextDef, nextValue, theChildElem)); } } } for (RuntimeChildDeclaredExtensionDefinition nextDef : resDef.getExtensionsModifier()) { for (IBase nextValue : nextDef.getAccessor().getValues(theResource)) { if (nextValue != null) { if (nextValue.isEmpty()) { continue; } modifierExtensions.add(new HeldExtension(nextDef, nextValue, theChildElem)); } } } }
RuntimeResourceBlockDefinition extDef = ((RuntimeResourceBlockDefinition) elementDef); for (RuntimeChildDeclaredExtensionDefinition next : extDef.getExtensions()) { myUrlToChildExtension.put(next.getExtensionUrl(), next);
/** * 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); }
@Override public BaseRuntimeElementDefinition<?> getChildByName(String theName) { String name = theName; if ("extension".equals(name)||"modifierExtension".equals(name)) { if (myChildResourceBlock != null) { return myChildResourceBlock; } if (myChildDef != null) { return myChildDef; } } if (getValidChildNames().contains(name) == false) { return null; } return super.getChildByName(name); }
private void extractDeclaredExtensions(IBase theResource, BaseRuntimeElementDefinition<?> resDef, List<HeldExtension> extensions, List<HeldExtension> modifierExtensions, CompositeChildElement theChildElem) { for (RuntimeChildDeclaredExtensionDefinition nextDef : resDef.getExtensionsNonModifier()) { for (IBase nextValue : nextDef.getAccessor().getValues(theResource)) { if (nextValue != null) { if (nextValue.isEmpty()) { continue; } extensions.add(new HeldExtension(nextDef, nextValue, theChildElem)); } } } for (RuntimeChildDeclaredExtensionDefinition nextDef : resDef.getExtensionsModifier()) { for (IBase nextValue : nextDef.getAccessor().getValues(theResource)) { if (nextValue != null) { if (nextValue.isEmpty()) { continue; } modifierExtensions.add(new HeldExtension(nextDef, nextValue, theChildElem)); } } } }
JsonParser.write(theEventWriter, "url", getExtensionUrl(myDef.getExtensionUrl())); BaseRuntimeElementDefinition<?> def = myDef.getChildElementDefinitionByDatatype(myValue.getClass()); if (def.getChildType() == ChildTypeEnum.RESOURCE_BLOCK) { extractAndWriteExtensionsAsDirectChild(myValue, theEventWriter, def, theResDef, theResource, myChildElem, null, theEncodeContext); } else { String childName = myDef.getChildNameByDatatype(myValue.getClass()); encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, myValue, def, childName, false, myParent, false, theEncodeContext); managePrimitiveExtension(myValue, theResDef, theResource, theEventWriter, def, childName, theEncodeContext);
String url = ((IBaseExtension<?, ?>) nextElement).getUrl(); for (RuntimeChildDeclaredExtensionDefinition nextExt : targetExts) { String nextTargetUrl = nextExt.getExtensionUrl(); if (!nextTargetUrl.equals(url)) { continue; String url = nextExt.getExtensionUrl(); addExtension(theSourceDef, theSource, theTarget, nextExt, url);
private void addExtension(BaseRuntimeElementCompositeDefinition<?> theSourceDef, IBase theSource, IBase theTarget, RuntimeChildDeclaredExtensionDefinition nextExt, String url) { RuntimeChildDeclaredExtensionDefinition sourceDeclaredExt = theSourceDef.getDeclaredExtension(url, ""); if (sourceDeclaredExt == null) { if (theSource instanceof IBaseHasExtensions) { for (IBaseExtension<?, ?> next : ((IBaseHasExtensions) theSource).getExtension()) { if (next.getUrl().equals(url)) { nextExt.getMutator().addValue(theTarget, next.getValue()); } } } if (theSource instanceof IBaseHasModifierExtensions) { for (IBaseExtension<?, ?> next : ((IBaseHasModifierExtensions) theSource).getModifierExtension()) { if (next.getUrl().equals(url)) { nextExt.getMutator().addValue(theTarget, next.getValue()); } } } } else { List<? extends IBase> values = sourceDeclaredExt.getAccessor().getValues(theSource); for (IBase nextElement : values) { nextExt.getMutator().addValue(theTarget, nextElement); } } } }
def = new RuntimeChildDeclaredExtensionDefinition(nextField, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et, binder); ((RuntimeChildDeclaredExtensionDefinition)def).setEnumerationType(ReflectionUtil.getGenericCollectionTypeOfFieldWithSecondOrderForList(nextField));
@Override public int compareTo(HeldExtension theArg0) { String url1 = myDef != null ? myDef.getExtensionUrl() : myUndeclaredExtension.getUrl(); String url2 = theArg0.myDef != null ? theArg0.myDef.getExtensionUrl() : theArg0.myUndeclaredExtension.getUrl(); url1 = defaultString(getExtensionUrl(url1)); url2 = defaultString(getExtensionUrl(url2)); return url1.compareTo(url2); }
RuntimeResourceBlockDefinition extDef = ((RuntimeResourceBlockDefinition) elementDef); for (RuntimeChildDeclaredExtensionDefinition next : extDef.getExtensions()) { myUrlToChildExtension.put(next.getExtensionUrl(), next);
String url = ((IBaseExtension<?, ?>) nextElement).getUrl(); for (RuntimeChildDeclaredExtensionDefinition nextExt : targetExts) { String nextTargetUrl = nextExt.getExtensionUrl(); if (!nextTargetUrl.equals(url)) { continue; String url = nextExt.getExtensionUrl(); addExtension(theSourceDef, theSource, theTarget, nextExt, url);