From 31fc4c538304d3c252f446e3fb2e79f144e63980 Mon Sep 17 00:00:00 2001 From: Luca Giamminonni Date: Mon, 9 Oct 2023 16:39:06 +0200 Subject: [PATCH] [DSC-1274] Provider configuration --- .../authority/RorOrgUnitAuthority.java | 2 +- .../provider/impl/RorOrgUnitDataProvider.java | 4 +++- .../java/org/dspace/ror/ROROrgUnitDTO.java | 23 +++++++++++++++---- .../org/dspace/ror/service/RORApiService.java | 2 -- .../dspace/ror/service/RORApiServiceImpl.java | 12 ++++------ dspace/config/modules/ror.cfg | 3 ++- dspace/config/spring/api/cris-plugin.xml | 12 ++++++++++ 7 files changed, 41 insertions(+), 17 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/content/authority/RorOrgUnitAuthority.java b/dspace-api/src/main/java/org/dspace/content/authority/RorOrgUnitAuthority.java index cab712a3a025..09f7330b62fe 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/RorOrgUnitAuthority.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/RorOrgUnitAuthority.java @@ -55,7 +55,7 @@ private Choices getRORApiMatches(String text, int start, int limit) { private List getChoiceFromRORQueryResults(List orgUnits) { return orgUnits .stream() - .map(orgUnit -> new Choice(composeAuthorityValue(orgUnit.getId()), orgUnit.getName(), + .map(orgUnit -> new Choice(composeAuthorityValue(orgUnit.getIdentifier()), orgUnit.getName(), orgUnit.getName(), buildExtras(orgUnit))) .collect(Collectors.toList()); } diff --git a/dspace-api/src/main/java/org/dspace/external/provider/impl/RorOrgUnitDataProvider.java b/dspace-api/src/main/java/org/dspace/external/provider/impl/RorOrgUnitDataProvider.java index d37503b44bf3..76a38796d5f6 100644 --- a/dspace-api/src/main/java/org/dspace/external/provider/impl/RorOrgUnitDataProvider.java +++ b/dspace-api/src/main/java/org/dspace/external/provider/impl/RorOrgUnitDataProvider.java @@ -40,7 +40,9 @@ public List searchExternalDataObjects(String query, int star private ExternalDataObject convertToExternalDataObject(ROROrgUnitDTO orgUnit) { ExternalDataObject object = new ExternalDataObject(sourceIdentifier); - object.setId(orgUnit.getId()); + object.setId(orgUnit.getIdentifier()); + object.setValue(orgUnit.getName()); + object.setDisplayValue(orgUnit.getName()); object.setMetadata(rorApiService.getMetadataValues(orgUnit)); return object; } diff --git a/dspace-api/src/main/java/org/dspace/ror/ROROrgUnitDTO.java b/dspace-api/src/main/java/org/dspace/ror/ROROrgUnitDTO.java index ca390948a007..9eac4494fc59 100644 --- a/dspace-api/src/main/java/org/dspace/ror/ROROrgUnitDTO.java +++ b/dspace-api/src/main/java/org/dspace/ror/ROROrgUnitDTO.java @@ -9,10 +9,14 @@ package org.dspace.ror; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.StringUtils; @JsonIgnoreProperties(ignoreUnknown = true) public class ROROrgUnitDTO { - private String id; + + @JsonProperty("id") + private String url; private String name; @@ -24,12 +28,21 @@ public class ROROrgUnitDTO { private String[] types; - public String getId() { - return id; + public String getIdentifier() { + if (StringUtils.isBlank(url)) { + return null; + } + + String[] splittedUrl = url.split("/"); + return splittedUrl[splittedUrl.length - 1]; + } + + public String getUrl() { + return url; } - public void setId(String id) { - this.id = id; + public void setUrl(String url) { + this.url = url; } public String getName() { diff --git a/dspace-api/src/main/java/org/dspace/ror/service/RORApiService.java b/dspace-api/src/main/java/org/dspace/ror/service/RORApiService.java index a027b007c762..fffaa14ee777 100644 --- a/dspace-api/src/main/java/org/dspace/ror/service/RORApiService.java +++ b/dspace-api/src/main/java/org/dspace/ror/service/RORApiService.java @@ -23,8 +23,6 @@ public interface RORApiService { public List getMetadataValues(String rorId); - public String getRORIdMetadataField(); - public List getMetadataFields(); } diff --git a/dspace-api/src/main/java/org/dspace/ror/service/RORApiServiceImpl.java b/dspace-api/src/main/java/org/dspace/ror/service/RORApiServiceImpl.java index a4e5faa1981b..cff214fe3f11 100644 --- a/dspace-api/src/main/java/org/dspace/ror/service/RORApiServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/ror/service/RORApiServiceImpl.java @@ -72,17 +72,15 @@ public List getMetadataValues(ROROrgUnitDTO orgUnit) { .ifPresent(metadataValues::add); getPersonMetadataField("url") - .flatMap(field -> getMetadataValue(orgUnit.getId(), field)) + .flatMap(field -> getMetadataValue(orgUnit.getUrl(), field)) .ifPresent(metadataValues::add); - return metadataValues; + getPersonMetadataField("identifier") + .flatMap(field -> getMetadataValue(orgUnit.getIdentifier(), field)) + .ifPresent(metadataValues::add); - } + return metadataValues; - @Override - public String getRORIdMetadataField() { - return getPersonMetadataField("sciper") - .orElseThrow(() -> new IllegalStateException("No Sciper metadata field configured")); } private List getInactiveMetadataField() { diff --git a/dspace/config/modules/ror.cfg b/dspace/config/modules/ror.cfg index 5f13ad65730b..f92b96c35d21 100644 --- a/dspace/config/modules/ror.cfg +++ b/dspace/config/modules/ror.cfg @@ -2,4 +2,5 @@ ror.orgunit-import.api-url = https://api.ror.org/organizations ror.authority.prefix = will be referenced::ROR-ID:: ror.orgunit-import.api.metadata-field.name = dc.title ror.orgunit-import.api.metadata-field.acronym = oairecerif.acronym -ror.orgunit-import.api.metadata-field.url = oairecerif.identifier.url \ No newline at end of file +ror.orgunit-import.api.metadata-field.url = oairecerif.identifier.url +ror.orgunit-import.api.metadata-field.identifier = organization.identifier.ror \ No newline at end of file diff --git a/dspace/config/spring/api/cris-plugin.xml b/dspace/config/spring/api/cris-plugin.xml index 0a7f19113beb..46bdfdd4562a 100644 --- a/dspace/config/spring/api/cris-plugin.xml +++ b/dspace/config/spring/api/cris-plugin.xml @@ -17,6 +17,7 @@ + @@ -117,6 +118,11 @@ + + + + + @@ -133,6 +139,7 @@ + @@ -184,6 +191,11 @@ + +