Skip to content

Commit

Permalink
Merge pull request #10382 from IQSS/le-croissant-exportateur
Browse files Browse the repository at this point in the history
Allow optional Croissant exporter to replace JSON-LD <head> content
  • Loading branch information
pdurbin authored Mar 21, 2024
2 parents fb76116 + 7023fbf commit 9e0587f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/release-notes/10382-optional-croissant-exporter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When a Dataverse installation is configured to use a metadata exporter for the [Croissant](https://github.com/mlcommons/croissant) format, the content of the JSON-LD in the `<head>` of dataset landing pages will be replaced with that format. However, both JSON-LD and Croissant will still be available for download from the dataset page and API.
1 change: 1 addition & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
DATAVERSE_AUTH_OIDC_CLIENT_ID: test
DATAVERSE_AUTH_OIDC_CLIENT_SECRET: 94XHrfNRwXsjqTqApRrwWmhDLDHpIYV8
DATAVERSE_AUTH_OIDC_AUTH_SERVER_URL: http://keycloak.mydomain.com:8090/realms/test
DATAVERSE_SPI_EXPORTERS_DIRECTORY: "/dv/exporters"
# These two oai settings are here to get HarvestingServerIT to pass
dataverse_oai_server_maxidentifiers: "2"
dataverse_oai_server_maxrecords: "2"
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5816,6 +5816,19 @@ public boolean isThisLatestReleasedVersion() {

}

public String getCroissant() {
if (isThisLatestReleasedVersion()) {
final String CROISSANT_SCHEMA_NAME = "croissant";
ExportService instance = ExportService.getInstance();
String croissant = instance.getExportAsString(dataset, CROISSANT_SCHEMA_NAME);
if (croissant != null && !croissant.isEmpty()) {
logger.fine("Returning cached CROISSANT.");
return croissant;
}
}
return null;
}

public String getJsonLd() {
if (isThisLatestReleasedVersion()) {
ExportService instance = ExportService.getInstance();
Expand Down
9 changes: 8 additions & 1 deletion src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@
<ui:define name="jsonld_header">
<ui:fragment rendered="#{!DatasetPage.anonymizedAccess}">
<script type="application/ld+json">
<h:outputText value="#{DatasetPage.jsonLd}"/>
<c:choose>
<c:when test="#{empty DatasetPage.croissant}">
<h:outputText value="#{DatasetPage.jsonLd}"/>
</c:when>
<c:otherwise>
<h:outputText value="#{DatasetPage.croissant}"/>
</c:otherwise>
</c:choose>
</script>
</ui:fragment>
</ui:define>
Expand Down

0 comments on commit 9e0587f

Please sign in to comment.