From ab08d12c4677fde85310e8af67ae0c2334663b7a Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Thu, 19 Nov 2020 10:42:10 +0100 Subject: [PATCH] considering abstract > MIN_LENGTH in ENRICH_MISSING_ABSTRACT --- .../oa/matchers/simple/EnrichMissingAbstract.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/matchers/simple/EnrichMissingAbstract.java b/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/matchers/simple/EnrichMissingAbstract.java index b61696e45..eb1a9acdd 100644 --- a/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/matchers/simple/EnrichMissingAbstract.java +++ b/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/matchers/simple/EnrichMissingAbstract.java @@ -5,12 +5,16 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.commons.lang3.StringUtils; + import eu.dnetlib.broker.objects.OaBrokerMainEntity; import eu.dnetlib.dhp.broker.model.Topic; import eu.dnetlib.dhp.broker.oa.matchers.UpdateMatcher; public class EnrichMissingAbstract extends UpdateMatcher { + private static final int MIN_LENGTH = 200; + public EnrichMissingAbstract() { super(1, s -> Topic.ENRICH_MISSING_ABSTRACT, @@ -21,10 +25,15 @@ public class EnrichMissingAbstract extends UpdateMatcher { @Override protected List findDifferences(final OaBrokerMainEntity source, final OaBrokerMainEntity target) { if (isMissing(target.getAbstracts()) && !isMissing(source.getAbstracts())) { - return Arrays.asList(source.getAbstracts().get(0)); - } else { - return new ArrayList<>(); + return source + .getAbstracts() + .stream() + .filter(s -> StringUtils.normalizeSpace(s).length() >= MIN_LENGTH) + .map(Arrays::asList) + .findFirst() + .orElse(new ArrayList<>()); } + return new ArrayList<>(); } }