Skip to content

Commit

Permalink
[CST-14906] Refactoring of code in order to work with relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattia Vianelli authored and atarix83 committed Sep 24, 2024
1 parent 34f136b commit 59e6418
Show file tree
Hide file tree
Showing 26 changed files with 736 additions and 1,350 deletions.
2 changes: 1 addition & 1 deletion dspace-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@
<dependency>
<groupId>org.orcid</groupId>
<artifactId>orcid-model</artifactId>
<version>3.0.2</version>
<version>3.0.7</version>
<exclusions>
<exclusion>
<groupId>javax.validation</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ private boolean doesNotContains(ExternalDataObject externalDataObject, Metadatum

private boolean hasRole(Contributor contributor, ContributorRole role) {
ContributorAttributes attributes = contributor.getContributorAttributes();
return attributes != null ? role.equals(attributes.getContributorRole()) : false;
return attributes != null ? role.value().equals(attributes.getContributorRole()) : false;
}

private Optional<String> getContributorName(Contributor contributor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.dspace.content.integration.crosswalks.CSLItemDataCrosswalk;
import org.dspace.util.SimpleMapConverter;
import org.orcid.jaxb.model.common.CitationType;
import org.orcid.jaxb.model.common.ContributorRole;
Expand Down Expand Up @@ -87,18 +86,6 @@ public class OrcidPatentWorkFieldMapping {
*/
private SimpleMapConverter languageConverter;

private Map<String, CSLItemDataCrosswalk> citationCrosswalks;

private String fundingField;

private String fundingExternalIdType;

private String fundingExternalId;

private String fundingEntityExternalId;

private String fundingUrlField;

public String convertType(String type) {
return typeConverter != null ? typeConverter.getValue(type) : type;
}
Expand Down Expand Up @@ -187,54 +174,6 @@ public void setSubTitleField(String subTitleField) {
this.subTitleField = subTitleField;
}

public Map<String, CSLItemDataCrosswalk> getCitationCrosswalks() {
return citationCrosswalks;
}

public void setCitationCrosswalks(Map<String, CSLItemDataCrosswalk> citationCrosswalks) {
this.citationCrosswalks = citationCrosswalks;
}

public String getFundingField() {
return fundingField;
}

public void setFundingField(String fundingField) {
this.fundingField = fundingField;
}

public String getFundingExternalIdType() {
return fundingExternalIdType;
}

public void setFundingExternalIdType(String fundingExternalIdType) {
this.fundingExternalIdType = fundingExternalIdType;
}

public String getFundingExternalId() {
return fundingExternalId;
}

public void setFundingExternalId(String fundingExternalId) {
this.fundingExternalId = fundingExternalId;
}

public String getFundingEntityExternalId() {
return fundingEntityExternalId;
}

public void setFundingEntityExternalId(String fundingEntityExternalId) {
this.fundingEntityExternalId = fundingEntityExternalId;
}

public String getFundingUrlField() {
return fundingUrlField;
}

public void setFundingUrlField(String fundingUrlField) {
this.fundingUrlField = fundingUrlField;
}

public CitationType getCitationType() {
return citationType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.dspace.content.integration.crosswalks.CSLItemDataCrosswalk;
import org.dspace.util.SimpleMapConverter;
import org.orcid.jaxb.model.common.CitationType;
import org.orcid.jaxb.model.common.ContributorRole;
Expand Down Expand Up @@ -87,18 +85,6 @@ public class OrcidProductWorkFieldMapping {
*/
private SimpleMapConverter languageConverter;

private Map<String, CSLItemDataCrosswalk> citationCrosswalks;

private String fundingField;

private String fundingExternalIdType;

private String fundingExternalId;

private String fundingEntityExternalId;

private String fundingUrlField;

public String convertType(String type) {
return typeConverter != null ? typeConverter.getValue(type) : type;
}
Expand Down Expand Up @@ -187,75 +173,6 @@ public void setSubTitleField(String subTitleField) {
this.subTitleField = subTitleField;
}

public Map<String, CSLItemDataCrosswalk> getCitationCrosswalks() {
return citationCrosswalks;
}

public void setCitationCrosswalks(Map<String, CSLItemDataCrosswalk> citationCrosswalks) {
this.citationCrosswalks = citationCrosswalks;
}

public String getFundingField() {
return fundingField;
}

public void setFundingField(String fundingField) {
this.fundingField = fundingField;
}

public String getFundingExternalIdType() {
return fundingExternalIdType;
}

public void setFundingExternalIdType(String fundingExternalIdType) {
this.fundingExternalIdType = fundingExternalIdType;
}

public String getFundingExternalId() {
return fundingExternalId;
}

public void setFundingExternalId(String fundingExternalId) {
this.fundingExternalId = fundingExternalId;
}

public String getFundingEntityExternalId() {
return fundingEntityExternalId;
}

public void setFundingEntityExternalId(String fundingEntityExternalId) {
this.fundingEntityExternalId = fundingEntityExternalId;
}

public String getFundingUrlField() {
return fundingUrlField;
}

public void setFundingUrlField(String fundingUrlField) {
this.fundingUrlField = fundingUrlField;
}

public CitationType getCitationType() {
return citationType;
}

public void setCitationType(String citationType) {
this.citationType = parseCitationType(citationType);
}

private CitationType parseCitationType(String citationType) {

if (StringUtils.isBlank(citationType)) {
return null;
}

try {
return CitationType.fromValue(citationType);
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("The citation type " + citationType + " is invalid, "
+ "allowed values are " + getAllowedCitationTypes(), ex);
}
}

private Map<String, ContributorRole> parseContributors(String contributors) {
Map<String, String> contributorsMap = parseConfigurations(contributors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public Optional<Country> createCountry(Context context, MetadataValue metadataVa

private ContributorAttributes getContributorAttributes(MetadataValue metadataValue, ContributorRole role) {
ContributorAttributes attributes = new ContributorAttributes();
attributes.setContributorRole(role != null ? role : null);
attributes.setContributorRole(role != null ? role.value() : null);
attributes.setContributorSequence(metadataValue.getPlace() == 0 ? FIRST : ADDITIONAL);
return attributes;
}
Expand All @@ -191,7 +191,7 @@ private OrganizationAddress createOrganizationAddress(Item organizationItem) {
private FundingContributorAttributes getFundingContributorAttributes(MetadataValue metadataValue,
FundingContributorRole role) {
FundingContributorAttributes attributes = new FundingContributorAttributes();
attributes.setContributorRole(role != null ? role : null);
attributes.setContributorRole(role != null ? role.value() : null);
return attributes;
}

Expand Down
Loading

0 comments on commit 59e6418

Please sign in to comment.