From 74b185d07b3655f6e964ce5ae0610695d1685903 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Sun, 3 Dec 2023 16:18:20 +0100 Subject: [PATCH] avoid NPEs --- .../dhp/schema/oaf/utils/GraphCleaningFunctions.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/GraphCleaningFunctions.java b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/GraphCleaningFunctions.java index 7cb32eab5..c65f36de9 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/GraphCleaningFunctions.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/GraphCleaningFunctions.java @@ -943,17 +943,17 @@ public class GraphCleaningFunctions extends CleaningFunctions { private static Qualifier getMetaResourceType(final List instances, final VocabularyGroup vocs) { if (vocs.vocabularyExists(OPENAIRE_META_RESOURCE_TYPE)) { - Optional instanceTypeMapping = instances + Optional itm = instances .stream() .flatMap( i -> Optional.ofNullable(i.getInstanceTypeMapping()).map(Collection::stream).orElse(Stream.empty())) .filter(t -> OPENAIRE_COAR_RESOURCE_TYPES_3_1.equals(t.getVocabularyName())) .findFirst(); - if (!instanceTypeMapping.isPresent()) { + if (!itm.isPresent() || Objects.isNull(itm.get().getTypeCode())) { return null; } else { - final String typeCode = instanceTypeMapping.get().getTypeCode(); + final String typeCode = itm.get().getTypeCode(); return Optional .ofNullable(vocs.lookupTermBySynonym(OPENAIRE_META_RESOURCE_TYPE, typeCode)) .orElseThrow(