本文整理汇总了Java中ca.uhn.fhir.context.BaseRuntimeChildDefinition类的典型用法代码示例。如果您正苦于以下问题:Java BaseRuntimeChildDefinition类的具体用法?Java BaseRuntimeChildDefinition怎么用?Java BaseRuntimeChildDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseRuntimeChildDefinition类属于ca.uhn.fhir.context包,在下文中一共展示了BaseRuntimeChildDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testVisitWithModelVisitor2
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
@Test
public void testVisitWithModelVisitor2() {
IModelVisitor2 visitor = mock(IModelVisitor2.class);
ArgumentCaptor<IBase> element = ArgumentCaptor.forClass(IBase.class);
ArgumentCaptor<List<IBase>> containingElementPath = ArgumentCaptor.forClass(getListClass(IBase.class));
ArgumentCaptor<List<BaseRuntimeChildDefinition>> childDefinitionPath = ArgumentCaptor.forClass(getListClass(BaseRuntimeChildDefinition.class));
ArgumentCaptor<List<BaseRuntimeElementDefinition<?>>> elementDefinitionPath = ArgumentCaptor.forClass(getListClass2());
when(visitor.acceptElement(element.capture(), containingElementPath.capture(), childDefinitionPath.capture(), elementDefinitionPath.capture())).thenReturn(true);
Patient p = new Patient();
p.addLink().getTypeElement().setValue(LinkType.REFER);
ourCtx.newTerser().visit(p, visitor);
assertEquals(3, element.getAllValues().size());
assertSame(p, element.getAllValues().get(0));
assertSame(p.getLink().get(0), element.getAllValues().get(1));
assertSame(p.getLink().get(0).getTypeElement(), element.getAllValues().get(2));
assertEquals(3, containingElementPath.getAllValues().size());
// assertEquals(0, containingElementPath.getAllValues().get(0).size());
// assertEquals(1, containingElementPath.getAllValues().get(1).size());
// assertEquals(2, containingElementPath.getAllValues().get(2).size());
}
示例2: populatePrimitiveValue
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
private static void populatePrimitiveValue(FhirContext theContext, IBaseResource theSubscription, String theChildName, String theValue) {
RuntimeResourceDefinition def = theContext.getResourceDefinition(theSubscription);
Validate.isTrue(def.getName().equals("Subscription"), "theResource is not a subscription");
BaseRuntimeChildDefinition statusChild = def.getChildByName(theChildName);
List<IBase> entries = statusChild.getAccessor().getValues(theSubscription);
IPrimitiveType<?> instance;
if (entries.size() == 0) {
BaseRuntimeElementDefinition<?> statusElement = statusChild.getChildByName(theChildName);
instance = (IPrimitiveType<?>) statusElement.newInstance(statusChild.getInstanceConstructorArguments());
statusChild.getMutator().addValue(theSubscription, instance);
} else {
instance = (IPrimitiveType<?>) entries.get(0);
}
instance.setValueAsString(theValue);
}
示例3: getFirstIssueStringPart
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
private static String getFirstIssueStringPart(FhirContext theCtx, IBaseOperationOutcome theOutcome, String name) {
if (theOutcome == null) {
return null;
}
RuntimeResourceDefinition ooDef = theCtx.getResourceDefinition(theOutcome);
BaseRuntimeChildDefinition issueChild = ooDef.getChildByName("issue");
List<IBase> issues = issueChild.getAccessor().getValues(theOutcome);
if (issues.isEmpty()) {
return null;
}
IBase issue = issues.get(0);
BaseRuntimeElementCompositeDefinition<?> issueElement = (BaseRuntimeElementCompositeDefinition<?>) theCtx.getElementDefinition(issue.getClass());
BaseRuntimeChildDefinition detailsChild = issueElement.getChildByName(name);
List<IBase> details = detailsChild.getAccessor().getValues(issue);
if (details.isEmpty()) {
return null;
}
return ((IPrimitiveType<?>) details.get(0)).getValueAsString();
}
示例4: readHtmlResponse
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private T readHtmlResponse(Reader theResponseReader) {
RuntimeResourceDefinition resDef = getFhirContext().getResourceDefinition(myReturnType);
IBaseResource instance = resDef.newInstance();
BaseRuntimeChildDefinition textChild = resDef.getChildByName("text");
BaseRuntimeElementCompositeDefinition<?> textElement = (BaseRuntimeElementCompositeDefinition<?>) textChild.getChildByName("text");
IBase textInstance = textElement.newInstance();
textChild.getMutator().addValue(instance, textInstance);
BaseRuntimeChildDefinition divChild = textElement.getChildByName("div");
BaseRuntimeElementDefinition<?> divElement = divChild.getChildByName("div");
IPrimitiveType<?> divInstance = (IPrimitiveType<?>) divElement.newInstance();
try {
divInstance.setValueAsString(IOUtils.toString(theResponseReader));
} catch (Exception e) {
throw new InvalidResponseException(400, "Failed to process HTML response from server: " + e.getMessage(), e);
}
divChild.getMutator().addValue(textInstance, divInstance);
return (T) instance;
}
示例5: testVisitWithModelVisitor2
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
@Test
public void testVisitWithModelVisitor2() {
IModelVisitor2 visitor = mock(IModelVisitor2.class);
ArgumentCaptor<IBase> element = ArgumentCaptor.forClass(IBase.class);
ArgumentCaptor<List<IBase>> containingElementPath = ArgumentCaptor.forClass(getListClass(IBase.class));
ArgumentCaptor<List<BaseRuntimeChildDefinition>> childDefinitionPath = ArgumentCaptor.forClass(getListClass(BaseRuntimeChildDefinition.class));
ArgumentCaptor<List<BaseRuntimeElementDefinition<?>>> elementDefinitionPath = ArgumentCaptor.forClass(getListClass2());
when(visitor.acceptElement(element.capture(), containingElementPath.capture(), childDefinitionPath.capture(), elementDefinitionPath.capture())).thenReturn(true);
Patient p = new Patient();
p.addLink().getTypeElement().setValue("CODE");
ourCtx.newTerser().visit(p, visitor);
assertEquals(3, element.getAllValues().size());
assertSame(p, element.getAllValues().get(0));
assertSame(p.getLinkFirstRep(), element.getAllValues().get(1));
assertSame(p.getLinkFirstRep().getTypeElement(), element.getAllValues().get(2));
assertEquals(3, containingElementPath.getAllValues().size());
// assertEquals(0, containingElementPath.getAllValues().get(0).size());
// assertEquals(1, containingElementPath.getAllValues().get(1).size());
// assertEquals(2, containingElementPath.getAllValues().get(2).size());
}
示例6: scanChildren
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
private void scanChildren(HashSet<Class<?>> theHashSet, Class<? extends IBase> theClazz, BaseRuntimeElementCompositeDefinition<?> theRes) {
for (BaseRuntimeChildDefinition next : theRes.getChildren()) {
if (next.getElementName().contains("_")) {
fail("Element name " + next.getElementName() + " in type " + theClazz + " contains illegal '_'");
}
if (next instanceof RuntimeChildResourceBlockDefinition) {
RuntimeChildResourceBlockDefinition nextBlock = (RuntimeChildResourceBlockDefinition) next;
for (String nextName : nextBlock.getValidChildNames()) {
BaseRuntimeElementCompositeDefinition<?> elementDef = nextBlock.getChildByName(nextName);
if (theHashSet.add(elementDef.getImplementingClass())) {
scanChildren(theHashSet, elementDef.getImplementingClass(), elementDef);
}
}
}
}
}
示例7: resolveChoiceProperty
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
protected BaseRuntimeChildDefinition resolveChoiceProperty(BaseRuntimeElementCompositeDefinition definition, String path) {
for (Object child : definition.getChildren()) {
if (child instanceof RuntimeChildChoiceDefinition) {
RuntimeChildChoiceDefinition choiceDefinition = (RuntimeChildChoiceDefinition) child;
if(choiceDefinition.getValidChildNames().contains(path)){
return choiceDefinition;
}
}
}
throw new IllegalArgumentException(String.format("Unable to resolve path %s for %s", path, definition.getName()));
}
开发者ID:Discovery-Research-Network-SCCM,项目名称:FHIR-CQL-ODM-service,代码行数:15,代码来源:UsciitgFhirDataProviderHL7.java
示例8: resolveProperty
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
@Override
protected Object resolveProperty(Object target, String path) {
if (target == null) {
return null;
}
IBase base = (IBase) target;
BaseRuntimeElementCompositeDefinition<?> definition;
if (base instanceof IPrimitiveType) {
return toJavaPrimitive(path.equals("value") ? ((IPrimitiveType<?>) target).getValue() : target, base);
}
else {
definition = resolveRuntimeDefinition(base);
}
//BaseRuntimeChildDefinition child = definition.getChildByName(path);
BaseRuntimeChildDefinition child = getChildByName(definition, path);
if (child == null) {
child = resolveChoiceProperty(definition, path);
}
List<IBase> values = child.getAccessor().getValues(base);
if (values == null || values.isEmpty()) {
return null;
}
if (child instanceof RuntimeChildChoiceDefinition && !child.getElementName().equalsIgnoreCase(path)) {
if (!values.get(0).getClass().getSimpleName().equalsIgnoreCase(child.getChildByName(path).getImplementingClass().getSimpleName()))
{
return null;
}
}
Object result = child.getMax() < 1 ? values : values.get(0);
return toJavaPrimitive(result, result);
}
开发者ID:Discovery-Research-Network-SCCM,项目名称:FHIR-CQL-ODM-service,代码行数:38,代码来源:UsciitgFhirDataProviderHL7.java
示例9: getChildByName
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
private BaseRuntimeChildDefinition getChildByName(BaseRuntimeElementCompositeDefinition<?> definition, String name){
//BaseRuntimeElementCompositeDefinition.getChildByName() method does not work with FileBasedFhirDstu2Provider
//fails with search fields that don't exactly match child name, for instance Observation.effective
//getChildren() works
for(BaseRuntimeChildDefinition child : definition.getChildren()){
if(child.getElementName().equalsIgnoreCase(name)){
return child;
}
}
return null;
}
开发者ID:Discovery-Research-Network-SCCM,项目名称:FHIR-CQL-ODM-service,代码行数:12,代码来源:UsciitgFhirDataProviderHL7.java
示例10: encodeResourceToStreamWriterInDstu2Format
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
private void encodeResourceToStreamWriterInDstu2Format(RuntimeResourceDefinition theResDef, IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter,
BaseRuntimeElementCompositeDefinition<?> resDef, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
/*
* DSTU2 requires extensions to come in a specific spot within the encoded content - This is a bit of a messy way to make that happen, but hopefully this won't matter as much once we use the
* HL7 structures
*/
List<BaseRuntimeChildDefinition> preExtensionChildren = new ArrayList<BaseRuntimeChildDefinition>();
List<BaseRuntimeChildDefinition> postExtensionChildren = new ArrayList<BaseRuntimeChildDefinition>();
List<BaseRuntimeChildDefinition> children = resDef.getChildren();
for (BaseRuntimeChildDefinition next : children) {
if (next.getElementName().equals("text")) {
preExtensionChildren.add(next);
} else if (next.getElementName().equals("contained")) {
preExtensionChildren.add(next);
} else {
postExtensionChildren.add(next);
}
}
encodeCompositeElementChildrenToStreamWriter(theResource, theElement, theEventWriter, preExtensionChildren, theIncludedResource);
encodeExtensionsIfPresent(theResource, theEventWriter, theElement, theIncludedResource);
encodeCompositeElementChildrenToStreamWriter(theResource, theElement, theEventWriter, resDef.getExtensions(), theIncludedResource);
encodeCompositeElementChildrenToStreamWriter(theResource, theElement, theEventWriter, postExtensionChildren, theIncludedResource);
}
示例11: throwExceptionForUnknownChildType
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
protected void throwExceptionForUnknownChildType(BaseRuntimeChildDefinition nextChild, Class<? extends IBase> theType) {
if (nextChild instanceof BaseRuntimeDeclaredChildDefinition) {
StringBuilder b = new StringBuilder();
b.append(((BaseRuntimeDeclaredChildDefinition) nextChild).getElementName());
b.append(" has type ");
b.append(theType.getName());
b.append(" but this is not a valid type for this element");
if (nextChild instanceof RuntimeChildChoiceDefinition) {
RuntimeChildChoiceDefinition choice = (RuntimeChildChoiceDefinition) nextChild;
b.append(" - Expected one of: " + choice.getValidChildTypes());
}
throw new DataFormatException(b.toString());
}
throw new DataFormatException(nextChild + " has no child of type " + theType);
}
示例12: execute
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object execute() {
String resourceName;
String id;
if (myType != null) {
resourceName = myContext.getResourceDefinition(myType).getName();
id = null;
} else if (myId != null) {
resourceName = myId.getResourceType();
id = myId.getIdPart();
} else {
resourceName = null;
id = null;
}
BaseHttpClientInvocation invocation = OperationMethodBinding.createOperationInvocation(myContext, resourceName, id, myOperationName, myParameters, myUseHttpGet);
IClientResponseHandler handler;
handler = new ResourceResponseHandler(myParameters.getClass(), null);
Object retVal = invoke(null, handler, invocation);
if (myContext.getResourceDefinition((IBaseResource)retVal).getName().equals("Parameters")) {
return retVal;
} else {
RuntimeResourceDefinition def = myContext.getResourceDefinition("Parameters");
IBaseResource parameters = def.newInstance();
BaseRuntimeChildDefinition paramChild = def.getChildByName("parameter");
BaseRuntimeElementCompositeDefinition<?> paramChildElem = (BaseRuntimeElementCompositeDefinition<?>) paramChild.getChildByName("parameter");
IBase parameter = paramChildElem.newInstance();
paramChild.getMutator().addValue(parameters, parameter);
BaseRuntimeChildDefinition resourceElem = paramChildElem.getChildByName("resource");
resourceElem.getMutator().addValue(parameter, (IBase) retVal);
return parameters;
}
}
示例13: addUndeclaredExtensions
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
private <T extends IBase> void addUndeclaredExtensions(IBase theElement, BaseRuntimeElementDefinition<?> theDefinition, BaseRuntimeChildDefinition theChildDefinition,
IModelVisitor theCallback) {
if (theElement instanceof ISupportsUndeclaredExtensions) {
ISupportsUndeclaredExtensions containingElement = (ISupportsUndeclaredExtensions) theElement;
for (ExtensionDt nextExt : containingElement.getUndeclaredExtensions()) {
theCallback.acceptUndeclaredExtension(containingElement, null, theChildDefinition, theDefinition, nextExt);
addUndeclaredExtensions(nextExt, theDefinition, theChildDefinition, theCallback);
}
}
}
示例14: getDefinition
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
private BaseRuntimeChildDefinition getDefinition(BaseRuntimeElementCompositeDefinition<?> theCurrentDef, List<String> theSubList) {
BaseRuntimeChildDefinition nextDef = theCurrentDef.getChildByNameOrThrowDataFormatException(theSubList.get(0));
if (theSubList.size() == 1) {
return nextDef;
} else {
BaseRuntimeElementCompositeDefinition<?> cmp = (BaseRuntimeElementCompositeDefinition<?>) nextDef.getChildByName(theSubList.get(0));
return getDefinition(cmp, theSubList.subList(1, theSubList.size()));
}
}
示例15: getValues
import ca.uhn.fhir.context.BaseRuntimeChildDefinition; //导入依赖的package包/类
private List<Object> getValues(BaseRuntimeElementCompositeDefinition<?> theCurrentDef, Object theCurrentObj, List<String> theSubList) {
String name = theSubList.get(0);
BaseRuntimeChildDefinition nextDef = theCurrentDef.getChildByNameOrThrowDataFormatException(name);
List<? extends IBase> values = nextDef.getAccessor().getValues(theCurrentObj);
List<Object> retVal = new ArrayList<Object>();
if (theSubList.size() == 1) {
if (nextDef instanceof RuntimeChildChoiceDefinition) {
for (IBase next : values) {
if (next != null) {
if (name.endsWith("[x]")) {
retVal.add(next);
} else {
String childName = nextDef.getChildNameByDatatype(next.getClass());
if (theSubList.get(0).equals(childName)) {
retVal.add(next);
}
}
}
}
} else {
retVal.addAll(values);
}
} else {
for (IBase nextElement : values) {
BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(nextElement.getClass());
List<?> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()));
retVal.addAll(foundValues);
}
}
return retVal;
}