Skip to content

Commit

Permalink
[DSC-1274] Provider configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaGiamminonni committed Oct 9, 2023
1 parent 419e8a9 commit 31fc4c5
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private Choices getRORApiMatches(String text, int start, int limit) {
private List<Choice> getChoiceFromRORQueryResults(List<ROROrgUnitDTO> 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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public List<ExternalDataObject> 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;
}
Expand Down
23 changes: 18 additions & 5 deletions dspace-api/src/main/java/org/dspace/ror/ROROrgUnitDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public interface RORApiService {

public List<MetadataValueDTO> getMetadataValues(String rorId);

public String getRORIdMetadataField();

public List<String> getMetadataFields();

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,15 @@ public List<MetadataValueDTO> 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<MetadataValueDTO> getInactiveMetadataField() {
Expand Down
3 changes: 2 additions & 1 deletion dspace/config/modules/ror.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
ror.orgunit-import.api.metadata-field.url = oairecerif.identifier.url
ror.orgunit-import.api.metadata-field.identifier = organization.identifier.ror
12 changes: 12 additions & 0 deletions dspace/config/spring/api/cris-plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<entry key="ORCID" value-ref="orcidImportFiller" />
<entry key="ISSN" value-ref="sherpaImportFiller" />
<entry key="OPENAIRE-PROJECT-ID" value-ref="openaireProjectImportFiller" />
<entry key="ROR-ID" value-ref="rorOrgUnitImportFiller" />
</map>
</property>
</bean>
Expand Down Expand Up @@ -117,6 +118,11 @@
<constructor-arg name="externalDataProvider" ref="openaireLiveImportDataProvider"/>
<constructor-arg name="authorityIdentifier" value="OPENAIRE-PROJECT-ID"/>
</bean>

<bean class="org.dspace.authority.filler.ExternalDataProviderImportFiller" id="rorOrgUnitImportFiller" >
<constructor-arg name="externalDataProvider" ref="rorDataProvider"/>
<constructor-arg name="authorityIdentifier" value="ROR-ID"/>
</bean>

<bean class="org.dspace.authority.service.ItemSearcherMapper" name="org.dspace.authority.service.ItemSearcherMapper">
<constructor-arg index="0">
Expand All @@ -133,6 +139,7 @@
<entry key="OPENAIRE-PROJECT-ID" value-ref="itemSearcherByOpenaireProjectId"/>
<entry key="LEGACY-ID" value-ref="itemSearcherByLegacyId"/>
<entry key="SCOPUS-AUTHOR-ID" value-ref="itemSearcherByScopusAuthorId"/>
<entry key="ROR-ID" value-ref="itemSearcherByRorId"></entry>
</map>
</constructor-arg>
<constructor-arg index="1">
Expand Down Expand Up @@ -184,6 +191,11 @@
<constructor-arg value="person.identifier.scopus-author-id"></constructor-arg>
<constructor-arg value="SCOPUS-AUTHOR-ID"></constructor-arg>
</bean>

<bean class="org.dspace.authority.service.impl.ItemSearcherByMetadata" name="itemSearcherByRorId">
<constructor-arg value="organization.identifier.ror"></constructor-arg>
<constructor-arg value="ROR-ID"></constructor-arg>
</bean>

<bean class="org.dspace.authority.service.impl.ItemSearchServiceImpl" name="org.dspace.authority.service.ItemSearchService"/>
<bean class="org.dspace.authority.service.impl.ItemReferenceResolverServiceImpl" name="org.dspace.authority.service.ItemReferenceResolverService"/>
Expand Down

0 comments on commit 31fc4c5

Please sign in to comment.