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

Allow for JSON array objects in name generation data and improve error messaging #4785

Merged
merged 4 commits into from
Sep 29, 2023
Merged
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
7 changes: 6 additions & 1 deletion api/src/org/labkey/api/data/NameGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONArray;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -668,9 +669,13 @@ else if (value instanceof Collection)
Collection<?> coll = (Collection)value;
values = coll.stream().map(String::valueOf);
}
else if (value instanceof JSONArray jsonArray)
{
values = jsonArray.toList().stream().map(String::valueOf);
}
else
{
throw new IllegalStateException("Expected string or collection for '" + parentColName + "': " + value);
throw new IllegalStateException("For parent values in naming pattern, expected string or collection for '" + parentColName + "': " + value);
}

return values
Expand Down