Handle sorting entries which contain no resources
This commit is contained in:
parent
798e960bb8
commit
a5e734fec8
|
@ -10,6 +10,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* HAPI FHIR - Core Library
|
* HAPI FHIR - Core Library
|
||||||
|
|
|
@ -248,6 +248,7 @@ public class BundleUtil {
|
||||||
|
|
||||||
for (BundleEntryParts bundleEntryPart : bundleEntryParts) {
|
for (BundleEntryParts bundleEntryPart : bundleEntryParts) {
|
||||||
IBaseResource resource = bundleEntryPart.getResource();
|
IBaseResource resource = bundleEntryPart.getResource();
|
||||||
|
if (resource != null) {
|
||||||
String resourceId = resource.getIdElement().toVersionless().toString();
|
String resourceId = resource.getIdElement().toVersionless().toString();
|
||||||
resourceIdToBundleEntryMap.put(resourceId, bundleEntryPart);
|
resourceIdToBundleEntryMap.put(resourceId, bundleEntryPart);
|
||||||
if (resourceId == null) {
|
if (resourceId == null) {
|
||||||
|
@ -257,11 +258,12 @@ public class BundleUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
color.put(resourceId, WHITE);
|
color.put(resourceId, WHITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BundleEntryParts bundleEntryPart : bundleEntryParts) {
|
for (BundleEntryParts bundleEntryPart : bundleEntryParts) {
|
||||||
IBaseResource resource = bundleEntryPart.getResource();
|
IBaseResource resource = bundleEntryPart.getResource();
|
||||||
|
if (resource != null) {
|
||||||
String resourceId = resource.getIdElement().toVersionless().toString();
|
String resourceId = resource.getIdElement().toVersionless().toString();
|
||||||
resourceIdToBundleEntryMap.put(resourceId, bundleEntryPart);
|
resourceIdToBundleEntryMap.put(resourceId, bundleEntryPart);
|
||||||
if (resourceId == null) {
|
if (resourceId == null) {
|
||||||
|
@ -282,6 +284,7 @@ public class BundleUtil {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, Integer> entry:color.entrySet()) {
|
for (Map.Entry<String, Integer> entry:color.entrySet()) {
|
||||||
if (entry.getValue() == WHITE) {
|
if (entry.getValue() == WHITE) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ca.uhn.fhir.util.bundle;
|
package ca.uhn.fhir.util.bundle;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.util.BundleBuilder;
|
||||||
import ca.uhn.fhir.util.BundleUtil;
|
import ca.uhn.fhir.util.BundleUtil;
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
import org.hl7.fhir.r4.model.Bundle;
|
import org.hl7.fhir.r4.model.Bundle;
|
||||||
|
@ -256,6 +257,15 @@ public class BundleUtilTest {
|
||||||
assertThat(entry.get(6).getRequest().getMethod(), is(equalTo(GET)));
|
assertThat(entry.get(6).getRequest().getMethod(), is(equalTo(GET)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBundleSortsCanHandlesDeletesThatContainNoResources() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.setId("Patient/123");
|
||||||
|
BundleBuilder builder = new BundleBuilder(ourCtx);
|
||||||
|
builder.addTransactionDeleteEntry(p);
|
||||||
|
BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, builder.getBundle());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransactionSorterReturnsDeletesInCorrectProcessingOrder() {
|
public void testTransactionSorterReturnsDeletesInCorrectProcessingOrder() {
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
|
|
Loading…
Reference in New Issue