From c28a70d8290817d185a552d01e4c90e6e81350ca Mon Sep 17 00:00:00 2001 From: Josh Holland Date: Tue, 14 Jan 2025 16:56:22 +0000 Subject: [PATCH 1/3] ResponsibleParty: fix up regular expressions --- .../uk/ac/ceh/gateway/catalogue/model/ResponsibleParty.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/src/main/java/uk/ac/ceh/gateway/catalogue/model/ResponsibleParty.java b/java/src/main/java/uk/ac/ceh/gateway/catalogue/model/ResponsibleParty.java index 904106e39..fddcee06f 100644 --- a/java/src/main/java/uk/ac/ceh/gateway/catalogue/model/ResponsibleParty.java +++ b/java/src/main/java/uk/ac/ceh/gateway/catalogue/model/ResponsibleParty.java @@ -40,17 +40,17 @@ private ResponsibleParty( @JsonIgnore public boolean isOrcid() { - return nameIdentifier.matches("^http(|s)://orcid.org/\\d{4}-\\d{4}-\\d{4}-\\d{3}(X|\\d)$"); + return nameIdentifier.matches("^https?://orcid\\.org/\\d{4}-\\d{4}-\\d{4}-\\d{3}(X|\\d)$"); } @JsonIgnore public boolean isIsni() { - return nameIdentifier.matches("^https://isni.org/isni/\\d{15}(X|\\d)$"); + return nameIdentifier.matches("^https://isni\\.org/isni/\\d{15}(X|\\d)$"); } @JsonIgnore public boolean isRor() { - return organisationIdentifier.matches("^https://ror.org/\\w{8,10}$"); + return organisationIdentifier.matches("^https://ror\\.org/\\w{8,10}$"); } public String getRoleDisplayName() { From 9e7d65b942370845b57bfa2a72871d7d4cae9ffd Mon Sep 17 00:00:00 2001 From: Josh Holland Date: Tue, 14 Jan 2025 17:02:28 +0000 Subject: [PATCH 2/3] Make schema.org output group organisations for responsible parties The authors and points of contact attached to a record might have an organisation they are affiliated with referenced. If that organisation also has an ROR identifier, there's no need to repeat its definition for each author in the schema.org output, just to ensure it's included at the end. EMC-399 --- .../catalogue/gemini/GeminiDocument.java | 17 +++++++++++++++++ templates/schema.org/macros.ftl | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/java/src/main/java/uk/ac/ceh/gateway/catalogue/gemini/GeminiDocument.java b/java/src/main/java/uk/ac/ceh/gateway/catalogue/gemini/GeminiDocument.java index b70002aee..dbd438b22 100644 --- a/java/src/main/java/uk/ac/ceh/gateway/catalogue/gemini/GeminiDocument.java +++ b/java/src/main/java/uk/ac/ceh/gateway/catalogue/gemini/GeminiDocument.java @@ -337,6 +337,23 @@ public List getInfoLinks() { .collect(Collectors.toCollection(ArrayList::new)); } + @JsonIgnore + public List getAuthorPointOfContactWithRORs() { + val seenRORs = new HashSet(); + return getResponsibleParties() + .stream() + .filter(party -> { + val role = party.getRole(); + val authorOrPOC = role.equalsIgnoreCase("author") || role.equalsIgnoreCase("pointOfContact"); + if (!authorOrPOC || !party.isRor()) return false; + val ror = party.getOrganisationIdentifier(); + if (seenRORs.contains(ror)) return false; + seenRORs.add(ror); + return true; + }) + .toList(); + } + private static @NonNull String convertEmail(@NonNull String email) { return email.endsWith("@ceh.ac.uk") ? "enquiries@ceh.ac.uk" : email; } diff --git a/templates/schema.org/macros.ftl b/templates/schema.org/macros.ftl index 0b98cb8a9..6f2e157f3 100644 --- a/templates/schema.org/macros.ftl +++ b/templates/schema.org/macros.ftl @@ -83,6 +83,7 @@ <#if funding?has_content>,<@fundDetails/> <#if parts?has_content>,<@partDetails parts/> <#if downloads?has_content>,<@distributionDetails/> + <#if authorPointOfContactWithRORs?has_content>,<@organisationRORs/> <#macro alternateTitlesList> @@ -322,11 +323,15 @@ <#if contact.organisationName?has_content> ,"affiliation":{ + <#if contact.organisationIdentifier?matches("^https://ror\\.org/\\w{8,10}$")> + "@id": "${contact.organisationIdentifier}" + <#else> "@type":"Organization", "name":"${contact.organisationName}" <#if contact.organisationIdentifier?has_content> ,"identifier":"${contact.organisationIdentifier}" + } <#else> @@ -405,3 +410,14 @@ ], + +<#macro organisationRORs> + <#list authorPointOfContactWithRORs as contact> + { + "@id": "${contact.organisationIdentifier}", + "@type": "Organization", + "name": "${contact.organisationName}", + "identifier": "${contact.organisationIdentifier}" + }<#sep>, + + From 127d8df14505d8b73f2f2d2df5699db9e75dd43b Mon Sep 17 00:00:00 2001 From: Rod Scott Date: Fri, 31 Jan 2025 15:18:13 +0000 Subject: [PATCH 3/3] Remove prefix from macro call EMC-399 --- templates/schema.org/macros.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/schema.org/macros.ftl b/templates/schema.org/macros.ftl index 6f2e157f3..e969a8d2b 100644 --- a/templates/schema.org/macros.ftl +++ b/templates/schema.org/macros.ftl @@ -22,7 +22,7 @@ { "@context":"http://schema.org/", "@graph": [ - <@m.schemaDocument docType parts/> + <@schemaDocument docType parts/> ] }