fixed tag prefilling

This commit is contained in:
Bernaldo Mihasi 2022-02-22 14:00:22 +02:00
parent 817ee9b44d
commit 0bd08c2fac
1 changed files with 10 additions and 5 deletions

View File

@ -146,7 +146,7 @@ public class PrefillingMapper {
properties.put(id, parseComboBoxValues(node, parsedValues));
break;
case TAGS:
properties.put(id, parseTags(parsedValue));
properties.put(id, mapper.valueToTree(parseTags(value)).toString());
break;
default:
if (!parsedValues.isEmpty())
@ -201,11 +201,16 @@ public class PrefillingMapper {
private static List<Tag> parseTags(String value) throws JsonProcessingException {
if (value == null || value.isEmpty())
return null;
String[] rawTags = value.split(", ");
return new LinkedList<>();
JsonNode rawTags = mapper.readTree(value);
List<Tag> parsedTags = new LinkedList<>();
for (String rawTag : rawTags) {
parsedTags.add(new Tag(rawTag, rawTag));
if (rawTags.isArray()) {
for (int i = 0; i < rawTags.size(); i++) {
parsedTags.add(new Tag(rawTags.get(i).textValue(), rawTags.get(i).textValue()));
}
} else if (rawTags.isTextual()) {
List<String> tags = Arrays.asList(rawTags.textValue().split(", "));
parsedTags.addAll(tags.stream().map(s -> new Tag(s, s)).collect(Collectors.toList()));
}
return parsedTags;
}