Skip to content

TRUNK-6260: Add Commons Collections 4 to the provided set of libraries #4989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.FlushMode;
import org.hibernate.Session;
Expand Down Expand Up @@ -1487,10 +1488,12 @@ private LuceneQuery<Drug> newDrugQuery(String drugName, boolean searchKeywords,
Collections.singletonList(locale), exactLocale, includeRetired, null, null, null, null, null);
List<Object[]> conceptIds = conceptNameQuery.listProjection("concept.conceptId");
if (!conceptIds.isEmpty()) {
CollectionUtils.transform(conceptIds, input -> ((Object[]) input)[0].toString());
List<String> conceptIdStrings = conceptIds.stream()
.map(input -> ((Object[]) input)[0].toString())
.collect(Collectors.toList());
//The default Lucene clauses limit is 1024. We arbitrarily chose to use 512 here as it does not make sense to return more hits by concept name anyway.
int maxSize = (conceptIds.size() < 512) ? conceptIds.size() : 512;
query.append(" OR concept.conceptId:(").append(StringUtils.join(conceptIds.subList(0, maxSize), " OR "))
int maxSize = Math.min(conceptIdStrings.size(), 512);
query.append(" OR concept.conceptId:(").append(StringUtils.join(conceptIdStrings.subList(0, maxSize), " OR "))
.append(")^0.1");
}
}
Expand Down
Loading