Skip to content

Commit

Permalink
Merge pull request #6965 from ORCID/8984-fix-the-outstanding-issues-t…
Browse files Browse the repository at this point in the history
…hat-we-have-with-a-small-number-of-work-identifiers

fix: Add OL identifier case sensitive and RRID regex validator
  • Loading branch information
amontenegro authored Jan 3, 2024
2 parents cafb120 + 4fce8d6 commit fd30a36
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
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;

import com.google.common.collect.Lists;

@Component
public class CurieNormalizer implements Normalizer {
public class CurieNormalizer implements NormalizerWithURLTransform {

private static final List<String> 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<String> canHandle() {
Expand All @@ -19,16 +22,29 @@ public List<String> 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
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 "";
}
}
1 change: 1 addition & 0 deletions orcid-persistence/src/main/resources/db-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,5 @@
<include file="/db/updates/dw_alter_event.xml" />
<include file="/db/updates/dw_alter_event_2.xml" />
<include file="/db/updates/grant_select_to_dw_user_on_dw_event.xml" />
<include file="/db/updates/identifier-types/update-ol-to-be-case-sensitive.xml" />
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">

<changeSet id="UPDATE-ETHOS-TO-BE-CASE-SENSITIVE" author="Daniel Palafox">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">select count(*) from identifier_type WHERE id_name = 'OL';</sqlCheck>
</preConditions>
<sql>UPDATE identifier_type SET "case_sensitive" = true WHERE id_name = 'OL';</sql>
</changeSet>

</databaseChangeLog>

0 comments on commit fd30a36

Please sign in to comment.