Prevent duplicate researchers to be added when importing from RDA json

This commit is contained in:
George Kalampokis 2020-06-09 17:12:09 +03:00
parent 12587ee865
commit 314c62e1aa
1 changed files with 2 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package eu.eudat.models.rda.mapper;
import eu.eudat.data.entities.*;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.rda.Dmp;
import eu.eudat.models.rda.DmpId;
import net.minidev.json.JSONObject;
@ -80,7 +81,7 @@ public class DmpRDAMapper {
}
}
if (rda.getContributor() != null && !rda.getContributor().isEmpty()) {
entity.setResearchers(rda.getContributor().stream().map(ContributorRDAMapper::toEntity).collect(Collectors.toSet()));
entity.setResearchers(rda.getContributor().stream().map(ContributorRDAMapper::toEntity).filter(StreamDistinctBy.distinctByKey(Researcher::getReference)).collect(Collectors.toSet()));
}
entity.setCreated(rda.getCreated());
entity.setModified(rda.getModified());