Fix issue saving tags from template when the field is a textField

This commit is contained in:
George Kalampokis 2022-03-15 17:52:58 +02:00
parent d3a1e85ba9
commit 563711eae4
1 changed files with 7 additions and 1 deletions

View File

@ -1058,13 +1058,19 @@ public class DatasetManager {
if (!tagNodes.isEmpty()) { if (!tagNodes.isEmpty()) {
tagNodes.forEach(node -> { tagNodes.forEach(node -> {
JsonNode value = node.get("value"); JsonNode value = node.get("value");
if (!value.toString().equals("\"\"") && !value.toString().equals("null")) { if (!value.toString().equals("\"\"") && !value.toString().equals("null") && value.toString().startsWith("[")) {
String stringValue = value.toString().replaceAll("=", ":"); String stringValue = value.toString().replaceAll("=", ":");
JSONArray values = new JSONArray(stringValue); JSONArray values = new JSONArray(stringValue);
values.iterator().forEachRemaining(element -> { values.iterator().forEachRemaining(element -> {
Map<String, Object> data = ((JSONObject) element).toMap(); Map<String, Object> data = ((JSONObject) element).toMap();
this.addTag(tags, wizardModel.getTags(), data.get("id").toString(), data.get("name").toString()); this.addTag(tags, wizardModel.getTags(), data.get("id").toString(), data.get("name").toString());
}); });
} else {
List<String> values = Arrays.asList(value.textValue().split(", "));
List<Tag> tagValues = values.stream().map(stringValue -> new Tag(stringValue, stringValue)).collect(Collectors.toList());
tagValues.iterator().forEachRemaining(tag -> {
this.addTag(tags, wizardModel.getTags(), tag.getId(), tag.getName());
});
} }
}); });
} }