Skip to content

Commit

Permalink
[DSC-1271] orcid extras change
Browse files Browse the repository at this point in the history
  • Loading branch information
steph-ieffam committed Sep 28, 2023
1 parent d7ca5e1 commit 3bf54e0
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -131,11 +131,24 @@ private String composeAuthorityValue(String orcid) {

private Map<String, String> composeExtras(ExpandedResult result) {
Map<String, String> 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;
Expand Down Expand Up @@ -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);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
14 changes: 14 additions & 0 deletions dspace/config/modules/authority.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3bf54e0

Please sign in to comment.