Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Diamantis Tziotzios 2024-03-27 20:08:00 +02:00
commit f4cbc3742c
1 changed files with 11 additions and 2 deletions

View File

@ -101,10 +101,19 @@ public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
},
Reference::getId);
} else {
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);
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);
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)