We only need to extract the existing contained resources once

This commit is contained in:
David Maplesden 2019-09-17 12:28:37 +12:00 committed by James Agnew
parent 1f253856cf
commit 4021fccf3b
1 changed files with 25 additions and 25 deletions

View File

@ -204,31 +204,6 @@ public abstract class BaseParser implements IParser {
}
private void containResourcesForEncoding(ContainedResources theContained, IBaseResource theResource, IBaseResource theTarget) {
if (theTarget instanceof IResource) {
List<? extends IResource> containedResources = ((IResource) theTarget).getContained().getContainedResources();
for (IResource next : containedResources) {
String nextId = next.getId().getValue();
if (StringUtils.isNotBlank(nextId)) {
if (!nextId.startsWith("#")) {
nextId = '#' + nextId;
}
theContained.getExistingIdToContainedResource().put(nextId, next);
}
}
} else if (theTarget instanceof IDomainResource) {
List<? extends IAnyResource> containedResources = ((IDomainResource) theTarget).getContained();
for (IAnyResource next : containedResources) {
String nextId = next.getIdElement().getValue();
if (StringUtils.isNotBlank(nextId)) {
if (!nextId.startsWith("#")) {
nextId = '#' + nextId;
}
theContained.getExistingIdToContainedResource().put(nextId, next);
}
}
}
List<IBaseReference> allReferences = getAllBaseReferences(theResource);
for (IBaseReference next : allReferences) {
IBaseResource resource = next.getResource();
@ -268,6 +243,31 @@ public abstract class BaseParser implements IParser {
protected void containResourcesForEncoding(IBaseResource theResource) {
ContainedResources contained = new ContainedResources();
if (theResource instanceof IResource) {
List<? extends IResource> containedResources = ((IResource) theResource).getContained().getContainedResources();
for (IResource next : containedResources) {
String nextId = next.getId().getValue();
if (StringUtils.isNotBlank(nextId)) {
if (!nextId.startsWith("#")) {
nextId = '#' + nextId;
}
contained.getExistingIdToContainedResource().put(nextId, next);
}
}
} else if (theResource instanceof IDomainResource) {
List<? extends IAnyResource> containedResources = ((IDomainResource) theResource).getContained();
for (IAnyResource next : containedResources) {
String nextId = next.getIdElement().getValue();
if (StringUtils.isNotBlank(nextId)) {
if (!nextId.startsWith("#")) {
nextId = '#' + nextId;
}
contained.getExistingIdToContainedResource().put(nextId, next);
}
}
}
containResourcesForEncoding(contained, theResource, theResource);
contained.assignIdsToContainedResources();
myContainedResources = contained;