From 805378baa6620383aa847a553079a218364ca006 Mon Sep 17 00:00:00 2001 From: Sam Leeflang Date: Mon, 2 Dec 2024 14:58:56 +0100 Subject: [PATCH] Improve DOI identifier check --- pom.xml | 2 +- .../core/translator/terms/utils/IdentifierUtils.java | 4 ++-- .../core/translator/terms/utils/IdentifierUtilsTest.java | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 052b1bd..5709dc9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 3.3.5 + 3.4.0 eu.dissco.core diff --git a/src/main/java/eu/dissco/core/translator/terms/utils/IdentifierUtils.java b/src/main/java/eu/dissco/core/translator/terms/utils/IdentifierUtils.java index db97dcd..1ab5e31 100644 --- a/src/main/java/eu/dissco/core/translator/terms/utils/IdentifierUtils.java +++ b/src/main/java/eu/dissco/core/translator/terms/utils/IdentifierUtils.java @@ -33,9 +33,9 @@ private IdentifierUtils() { private static Map, Triple> patternMap() { var linkedMap = new LinkedHashMap, Triple>(); - linkedMap.put(List.of(compile("^https?://doi.org")), + linkedMap.put(List.of(compile("^https?://doi.org/10.")), Triple.of(DOI, "DOI", GLOBALLY_UNIQUE_STABLE_PERSISTENT_RESOLVABLE_FDO_COMPLIANT)); - linkedMap.put(List.of(compile("^https?://hdl.handle.net")), + linkedMap.put(List.of(compile("^https?://hdl.handle.net"), compile("^https?://doi.org/")), Triple.of(HANDLE, "Handle", GLOBALLY_UNIQUE_STABLE_PERSISTENT_RESOLVABLE_FDO_COMPLIANT)); linkedMap.put(List.of(compile("^https?://www.wikidata.org")), Triple.of(URL, "Wikidata", GLOBALLY_UNIQUE_STABLE_PERSISTENT_RESOLVABLE)); diff --git a/src/test/java/eu/dissco/core/translator/terms/utils/IdentifierUtilsTest.java b/src/test/java/eu/dissco/core/translator/terms/utils/IdentifierUtilsTest.java index ce4b3f8..f75578a 100644 --- a/src/test/java/eu/dissco/core/translator/terms/utils/IdentifierUtilsTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/utils/IdentifierUtilsTest.java @@ -1,6 +1,7 @@ package eu.dissco.core.translator.terms.utils; import static eu.dissco.core.translator.schema.Identifier.DctermsType.ARK; +import static eu.dissco.core.translator.schema.Identifier.DctermsType.DOI; import static eu.dissco.core.translator.schema.Identifier.DctermsType.HANDLE; import static eu.dissco.core.translator.schema.Identifier.DctermsType.LOCALLY_UNIQUE_IDENTIFIER; import static eu.dissco.core.translator.schema.Identifier.DctermsType.PURL; @@ -31,6 +32,12 @@ class IdentifierUtilsTest { public static Stream identifierProvider() { return Stream.of( + Arguments.of("https://doi.org/10.3535/M42-Z4P-DRD", null, PREFERRED, + createIdentifier("https://doi.org/10.3535/M42-Z4P-DRD", DOI, "DOI", + GLOBALLY_UNIQUE_STABLE_PERSISTENT_RESOLVABLE_FDO_COMPLIANT, PREFERRED)), + Arguments.of("https://doi.org/21.T11148/894b1e6cad57e921764e", null, PREFERRED, + createIdentifier("https://doi.org/21.T11148/894b1e6cad57e921764e", HANDLE, "Handle", + GLOBALLY_UNIQUE_STABLE_PERSISTENT_RESOLVABLE_FDO_COMPLIANT, PREFERRED)), Arguments.of("https://www.wikidata.org/wiki/Q66581882", null, null, createIdentifier("https://www.wikidata.org/wiki/Q66581882", URL, "Wikidata", GLOBALLY_UNIQUE_STABLE_PERSISTENT_RESOLVABLE, null)),