Skip to content

Commit

Permalink
Merge branch 'EMC-399-schema.org-deduplication' into 'develop'
Browse files Browse the repository at this point in the history
Make schema.org output group organisations for responsible parties

See merge request eip/catalogue!810
  • Loading branch information
rodscott committed Jan 31, 2025
2 parents a5857e7 + 127d8df commit fc1db3e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,23 @@ public List<OnlineResource> getInfoLinks() {
.collect(Collectors.toCollection(ArrayList::new));
}

@JsonIgnore
public List<ResponsibleParty> getAuthorPointOfContactWithRORs() {
val seenRORs = new HashSet<String>();
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
18 changes: 17 additions & 1 deletion templates/schema.org/macros.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{
"@context":"http://schema.org/",
"@graph": [
<@m.schemaDocument docType parts/>
<@schemaDocument docType parts/>
]
}
</#if>
Expand Down Expand Up @@ -83,6 +83,7 @@
<#if funding?has_content>,<@fundDetails/></#if>
<#if parts?has_content>,<@partDetails parts/></#if>
<#if downloads?has_content>,<@distributionDetails/></#if>
<#if authorPointOfContactWithRORs?has_content>,<@organisationRORs/></#if>
</#macro>

<#macro alternateTitlesList>
Expand Down Expand Up @@ -322,11 +323,15 @@
</#if>
<#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}"
</#if>
</#if>
}
</#if>
<#else>
Expand Down Expand Up @@ -405,3 +410,14 @@
],
</#if>
</#macro>

<#macro organisationRORs>
<#list authorPointOfContactWithRORs as contact>
{
"@id": "${contact.organisationIdentifier}",
"@type": "Organization",
"name": "${contact.organisationName}",
"identifier": "${contact.organisationIdentifier}"
}<#sep>,
</#list>
</#macro>

0 comments on commit fc1db3e

Please sign in to comment.