dnet-hadoop/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/matchers/simple/EnrichMissingAbstract.java

45 lines
1.3 KiB
Java
Raw Normal View History

2020-05-08 16:49:47 +02:00
package eu.dnetlib.dhp.broker.oa.matchers.simple;
2020-05-13 12:00:27 +02:00
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
2020-05-13 12:00:27 +02:00
import eu.dnetlib.dhp.broker.model.Topic;
import eu.dnetlib.dhp.broker.oa.matchers.UpdateMatcher;
2020-05-15 12:25:37 +02:00
import eu.dnetlib.dhp.broker.oa.util.UpdateInfo;
2020-06-11 11:25:18 +02:00
import eu.dnetlib.dhp.broker.oa.util.aggregators.withRels.ResultWithRelations;
2020-06-09 16:01:31 +02:00
import eu.dnetlib.pace.config.DedupConfig;
2020-06-11 11:25:18 +02:00
public class EnrichMissingAbstract extends UpdateMatcher<String> {
2020-05-13 12:00:27 +02:00
public EnrichMissingAbstract() {
super(false);
}
@Override
2020-06-11 11:25:18 +02:00
protected List<UpdateInfo<String>> findUpdates(final ResultWithRelations source,
final ResultWithRelations target,
2020-06-10 12:11:16 +02:00
final DedupConfig dedupConfig) {
2020-06-11 11:25:18 +02:00
if (isMissing(target.getResult().getDescription()) && !isMissing(source.getResult().getDescription())) {
2020-06-10 12:11:16 +02:00
return Arrays
2020-06-11 11:25:18 +02:00
.asList(
generateUpdateInfo(
source.getResult().getDescription().get(0).getValue(), source, target, dedupConfig));
2020-05-13 12:00:27 +02:00
}
return new ArrayList<>();
}
public UpdateInfo<String> generateUpdateInfo(final String highlightValue,
2020-06-11 11:25:18 +02:00
final ResultWithRelations source,
final ResultWithRelations target,
2020-06-09 16:01:31 +02:00
final DedupConfig dedupConfig) {
2020-05-13 12:00:27 +02:00
return new UpdateInfo<>(
Topic.ENRICH_MISSING_ABSTRACT,
highlightValue, source, target,
(p, s) -> p.getAbstracts().add(s),
2020-06-09 16:01:31 +02:00
s -> s, dedupConfig);
}
}