2020-05-21 16:47:53 +02:00
|
|
|
|
2020-06-04 17:10:43 +02:00
|
|
|
package eu.dnetlib.dhp.broker.oa.matchers.relatedSoftware;
|
2020-05-21 16:47:53 +02:00
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
2020-06-04 17:10:43 +02:00
|
|
|
import java.util.stream.Collectors;
|
2020-05-21 16:47:53 +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-06-04 17:10:43 +02:00
|
|
|
import eu.dnetlib.dhp.broker.oa.util.ConversionUtils;
|
2020-06-11 11:25:18 +02:00
|
|
|
import eu.dnetlib.dhp.broker.oa.util.aggregators.withRels.RelatedSoftware;
|
|
|
|
import eu.dnetlib.dhp.broker.oa.util.aggregators.withRels.ResultWithRelations;
|
2020-05-21 16:47:53 +02:00
|
|
|
|
|
|
|
public class EnrichMissingSoftware
|
2020-06-11 11:25:18 +02:00
|
|
|
extends UpdateMatcher<eu.dnetlib.broker.objects.Software> {
|
2020-05-21 16:47:53 +02:00
|
|
|
|
|
|
|
public EnrichMissingSoftware() {
|
2020-06-12 09:47:55 +02:00
|
|
|
super(true,
|
|
|
|
s -> Topic.ENRICH_MISSING_SOFTWARE,
|
|
|
|
(p, s) -> p.getSoftwares().add(s),
|
|
|
|
s -> s.getName());
|
2020-05-21 16:47:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-06-12 09:47:55 +02:00
|
|
|
protected List<eu.dnetlib.broker.objects.Software> findDifferences(
|
2020-06-11 11:25:18 +02:00
|
|
|
final ResultWithRelations source,
|
2020-06-12 09:47:55 +02:00
|
|
|
final ResultWithRelations target) {
|
2020-06-04 17:10:43 +02:00
|
|
|
|
2020-06-11 11:25:18 +02:00
|
|
|
if (source.getSoftwares().isEmpty()) {
|
2020-06-04 17:10:43 +02:00
|
|
|
return Arrays.asList();
|
|
|
|
} else {
|
2020-06-08 08:32:22 +02:00
|
|
|
return target
|
2020-06-11 11:25:18 +02:00
|
|
|
.getSoftwares()
|
2020-06-04 17:10:43 +02:00
|
|
|
.stream()
|
2020-06-11 11:25:18 +02:00
|
|
|
.map(RelatedSoftware::getRelSoftware)
|
2020-06-04 17:10:43 +02:00
|
|
|
.map(ConversionUtils::oafSoftwareToBrokerSoftware)
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
}
|
2020-05-21 16:47:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|