Skip to content

Commit

Permalink
Merged in DSC-1271 (pull request DSpace#1146)
Browse files Browse the repository at this point in the history
[DSC-1271] orcid extras change
  • Loading branch information
steph-ieffam committed Oct 17, 2023
2 parents 5de1c43 + 29f9136 commit 5568834
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 16 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 Expand Up @@ -600,8 +600,8 @@ public void testWithAffiliationExtra() throws Exception {
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.entries", containsInAnyOrder(
orcidEntry("Author From Orcid 1", REFERENCE, "0000-1111-2222-3333"),
orcidEntryWithInstitution("Author From Orcid 2", REFERENCE, "0000-2222-3333-4444", "Org1, Org2"),
orcidEntryWithInstitution("Author From Orcid 3", REFERENCE, "0000-5555-6666-7777", "Organization"))))
orcidEntryWithAffiliation("Author From Orcid 2", REFERENCE, "0000-2222-3333-4444", "Org1, Org2"),
orcidEntryWithAffiliation("Author From Orcid 3", REFERENCE, "0000-5555-6666-7777", "Organization"))))
.andExpect(jsonPath("$.page.size", Matchers.is(20)))
.andExpect(jsonPath("$.page.totalPages", Matchers.is(1)))
.andExpect(jsonPath("$.page.totalElements", Matchers.is(3)));
Expand Down Expand Up @@ -679,11 +679,18 @@ private Matcher<? super Object> orcidEntry(String title, String authorityPrefix,
title, "vocabularyEntry", ORCID_INFO, orcid);
}

private Matcher<? super Object> orcidEntryWithInstitution(String title, String authorityPrefix,
String orcid, String institutions) {
private Matcher<? super Object> orcidEntryWithAffiliation(String title, String authorityPrefix,
String orcid, String affiliation) {
String authority = authorityPrefix + "ORCID::" + orcid;
return ItemAuthorityMatcher.matchItemAuthorityWithTwoMetadataInOtherInformations(authority, title,
title, "vocabularyEntry", ORCID_INFO, orcid, ORCID_INSTITUTION, institutions);
return ItemAuthorityMatcher.matchItemAuthorityWithTwoMetadataInOtherInformations(
authority, title, title, "vocabularyEntry",
Map.of(
"data-" + ORCID_INFO, orcid,
ORCID_INFO, orcid,
"data-oairecerif_author_affiliation", affiliation,
"oairecerif_author_affiliation", affiliation
)
);
}

private String id(Item item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public static Matcher<? super Object> matchItemAuthorityWithOtherInformations(St
hasJsonPath("$.display", is(display)),
hasJsonPath("$.value", is(value)),
hasJsonPath("$.type", is(type)),
hasJsonPath("$.otherInformation", aMapWithSize(1)),
hasJsonPath("$.otherInformation['" + otherInfMetadata + "']", is(metadataValue))
hasJsonPath("$.otherInformation", aMapWithSize(2)),
hasJsonPath("$.otherInformation['" + otherInfMetadata + "']", is(metadataValue)),
hasJsonPath("$.otherInformation['" + "data-" + otherInfMetadata + "']", is(metadataValue))
);
}

Expand Down Expand Up @@ -73,4 +74,18 @@ public static Matcher<? super Object> matchItemAuthorityWithTwoMetadataInOtherIn
)
);
}

public static Matcher<? super Object> matchItemAuthorityWithTwoMetadataInOtherInformations(String authority,
String display, String value, String type, Map<String, String> orcidAndAffiliation) {
return allOf(
hasJsonPath("$.authority", is(authority)),
hasJsonPath("$.display", is(display)),
hasJsonPath("$.value", is(value)),
hasJsonPath("$.type", is(type)),
hasJsonPath("$.otherInformation", aMapWithSize(4)),
allOf (
hasJsonPath("$.otherInformation", is(orcidAndAffiliation))
)
);
}
}
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 5568834

Please sign in to comment.