Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow optional Croissant exporter to replace JSON-LD <head> content #10382

Merged
merged 5 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -5809,6 +5809,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
Loading