Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tsande16 committed Jan 12, 2024
1 parent d570c9b commit b546743
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package org.eclipse.pass.deposit.config.repository;

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -31,9 +28,6 @@ public class RepositoryDepositConfig {
@JsonProperty("mapping")
private StatusMapping statusMapping;

@JsonProperty("funder-mapping")
private Map<String, String> funderMapping = new HashMap<>();

public DepositProcessing getDepositProcessing() {
return depositProcessing;
}
Expand All @@ -50,14 +44,6 @@ public void setStatusMapping(StatusMapping statusMapping) {
this.statusMapping = statusMapping;
}

public Map<String, String> getFunderMapping() {
return funderMapping;
}

public void setFunderMapping(Map<String, String> funderMapping) {
this.funderMapping = funderMapping;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down Expand Up @@ -86,6 +72,6 @@ public int hashCode() {
@Override
public String toString() {
return "RepositoryDepositConfig{" + "depositProcessing=" + depositProcessing +
", statusMapping=" + statusMapping + " funderMapping=" + funderMapping + "}";
", statusMapping=" + statusMapping + "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.time.LocalDate;
import java.time.Period;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -53,7 +52,7 @@ public class NihmsMetadataSerializer implements StreamingSerializer {
private static final Logger LOG = LoggerFactory.getLogger(NihmsMetadataSerializer.class);

private DepositMetadata metadata;
private Map<String, String> funderMapping = new HashMap<>();
private Map<String, String> funderMapping;

public NihmsMetadataSerializer(DepositMetadata metadata, Map<String, Object> packageOptions) {
this.metadata = metadata;
Expand Down Expand Up @@ -256,7 +255,7 @@ private void addGrants(Document doc, Element root) {
.toList();

//Only create the top level grant element if at least one of the keys is associated with nihms
if (funderLocalKeyExists(funderKeys)) {
if (funderKeys.stream().anyMatch(funderMapping::containsKey)) {

Element grantsElement = doc.createElement("grants");
root.appendChild(grantsElement);
Expand All @@ -267,13 +266,13 @@ private void addGrants(Document doc, Element root) {
Element grantElement = doc.createElement("grant");
grantsElement.appendChild(grantElement);

//use the nihms abbreviations for funders, the accepted list is in the nihms DTD
grantElement.setAttribute("funder", funderMapping.get(grant.getFunderLocalKey()));

if (StringUtils.isNotBlank(grant.getGrantId())) {
grantElement.setAttribute("id", grant.getGrantId());
}

//use the nihms abbreviations for funders, the accepted list is in the nihms DTD
grantElement.setAttribute("funder", funderMapping.get(grant.getFunderLocalKey()));

DepositMetadata.Person pi = grant.getGrantPi();
if (pi != null) {
Element piElement = doc.createElement("PI");
Expand All @@ -295,18 +294,4 @@ private void addGrants(Document doc, Element root) {
}
}
}

/**
* Used to determine if one of the grants localKeys exists in the list of accepted nihms funders
*
* @return True if at least one nihms funderKey exists in the metadata grant list
*/
private boolean funderLocalKeyExists(List<String> metaDataGrantFunderKeys) {
for (String key : metaDataGrantFunderKeys) {
if (funderMapping.containsKey(key)) {
return true;
}
}
return false;
}
}

0 comments on commit b546743

Please sign in to comment.