Skip to content
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

Issue 52072: Text choice field values to handle | character within values #6374

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from

Conversation

cnathe
Copy link
Contributor

@cnathe cnathe commented Feb 25, 2025

Rationale

https://www.labkey.org/home/Developer/issues/issues-details.view?issueId=52072
Text choice values are stored with a domain field as a regex validator as a concatenated string of values using the "|" delimiter. This PR updates this to account for values that contain the delimiter value.

Related Pull Requests

Changes

  • PageFlowUtil.joinValuesToString() and PageFlowUtil.splitStringToValues()
  • update usage in getTextChoiceValidatorOptions()

String[] valueTokens = str.split("(?<!\\\\)" + escapedDelimiter);

// trim values and replace escaped delimiter
List<String> valueList = Arrays.stream(valueTokens).map(String::trim)
Copy link
Contributor

@labkey-adam labkey-adam Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to go from list to stream to list to stream to list. Skip the toList() step on this line... keep it Stream<String> and then the steps below each become something simple like:

valueStream = valueStream.distinct();
valueStream = valueStream.sorted();

Then call .toList() on the return line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefect. That makes sense. Change made.

Copy link
Contributor

@labkey-adam labkey-adam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment about simplifying the stream handling in splitStringToValues()


values = PageFlowUtil.splitStringToValues("b|a|c| b | |", "|", false, false, false);
Assert.assertEquals(List.of("b", "a", "c", "b", ""), values);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for junit tests!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants