From 993406e3f010ce44760b5c13b27cc7d6ffd81e29 Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 27 Mar 2024 19:02:14 +0200 Subject: [PATCH] field builder fix --- .../FieldBuilder.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptionpropertiesdefinition/FieldBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptionpropertiesdefinition/FieldBuilder.java index e2fbf1ec9..84927c4f9 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptionpropertiesdefinition/FieldBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptionpropertiesdefinition/FieldBuilder.java @@ -101,10 +101,19 @@ public class FieldBuilder extends BaseBuilder { }, Reference::getId); } else { + List ids = new ArrayList<>(); + for (FieldEntity field: data) { + if (field.getTextListValue() != null) { + for (String value: field.getTextListValue()) { + if (value != null && !ids.contains(value)) ids.add(UUID.fromString(value)); + } + } + } FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Reference._id); - ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().map(FieldEntity::getTextListValue).flatMap(List::stream).map(UUID::fromString).distinct().collect(Collectors.toList())); - itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId); + ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(ids); + itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId);; } + if (!fields.hasField(Reference._id)) { itemMap.forEach((id, item) -> { if (item != null)