From 3bf54e08180c3c39770714bd52e2d3fa310841b9 Mon Sep 17 00:00:00 2001 From: Stefano Maffei Date: Thu, 28 Sep 2023 18:03:46 +0200 Subject: [PATCH] [DSC-1271] orcid extras change --- .../content/authority/OrcidAuthority.java | 62 +++++++++++++++++-- .../org/dspace/app/rest/OrcidAuthorityIT.java | 4 +- dspace/config/modules/authority.cfg | 14 +++++ 3 files changed, 72 insertions(+), 8 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/content/authority/OrcidAuthority.java b/dspace-api/src/main/java/org/dspace/content/authority/OrcidAuthority.java index 4dfe09cdec6..8978c1f90fc 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/OrcidAuthority.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/OrcidAuthority.java @@ -43,9 +43,9 @@ public class OrcidAuthority extends ItemAuthority { private static final Logger LOGGER = LoggerFactory.getLogger(OrcidAuthority.class); - public static final String ORCID_EXTRA = "data-person_identifier_orcid"; + public static final String DEFAULT_ORCID_KEY = "person_identifier_orcid"; - public static final String INSTITUTION_EXTRA = "institution-affiliation-name"; + public static final String DEFAULT_INSTITUTION_KEY = "institution-affiliation-name"; private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService(); @@ -131,11 +131,24 @@ private String composeAuthorityValue(String orcid) { private Map composeExtras(ExpandedResult result) { Map extras = new HashMap<>(); - extras.put(ORCID_EXTRA, result.getOrcidId()); - + String orcidIdKey = getOrcidIdKey(); + String orcidId = result.getOrcidId(); + if (StringUtils.isNotBlank(orcidId)) { + if (useOrcidIDAsData()) { + extras.put("data-" + orcidIdKey, orcidId); + } + if (useOrcidIDForDisplaying()) { + extras.put(orcidIdKey, orcidId); + } + } + String institutionKey = getInstitutionKey(); String[] institutionNames = result.getInstitutionNames(); - if (ArrayUtils.isNotEmpty(institutionNames)) { - extras.put(INSTITUTION_EXTRA, String.join(", ", institutionNames)); + + if (ArrayUtils.isNotEmpty(institutionNames) && useInstitutionAsData()) { + extras.put("data-" + institutionKey, String.join(", ", institutionNames)); + } + if (ArrayUtils.isNotEmpty(institutionNames) && useInstitutionForDisplaying()) { + extras.put(institutionKey, String.join(", ", institutionNames)); } return extras; @@ -165,4 +178,41 @@ public static void setAccessToken(String accessToken) { OrcidAuthority.accessToken = accessToken; } + public String getOrcidIdKey() { + return configurationService.getProperty("cris.OrcidAuthority." + + getPluginInstanceName() + ".orcid-id.key", + DEFAULT_ORCID_KEY); + } + + public String getInstitutionKey() { + return configurationService.getProperty("cris.OrcidAuthority." + + getPluginInstanceName() + ".institution.key", + DEFAULT_INSTITUTION_KEY); + } + + public boolean useInstitutionAsData() { + return configurationService + .getBooleanProperty("cris.OrcidAuthority." + + getPluginInstanceName() + ".institution.as-data", true); + } + + public boolean useInstitutionForDisplaying() { + return configurationService + .getBooleanProperty("cris.OrcidAuthority." + + getPluginInstanceName() + ".institution.display", true); + } + + public boolean useOrcidIDAsData() { + return configurationService + .getBooleanProperty("cris.OrcidAuthority." + + getPluginInstanceName() + ".orcid-id.as-data", true); + } + + public boolean useOrcidIDForDisplaying() { + return configurationService + .getBooleanProperty("cris.OrcidAuthority." + + getPluginInstanceName() + ".orcid-id.display", true); + + } + } diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/OrcidAuthorityIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/OrcidAuthorityIT.java index 2eb9cae64ae..ab18851e798 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/OrcidAuthorityIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/OrcidAuthorityIT.java @@ -56,8 +56,8 @@ */ public class OrcidAuthorityIT extends AbstractControllerIntegrationTest { - private static final String ORCID_INFO = OrcidAuthority.ORCID_EXTRA; - private static final String ORCID_INSTITUTION = OrcidAuthority.INSTITUTION_EXTRA; + private static final String ORCID_INFO = OrcidAuthority.DEFAULT_ORCID_KEY; + private static final String ORCID_INSTITUTION = OrcidAuthority.DEFAULT_INSTITUTION_KEY; private static final String READ_PUBLIC_TOKEN = "062d9f30-7e11-47ef-bd95-eaa2f2452565"; diff --git a/dspace/config/modules/authority.cfg b/dspace/config/modules/authority.cfg index 790489d15d5..0b78af0d453 100644 --- a/dspace/config/modules/authority.cfg +++ b/dspace/config/modules/authority.cfg @@ -112,6 +112,20 @@ cris.ItemAuthority.FundingAuthority.entityType = Funding cris.ItemAuthority.PublicationAuthority.entityType = Publication cris.ItemAuthority.EquipmentAuthority.entityType = Equipment +## OrcidAuthority Extras configuration +# + +cris.OrcidAuthority.EditorAuthority.institution.key = oairecerif_editor_affiliation +cris.OrcidAuthority.AuthorAuthority.institution.key = oairecerif_author_affiliation + +#cris.OrcidAuthority.AuthorAuthority.institution.display = true +#cris.OrcidAuthority.AuthorAuthority.institution.as-data = true +# +#cris.OrcidAuthority.AuthorAuthority.orcid-id.key = person_identifier_orcid +#cris.OrcidAuthority.AuthorAuthority.orcid-id.display = true +#cris.OrcidAuthority.AuthorAuthority.orcid-id.as-data = true + + cris.SherpaAuthority.entityType = Journal cris.SherpaAuthority.local-item-choices-enabled = true