2020-05-08 16:49:47 +02:00
|
|
|
|
2020-05-22 17:17:41 +02:00
|
|
|
package eu.dnetlib.dhp.broker.oa.matchers.simple;
|
2020-05-07 12:31:26 +02:00
|
|
|
|
|
|
|
import java.util.List;
|
2020-06-11 14:30:24 +02:00
|
|
|
import java.util.Set;
|
|
|
|
import java.util.stream.Collectors;
|
2020-05-07 12:31:26 +02:00
|
|
|
|
2020-06-16 12:34:13 +02:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
2020-06-22 08:51:31 +02:00
|
|
|
import eu.dnetlib.broker.objects.OaBrokerAuthor;
|
|
|
|
import eu.dnetlib.broker.objects.OaBrokerMainEntity;
|
2020-05-13 12:00:27 +02:00
|
|
|
import eu.dnetlib.dhp.broker.model.Topic;
|
2020-05-22 17:17:41 +02:00
|
|
|
import eu.dnetlib.dhp.broker.oa.matchers.UpdateMatcher;
|
2020-05-07 12:31:26 +02:00
|
|
|
|
2020-06-22 08:51:31 +02:00
|
|
|
public class EnrichMissingAuthorOrcid extends UpdateMatcher<OaBrokerAuthor> {
|
2020-05-07 12:31:26 +02:00
|
|
|
|
2020-05-13 12:00:27 +02:00
|
|
|
public EnrichMissingAuthorOrcid() {
|
2020-06-26 11:20:45 +02:00
|
|
|
super(40,
|
2020-06-12 09:47:55 +02:00
|
|
|
aut -> Topic.ENRICH_MISSING_AUTHOR_ORCID,
|
|
|
|
(p, aut) -> p.getCreators().add(aut),
|
2020-06-16 12:34:13 +02:00
|
|
|
aut -> aut.getOrcid());
|
2020-05-07 12:31:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-06-22 08:51:31 +02:00
|
|
|
protected List<OaBrokerAuthor> findDifferences(final OaBrokerMainEntity source,
|
|
|
|
final OaBrokerMainEntity target) {
|
2020-06-11 14:30:24 +02:00
|
|
|
|
|
|
|
final Set<String> existingOrcids = target
|
2020-06-16 12:34:13 +02:00
|
|
|
.getCreators()
|
2020-06-11 14:30:24 +02:00
|
|
|
.stream()
|
2020-06-22 08:51:31 +02:00
|
|
|
.map(OaBrokerAuthor::getOrcid)
|
2020-06-16 12:34:13 +02:00
|
|
|
.filter(StringUtils::isNotBlank)
|
2020-06-11 14:30:24 +02:00
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
2020-06-16 12:34:13 +02:00
|
|
|
return source
|
|
|
|
.getCreators()
|
|
|
|
.stream()
|
|
|
|
.filter(a -> StringUtils.isNotBlank(a.getOrcid()))
|
|
|
|
.filter(a -> !existingOrcids.contains(a.getOrcid()))
|
|
|
|
.collect(Collectors.toList());
|
2020-06-11 14:30:24 +02:00
|
|
|
|
2020-05-07 12:31:26 +02:00
|
|
|
}
|
|
|
|
}
|