Fix error message for bad $mdm-link-history input and handle comma-delimited input (#4701)
* Fix error message for bad $mdm-link-history input and handle comma-delimited input. * Code review feedback: filter out null objects in the stream.
This commit is contained in:
parent
ee8b5b39d4
commit
1faf77dcc8
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 4700
|
||||
title: "When querying $mdm-link-history with no inputs, the error message is mislaeading. Also, $mdm-link-history cannot handle comma-delimited inputs.
|
||||
Both issues are now fixed."
|
|
@ -41,8 +41,11 @@ import org.springframework.data.domain.Page;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
@ -74,7 +77,7 @@ public abstract class BaseMdmProvider {
|
|||
|
||||
private void validateBothCannotBeNullOrEmpty(String theFirstName, List<IPrimitiveType<String>> theFirstList, String theSecondName, List<IPrimitiveType<String>> theSecondList) {
|
||||
if ((theFirstList == null || theFirstList.isEmpty()) && (theSecondList == null || theSecondList.isEmpty())) {
|
||||
throw new InvalidRequestException(Msg.code(2292) + "both ["+theFirstName+"] and ["+theSecondName+"] cannot be null or empty");
|
||||
throw new InvalidRequestException(Msg.code(2292) + "Please include either ["+theFirstName+"]s, ["+theSecondName+"]s, or both in your search inputs.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,10 +126,17 @@ public abstract class BaseMdmProvider {
|
|||
}
|
||||
|
||||
@Nonnull
|
||||
protected List<String> convertToStringsIfNotNull(List<IPrimitiveType<String>> thePrimitiveTypeStrings) {
|
||||
return thePrimitiveTypeStrings == null
|
||||
? Collections.emptyList()
|
||||
: thePrimitiveTypeStrings.stream().map(this::extractStringOrNull).collect(Collectors.toUnmodifiableList());
|
||||
protected List<String> convertToStringsIncludingCommaDelimitedIfNotNull(List<IPrimitiveType<String>> thePrimitiveTypeStrings) {
|
||||
if (thePrimitiveTypeStrings == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return thePrimitiveTypeStrings.stream()
|
||||
.map(this::extractStringOrNull)
|
||||
.filter(Objects::nonNull)
|
||||
.map(input -> Arrays.asList(input.split(",")))
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toUnmodifiableList());
|
||||
}
|
||||
|
||||
protected String extractStringOrNull(IPrimitiveType<String> theString) {
|
||||
|
|
|
@ -53,8 +53,8 @@ public class MdmLinkHistoryProviderDstu3Plus extends BaseMdmProvider {
|
|||
ServletRequestDetails theRequestDetails) {
|
||||
validateMdmLinkHistoryParameters(theMdmGoldenResourceIds, theResourceIds);
|
||||
|
||||
final List<String> goldenResourceIdsToUse = convertToStringsIfNotNull(theMdmGoldenResourceIds);
|
||||
final List<String> resourceIdsToUse = convertToStringsIfNotNull(theResourceIds);
|
||||
final List<String> goldenResourceIdsToUse = convertToStringsIncludingCommaDelimitedIfNotNull(theMdmGoldenResourceIds);
|
||||
final List<String> resourceIdsToUse = convertToStringsIncludingCommaDelimitedIfNotNull(theResourceIds);
|
||||
|
||||
final IBaseParameters retVal = ParametersUtil.newInstance(myFhirContext);
|
||||
|
||||
|
|
Loading…
Reference in New Issue