diff --git a/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/normalizers/CurieNormalizer.java b/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/normalizers/CurieNormalizer.java index 79754b9736f..6f6c3b5d37c 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/normalizers/CurieNormalizer.java +++ b/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/normalizers/CurieNormalizer.java @@ -1,6 +1,8 @@ package org.orcid.core.utils.v3.identifiers.normalizers; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.springframework.core.Ordered; import org.springframework.stereotype.Component; @@ -8,9 +10,10 @@ import com.google.common.collect.Lists; @Component -public class CurieNormalizer implements Normalizer { +public class CurieNormalizer implements NormalizerWithURLTransform { private static final List canHandle = Lists.newArrayList("rrid"); + private static final Pattern pattern = Pattern.compile("(?:(?i)RRID:)?(AB_\\d{6}|CVCL_[0-9A-Z]{4}|SCR_\\d{6}|IMSR_JAX\\:\\d{6}|Addgene_\\d{5}|SAMN\\d{8}|MMRRC_\\d{6}-UCD)"); @Override public List canHandle() { @@ -19,11 +22,7 @@ public List canHandle() { @Override public String normalise(String apiTypeName, String value) { - if (!canHandle.contains(apiTypeName)) - return value; - if (!value.startsWith(apiTypeName.toUpperCase() + ":")) - return apiTypeName.toUpperCase() + ":" + value; - return value; + return curieIdentifier(apiTypeName, value); } @Override @@ -31,4 +30,21 @@ public int getOrder() { return Ordered.LOWEST_PRECEDENCE; } + @Override + public String normaliseURL(String apiTypeName, String value) { + return curieIdentifier(apiTypeName, value); + } + + private String curieIdentifier(String apiTypeName, String value) { + if (!canHandle.contains(apiTypeName)) + return value; + Matcher m = pattern.matcher(value); + if (m.find()){ + String n = m.group(1); + if (n != null){ + return "RRID:"+n; + } + } + return ""; + } } diff --git a/orcid-persistence/src/main/resources/db-master.xml b/orcid-persistence/src/main/resources/db-master.xml index d3bd25cea31..c27b11c2f22 100644 --- a/orcid-persistence/src/main/resources/db-master.xml +++ b/orcid-persistence/src/main/resources/db-master.xml @@ -380,4 +380,5 @@ + diff --git a/orcid-persistence/src/main/resources/db/updates/identifier-types/update-ol-to-be-case-sensitive.xml b/orcid-persistence/src/main/resources/db/updates/identifier-types/update-ol-to-be-case-sensitive.xml new file mode 100644 index 00000000000..375e56a6463 --- /dev/null +++ b/orcid-persistence/src/main/resources/db/updates/identifier-types/update-ol-to-be-case-sensitive.xml @@ -0,0 +1,11 @@ + + + + + select count(*) from identifier_type WHERE id_name = 'OL'; + + UPDATE identifier_type SET "case_sensitive" = true WHERE id_name = 'OL'; + + +