field builder fix

This commit is contained in:
amentis 2024-03-27 19:02:14 +02:00
parent 4d50aefacd
commit 993406e3f0
1 changed files with 11 additions and 2 deletions

View File

@ -101,10 +101,19 @@ public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
}, },
Reference::getId); Reference::getId);
} else { } else {
List<UUID> 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); 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())); 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); itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId);;
} }
if (!fields.hasField(Reference._id)) { if (!fields.hasField(Reference._id)) {
itemMap.forEach((id, item) -> { itemMap.forEach((id, item) -> {
if (item != null) if (item != null)