From e43ab07af602ab1da553ab23441dc37aa92646ed Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Tue, 24 Nov 2020 14:41:39 +0100 Subject: [PATCH] code formatting --- .../schema/oaf/utils/IdentifierFactory.java | 43 +++++++++++-------- .../oaf/utils/OrganizationPidComparator.java | 6 +-- .../schema/oaf/utils/PidValueComparator.java | 19 ++++---- .../schema/oaf/utils/ResultPidComparator.java | 4 +- 4 files changed, 40 insertions(+), 32 deletions(-) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/IdentifierFactory.java b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/IdentifierFactory.java index a7310e8de..6090b8e2f 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/IdentifierFactory.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/IdentifierFactory.java @@ -48,27 +48,32 @@ public class IdentifierFactory implements Serializable { } Map> pids = entity - .getPid() - .stream() - .filter(s -> pidFilter(s)) - .collect( - Collectors.groupingBy(p -> p.getQualifier().getClassid(), - Collectors.mapping(p -> p, Collectors.toList())) - ); + .getPid() + .stream() + .filter(s -> pidFilter(s)) + .collect( + Collectors + .groupingBy( + p -> p.getQualifier().getClassid(), + Collectors.mapping(p -> p, Collectors.toList()))); return pids - .values() - .stream() - .flatMap(s -> s.stream()) - .min(new PidComparator<>(entity)) - .map(min -> Optional.ofNullable(pids.get(min.getQualifier().getClassid())) - .map(p -> p.stream() - .sorted(new PidValueComparator()) - .findFirst() - .map(s -> idFromPid(entity, s)) - .orElseGet(entity::getId)) - .orElseGet(entity::getId)) - .orElseGet(entity::getId); + .values() + .stream() + .flatMap(s -> s.stream()) + .min(new PidComparator<>(entity)) + .map( + min -> Optional + .ofNullable(pids.get(min.getQualifier().getClassid())) + .map( + p -> p + .stream() + .sorted(new PidValueComparator()) + .findFirst() + .map(s -> idFromPid(entity, s)) + .orElseGet(entity::getId)) + .orElseGet(entity::getId)) + .orElseGet(entity::getId); } protected static boolean pidFilter(StructuredProperty s) { diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/OrganizationPidComparator.java b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/OrganizationPidComparator.java index a5e1b34d7..8cca517f9 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/OrganizationPidComparator.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/OrganizationPidComparator.java @@ -1,10 +1,10 @@ package eu.dnetlib.dhp.schema.oaf.utils; -import eu.dnetlib.dhp.schema.oaf.StructuredProperty; - import java.util.Comparator; +import eu.dnetlib.dhp.schema.oaf.StructuredProperty; + public class OrganizationPidComparator implements Comparator { @Override @@ -12,7 +12,7 @@ public class OrganizationPidComparator implements Comparator PidType lClass = PidType.valueOf(left.getQualifier().getClassid()); PidType rClass = PidType.valueOf(right.getQualifier().getClassid()); - + if (lClass.equals(PidType.GRID)) return -1; if (rClass.equals(PidType.GRID)) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/PidValueComparator.java b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/PidValueComparator.java index 3ac2381cc..087bbc121 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/PidValueComparator.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/PidValueComparator.java @@ -1,6 +1,9 @@ package eu.dnetlib.dhp.schema.oaf.utils; +import java.util.Comparator; +import java.util.Optional; + import eu.dnetlib.dhp.oa.graph.clean.CleaningFunctions; import eu.dnetlib.dhp.schema.common.ModelSupport; import eu.dnetlib.dhp.schema.oaf.OafEntity; @@ -8,9 +11,6 @@ import eu.dnetlib.dhp.schema.oaf.Organization; import eu.dnetlib.dhp.schema.oaf.Result; import eu.dnetlib.dhp.schema.oaf.StructuredProperty; -import java.util.Comparator; -import java.util.Optional; - public class PidValueComparator implements Comparator { @Override @@ -26,10 +26,13 @@ public class PidValueComparator implements Comparator { StructuredProperty l = CleaningFunctions.normalizePidValue(left); StructuredProperty r = CleaningFunctions.normalizePidValue(right); - return Optional.ofNullable(l.getValue()) - .map(lv -> Optional.ofNullable(r.getValue()) - .map(rv -> lv.compareTo(rv)) - .orElse(-1)) - .orElse(1); + return Optional + .ofNullable(l.getValue()) + .map( + lv -> Optional + .ofNullable(r.getValue()) + .map(rv -> lv.compareTo(rv)) + .orElse(-1)) + .orElse(1); } } diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/ResultPidComparator.java b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/ResultPidComparator.java index 0a733495d..38c7743a2 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/ResultPidComparator.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/ResultPidComparator.java @@ -1,10 +1,10 @@ package eu.dnetlib.dhp.schema.oaf.utils; -import eu.dnetlib.dhp.schema.oaf.StructuredProperty; - import java.util.Comparator; +import eu.dnetlib.dhp.schema.oaf.StructuredProperty; + public class ResultPidComparator implements Comparator { @Override