[
https://issues.apache.org/jira/browse/OFBIZ-10458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16535389#comment-16535389 ]
Mathieu Lirzin commented on OFBIZ-10458:
----------------------------------------
You are correct about the fact that we can rely on groovy truth, I overlooked that.
Given your suggestion, here is the implementation I am proposing which additionally makes use of the [{{with}}|
http://groovy-lang.org/style-guide.html#_using_code_with_code_and_code_tap_code_for_repeated_operations_on_the_same_bean] method:
{code:java}
// Check that `a` contains `b` when ignoring case.
boolean contains(String a, String b) {
b && a.toUpperCase().contains(b.toUpperCase())
}
hasFilter = parameters.with { localeString || localeName }
context.locales = availableLocales()
.stream()
.map { [localeName: it.getDisplayName(it), localeString: it.toString()] }
.filter {
!hasFilter ||
contains(it.localeString, parameters.localeString) ||
contains(it.localeName, parameters.localeName)
}
.collect toList()
{code}
> GetLocaleList call can provide duplicate results
> ------------------------------------------------
>
> Key: OFBIZ-10458
> URL:
https://issues.apache.org/jira/browse/OFBIZ-10458> Project: OFBiz
> Issue Type: Bug
> Reporter: Mathieu Lirzin
> Assignee: Gil Portenseigne
> Priority: Minor
> Fix For: 17.12.01, 16.11.05, Upcoming Branch
>
> Attachments: OFBIZ-10458_0001-Add-failing-tests.patch, OFBIZ-10458_0002-Fix-duplicates-bug.patch, OFBIZ-10458_0003-Refactor.patch
>
>
> This is not a huge issue but I detected an issue with the {{GetLocaleList}} script which when providing both a {{localeString}} and {{localeName}} can provide duplicate results.
> Here is a set of 3 patches that should be applied in order:
> - the first one is adding some tests with a failing one which identifies the bug
> - the second one resolves the bug
> - the third one refactors the code to use a more functional style
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)