From ffa6bbf392af6ef27cfb0d0b7f13cc5d5e3e0710 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Fri, 25 Mar 2022 15:05:17 +0100 Subject: [PATCH] added MPE checks in the mergeOAFDataInfo method --- src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java b/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java index b0c5165..0df5572 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java +++ b/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java @@ -70,9 +70,14 @@ public abstract class Oaf implements Serializable { } public void mergeOAFDataInfo(Oaf o) { - - if (o.getDataInfo() != null && (compareTrust(this, o) < 0 || this.getDataInfo().getInvisible())) - dataInfo = o.getDataInfo(); + Optional.ofNullable(o) + .ifPresent(other -> Optional.ofNullable(other.getDataInfo()) + .ifPresent(otherDataInfo -> Optional.ofNullable(this.getDataInfo()) + .ifPresent(thisDataInfo -> { + if (compareTrust(this, other) < 0 || thisDataInfo.getInvisible()) { + setDataInfo(otherDataInfo); + } + }))); } protected String extractTrust(Oaf e) {