public List<ResourceReferenceInfo> getAllResourceReferences(final IBaseResource theResource) { final ArrayList<ResourceReferenceInfo> retVal = new ArrayList<ResourceReferenceInfo>(); BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource); visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, new IModelVisitor() { @Override public void acceptElement(IBaseResource theOuterResource, IBase theElement, List<String> thePathToElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition<?> theDefinition) { if (theElement == null || theElement.isEmpty()) { return; } if (IBaseReference.class.isAssignableFrom(theElement.getClass())) { retVal.add(new ResourceReferenceInfo(myContext, theOuterResource, thePathToElement, (IBaseReference) theElement)); } } }); return retVal; }
/** * Visit all elements in a given resource * * <p> * Note on scope: This method will descend into any contained resources ({@link IResource#getContained()}) as well, but will not descend into linked resources (e.g. * {@link BaseResourceReferenceDt#getResource()}) or embedded resources (e.g. Bundle.entry.resource) * </p> * * @param theResource The resource to visit * @param theVisitor The visitor */ public void visit(IBaseResource theResource, IModelVisitor theVisitor) { BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource); visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, theVisitor); }
/** * Visit all elements in a given resource * <p> * THIS ALTERNATE METHOD IS STILL EXPERIMENTAL * * <p> * Note on scope: This method will descend into any contained resources ({@link IResource#getContained()}) as well, but will not descend into linked resources (e.g. * {@link BaseResourceReferenceDt#getResource()}) or embedded resources (e.g. Bundle.entry.resource) * </p> * * @param theResource The resource to visit * @param theVisitor The visitor */ void visit(IBaseResource theResource, IModelVisitor2 theVisitor) { BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource); visit(theResource, null, def, theVisitor, new ArrayList<IBase>(), new ArrayList<BaseRuntimeChildDefinition>(), new ArrayList<BaseRuntimeElementDefinition<?>>()); }
final ArrayList<T> retVal = new ArrayList<T>(); BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource); visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, new IModelVisitor() { @SuppressWarnings("unchecked") @Override
theElementDefinitionPath.remove(theElementDefinitionPath.size() - 1); } else { visit(nextValue, nextChild, childElementDef, theCallback, theContainingElementPath, theChildDefinitionPath, theElementDefinitionPath); for (IResource next : value.getContainedResources()) { BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(next); visit(next, null, def, theCallback, theContainingElementPath, theChildDefinitionPath, theElementDefinitionPath); if (theElement != null) { BaseRuntimeElementDefinition<?> def = myContext.getElementDefinition(theElement.getClass()); visit(theElement, null, def, theCallback, theContainingElementPath, theChildDefinitionPath, theElementDefinitionPath);
if (target.getIdElement().hasIdPart() == false || target.getIdElement().isLocal()) { RuntimeResourceDefinition targetDef = myContext.getResourceDefinition(target); visit(theStack, target, target, pathToElement, null, targetDef, theCallback); visit(theStack, theResource, nextValue, pathToElement, nextChild, childElementDef, theCallback); for (IResource next : value.getContainedResources()) { def = myContext.getResourceDefinition(next); visit(theStack, next, next, pathToElement, null, def, theCallback);
/** * Visit all elements in a given resource * <p> * THIS ALTERNATE METHOD IS STILL EXPERIMENTAL * * <p> * Note on scope: This method will descend into any contained resources ({@link IResource#getContained()}) as well, but will not descend into linked resources (e.g. * {@link BaseResourceReferenceDt#getResource()}) or embedded resources (e.g. Bundle.entry.resource) * </p> * * @param theResource The resource to visit * @param theVisitor The visitor */ void visit(IBaseResource theResource, IModelVisitor2 theVisitor) { BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource); visit(theResource, null, def, theVisitor, new ArrayList<IBase>(), new ArrayList<BaseRuntimeChildDefinition>(), new ArrayList<BaseRuntimeElementDefinition<?>>()); }
/** * Visit all elements in a given resource * * <p> * Note on scope: This method will descend into any contained resources ({@link IResource#getContained()}) as well, but will not descend into linked resources (e.g. * {@link BaseResourceReferenceDt#getResource()}) or embedded resources (e.g. Bundle.entry.resource) * </p> * * @param theResource The resource to visit * @param theVisitor The visitor */ public void visit(IBaseResource theResource, IModelVisitor theVisitor) { BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource); visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, theVisitor); }
public List<ResourceReferenceInfo> getAllResourceReferences(final IBaseResource theResource) { final ArrayList<ResourceReferenceInfo> retVal = new ArrayList<ResourceReferenceInfo>(); BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource); visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, new IModelVisitor() { @Override public void acceptElement(IBaseResource theOuterResource, IBase theElement, List<String> thePathToElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition<?> theDefinition) { if (theElement == null || theElement.isEmpty()) { return; } if (IBaseReference.class.isAssignableFrom(theElement.getClass())) { retVal.add(new ResourceReferenceInfo(myContext, theOuterResource, thePathToElement, (IBaseReference) theElement)); } } }); return retVal; }
final ArrayList<T> retVal = new ArrayList<T>(); BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource); visit(new IdentityHashMap<Object, Object>(), theResource, theResource, null, null, def, new IModelVisitor() { @SuppressWarnings("unchecked") @Override
theElementDefinitionPath.remove(theElementDefinitionPath.size() - 1); } else { visit(nextValue, nextChild, childElementDef, theCallback, theContainingElementPath, theChildDefinitionPath, theElementDefinitionPath); for (IResource next : value.getContainedResources()) { BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(next); visit(next, null, def, theCallback, theContainingElementPath, theChildDefinitionPath, theElementDefinitionPath); if (theElement != null) { BaseRuntimeElementDefinition<?> def = myContext.getElementDefinition(theElement.getClass()); visit(theElement, null, def, theCallback, theContainingElementPath, theChildDefinitionPath, theElementDefinitionPath);
if (target.getIdElement().hasIdPart() == false || target.getIdElement().isLocal()) { RuntimeResourceDefinition targetDef = myContext.getResourceDefinition(target); visit(theStack, target, target, pathToElement, null, targetDef, theCallback); visit(theStack, theResource, nextValue, pathToElement, nextChild, childElementDef, theCallback); for (IResource next : value.getContainedResources()) { def = myContext.getResourceDefinition(next); visit(theStack, next, next, pathToElement, null, def, theCallback);