Skip to content

Commit

Permalink
put ROR regex in line with existing pattern #11075
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jan 21, 2025
1 parent 8653513 commit 1fe95d9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ public enum ExternalIdentifier {
// note: DAI is missing from this list, because it doesn't have resolvable URL
ResearcherID("ResearcherID", "https://publons.com/researcher/%s/", "^[A-Z\\d][A-Z\\d-]+[A-Z\\d]$"),
ScopusID("ScopusID", "https://www.scopus.com/authid/detail.uri?authorId=%s", "^\\d*$"),
//Requiring ROR to be URL form as we use it where there is no id type field and matching any 9 digit number starting with 0 seems a bit aggressive
ROR("ROR", "https://ror.org/%s", "^(https:\\/\\/ror.org\\/)0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$");
// ROR regex from https://ror.readme.io/docs/identifier
ROR("ROR", "https://ror.org/%s", "^0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$"),
// In some contexts, we check for the full ROR URL.
ROR_FULL_URL("ROR", "https://ror.org/%s", "^(https:\\/\\/ror.org\\/)0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$");

private String name;
private String template;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ private void writeEntityElements(XMLStreamWriter xmlw, String elementName, Strin
attributeMap.clear();
boolean isROR=false;
String orgName = affiliation;
ExternalIdentifier externalIdentifier = ExternalIdentifier.ROR;
ExternalIdentifier externalIdentifier = ExternalIdentifier.ROR_FULL_URL;
if (externalIdentifier.isValidIdentifier(orgName)) {
isROR = true;
JsonObject jo = getExternalVocabularyValue(orgName);
Expand Down Expand Up @@ -1528,7 +1528,7 @@ private void writeFundingReferences(XMLStreamWriter xmlw, DvObject dvObject) thr
fundingReferenceWritten = XmlWriterUtil.writeOpenTagIfNeeded(xmlw, "fundingReferences", fundingReferenceWritten);
boolean isROR=false;
String funderIdentifier = null;
ExternalIdentifier externalIdentifier = ExternalIdentifier.ROR;
ExternalIdentifier externalIdentifier = ExternalIdentifier.ROR_FULL_URL;
if (externalIdentifier.isValidIdentifier(funder)) {
isROR = true;
JsonObject jo = getExternalVocabularyValue(funder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void testIsValidAuthorIdentifierGnd() {
public void testIsValidAuthorIdentifierRor() {
DatasetFieldValueValidator validator = new DatasetFieldValueValidator();
Pattern pattern = ExternalIdentifier.valueOf("ROR").getPattern();
assertTrue(validator.isValidAuthorIdentifier("https://ror.org/03vek6s52", pattern));
assertTrue(validator.isValidAuthorIdentifier("03vek6s52", pattern));
assertFalse(validator.isValidAuthorIdentifier("junk", pattern));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,14 @@ public void testDataCiteXMLCreation() throws IOException {
assertEquals("https://orcid.org", XmlPath.from(xml).getString("resource.creators.creator[0].nameIdentifier.@schemeURI"));
assertEquals("Bob", XmlPath.from(xml).getString("resource.creators.creator[1].creatorName"));
assertEquals("Harvard University", XmlPath.from(xml).getString("resource.creators.creator[2].creatorName"));
// FIXME: nameIdentifierScheme, nameIdentifierScheme, and schemeURI should be populated
assertEquals("", XmlPath.from(xml).getString("resource.creators.creator[2].nameIdentifier"));
assertEquals(null, XmlPath.from(xml).getString("resource.creators.creator[2].nameIdentifier.@nameIdentifierScheme"));
assertEquals(null, XmlPath.from(xml).getString("resource.creators.creator[2].nameIdentifier.@schemeURI"));
assertEquals("https://ror.org/03vek6s52", XmlPath.from(xml).getString("resource.creators.creator[2].nameIdentifier"));
assertEquals("ROR", XmlPath.from(xml).getString("resource.creators.creator[2].nameIdentifier.@nameIdentifierScheme"));
assertEquals("https://ror.org", XmlPath.from(xml).getString("resource.creators.creator[2].nameIdentifier.@schemeURI"));
assertEquals("Qualitative Data Repository", XmlPath.from(xml).getString("resource.creators.creator[3].creatorName"));
// FIXME: the URL below is not right
assertEquals("https://ror.org/https://ror.org/014trz974", XmlPath.from(xml).getString("resource.creators.creator[3].nameIdentifier"));
assertEquals("ROR", XmlPath.from(xml).getString("resource.creators.creator[3].nameIdentifier.@nameIdentifierScheme"));
assertEquals("https://ror.org", XmlPath.from(xml).getString("resource.creators.creator[3].nameIdentifier.@schemeURI"));
// The nameIdentifier fields below are not populated because the full ROR URL was entered.
assertEquals("", XmlPath.from(xml).getString("resource.creators.creator[3].nameIdentifier"));
assertEquals(null, XmlPath.from(xml).getString("resource.creators.creator[3].nameIdentifier.@nameIdentifierScheme"));
assertEquals(null, XmlPath.from(xml).getString("resource.creators.creator[3].nameIdentifier.@schemeURI"));
assertEquals("Dataverse", XmlPath.from(xml).getString("resource.publisher"));

}
Expand Down

0 comments on commit 1fe95d9

Please sign in to comment.