From 48f2b6127ea739a81f3c43be659a45dfa22bcd51 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Mon, 29 Mar 2021 14:23:18 +0200 Subject: [PATCH] [Cleaning] drop alternate identifiers with empty values --- .../dhp/schema/oaf/CleaningFunctions.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/CleaningFunctions.java b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/CleaningFunctions.java index 6c7d3e915b..3be062c0c4 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/CleaningFunctions.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/CleaningFunctions.java @@ -152,14 +152,20 @@ public class CleaningFunctions { Optional .ofNullable(i.getPid()) .ifPresent(pid -> { - final Set pids = Sets - .newHashSet( + final Set pids = pid .stream() - .filter(p -> StringUtils.isBlank(p.getValue())) - .collect(Collectors.toList())); - final Set altIds = Sets.newHashSet(i.getAlternateIdentifier()); - i.setAlternateIdentifier(Lists.newArrayList(Sets.difference(altIds, pids))); + .filter(p -> StringUtils.isNotBlank(p.getValue())) + .collect(Collectors.toCollection(HashSet::new)); + + Optional.ofNullable(i.getAlternateIdentifier()) + .ifPresent(altId -> { + final Set altIds = altId.stream() + .filter(p -> StringUtils.isNotBlank(p.getValue())) + .collect(Collectors.toCollection(HashSet::new)); + + i.setAlternateIdentifier(Lists.newArrayList(Sets.difference(altIds, pids))); + }); }); if (Objects.isNull(i.getAccessright()) || StringUtils.isBlank(i.getAccessright().getClassid())) {