[graph provision] select the longest abstract

This commit is contained in:
Claudio Atzori 2024-10-28 10:03:02 +01:00
parent 0fb6af5586
commit 32fa579b80
1 changed files with 3 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package eu.dnetlib.dhp.oa.provision;
import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession; import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
@ -167,8 +168,9 @@ public class CreateRelatedEntitiesJob_phase1 {
result result
.getDescription() .getDescription()
.stream() .stream()
.findFirst() .filter(d -> Objects.nonNull(d.getValue()))
.map(Field::getValue) .map(Field::getValue)
.max(Comparator.comparingInt(String::length))
.ifPresent( .ifPresent(
d -> re.setDescription(StringUtils.left(d, ModelHardLimits.MAX_RELATED_ABSTRACT_LENGTH))); d -> re.setDescription(StringUtils.left(d, ModelHardLimits.MAX_RELATED_ABSTRACT_LENGTH)));
} }