Skip to content

Commit

Permalink
Merge pull request #435 from Breeding-Insight/bug/BI-2343
Browse files Browse the repository at this point in the history
[BI-2343] - GID filtering not informative
  • Loading branch information
HMS17 authored Nov 27, 2024
2 parents e778c65 + 0130ce6 commit 8e7ec0c
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ private static List<?> search(List<?> data, SearchRequest searchRequest, Abstrac
.collect(Collectors.toList());
}

//To enable checking for the case of Germplasm Search when the filter is accessionNumber or list entry number and thereby needs to do exact match
String accessionNumFilter;
if (mapper.exists("accessionNumber")) accessionNumFilter = mapper.getField("accessionNumber").toString();
else {
accessionNumFilter = "";
}
String entryNumFilter;
if (mapper.exists("importEntryNumber")) entryNumFilter = mapper.getField("importEntryNumber").toString();
else {
entryNumFilter = "";
}

if (filterFields.size() > 0){
// Apply filters
List<FilterField> finalFilterFields = filterFields;
Expand All @@ -211,6 +223,16 @@ private static List<?> search(List<?> data, SearchRequest searchRequest, Abstrac
return recordList.stream()
.anyMatch(listValue ->
listValue.toString().toLowerCase().contains(filterField.getValue().toLowerCase()));
}
else if (!accessionNumFilter.isEmpty() && filterField.getField().toString().equals(accessionNumFilter)) {
//enable exact match in case of GID
return filterField.getField().apply(record).toString()
.toLowerCase().equalsIgnoreCase(filterField.getValue().toLowerCase());
}
else if (!entryNumFilter.isEmpty() && filterField.getField().toString().equals(entryNumFilter)) {
//enable exact match in case of entry number
return filterField.getField().apply(record).toString()
.toLowerCase().equalsIgnoreCase(filterField.getValue().toLowerCase());
} else {
return filterField.getField().apply(record).toString()
.toLowerCase().contains(filterField.getValue().toLowerCase());
Expand Down

0 comments on commit 8e7ec0c

Please sign in to comment.