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)); properties.put(id, parseComboBoxValues(node, parsedValues));
break; break;
case TAGS: case TAGS:
properties.put(id, parseTags(parsedValue)); properties.put(id, mapper.valueToTree(parseTags(value)).toString());
break; break;
default: default:
if (!parsedValues.isEmpty()) if (!parsedValues.isEmpty())
@ -201,11 +201,16 @@ public class PrefillingMapper {
private static List<Tag> parseTags(String value) throws JsonProcessingException { private static List<Tag> parseTags(String value) throws JsonProcessingException {
if (value == null || value.isEmpty()) if (value == null || value.isEmpty())
return null; return new LinkedList<>();
String[] rawTags = value.split(", "); JsonNode rawTags = mapper.readTree(value);
List<Tag> parsedTags = new LinkedList<>(); List<Tag> parsedTags = new LinkedList<>();
for (String rawTag : rawTags) { if (rawTags.isArray()) {
parsedTags.add(new Tag(rawTag, rawTag)); 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; return parsedTags;
} }