From 349e7246aa77db4baeeb7f152c8bfc882d0edd4d Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Mon, 30 Nov 2020 16:52:40 +0100 Subject: [PATCH] do not consider NCID, GBIF as PIDs candidate for the ID creation --- .../schema/oaf/utils/IdentifierFactory.java | 18 ++++++++---------- .../oaf/utils/OrganizationPidComparator.java | 4 ++-- .../dnetlib/dhp/schema/oaf/utils/PidType.java | 2 +- .../schema/oaf/utils/ResultPidComparator.java | 18 ++++-------------- 4 files changed, 15 insertions(+), 27 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 7acc021b4..5c3a4c37c 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 @@ -91,16 +91,14 @@ public class IdentifierFactory implements Serializable { if (CleaningFunctions.PID_BLACKLIST.contains(StringUtils.trim(s.getValue().toLowerCase()))) { return false; } - try { - switch (PidType.valueOf(s.getQualifier().getClassid())) { - case doi: - final String doi = StringUtils.trim(StringUtils.lowerCase(s.getValue())); - return doi.matches(DOI_REGEX); - default: - return true; - } - } catch (IllegalArgumentException e) { - return false; + switch (PidType.tryValueOf(s.getQualifier().getClassid())) { + case doi: + final String doi = StringUtils.trim(StringUtils.lowerCase(s.getValue())); + return doi.matches(DOI_REGEX); + case original: + return false; + default: + return true; } } 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 8cca517f9..57285fb82 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 @@ -10,8 +10,8 @@ public class OrganizationPidComparator implements Comparator @Override public int compare(StructuredProperty left, StructuredProperty right) { - PidType lClass = PidType.valueOf(left.getQualifier().getClassid()); - PidType rClass = PidType.valueOf(right.getQualifier().getClassid()); + PidType lClass = PidType.tryValueOf(left.getQualifier().getClassid()); + PidType rClass = PidType.tryValueOf(right.getQualifier().getClassid()); if (lClass.equals(PidType.GRID)) return -1; diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/PidType.java b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/PidType.java index 9a0196ccc..62f682026 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/PidType.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/PidType.java @@ -6,7 +6,7 @@ import org.apache.commons.lang3.EnumUtils; public enum PidType { // Result - doi, pmid, pmc, handle, arXiv, NCID, GBIF, nct, pdb, + doi, pmid, pmc, handle, arXiv, nct, pdb, // Organization GRID, mag_id, urn, 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 38c7743a2..e51c4801f 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 @@ -10,8 +10,8 @@ public class ResultPidComparator implements Comparator { @Override public int compare(StructuredProperty left, StructuredProperty right) { - PidType lClass = PidType.valueOf(left.getQualifier().getClassid()); - PidType rClass = PidType.valueOf(right.getQualifier().getClassid()); + PidType lClass = PidType.tryValueOf(left.getQualifier().getClassid()); + PidType rClass = PidType.tryValueOf(right.getQualifier().getClassid()); if (lClass.equals(PidType.doi)) return -1; @@ -38,24 +38,14 @@ public class ResultPidComparator implements Comparator { if (rClass.equals(PidType.arXiv)) return 1; - if (lClass.equals(PidType.NCID)) - return -1; - if (rClass.equals(PidType.NCID)) - return 1; - - if (lClass.equals(PidType.GBIF)) - return -1; - if (rClass.equals(PidType.GBIF)) - return 1; - if (lClass.equals(PidType.nct)) return -1; if (rClass.equals(PidType.nct)) return 1; - if (lClass.equals(PidType.urn)) + if (lClass.equals(PidType.pdb)) return -1; - if (rClass.equals(PidType.urn)) + if (rClass.equals(PidType.pdb)) return 1; return 0;