Skip to content

Commit

Permalink
check for ROR in grantAgency field too
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Sep 12, 2024
1 parent bb7adee commit bde5147
Showing 1 changed file with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -623,29 +623,34 @@ private void writeEntityElements(XMLStreamWriter xmlw, String elementName, Strin
}

if (StringUtils.isNotBlank(affiliation)) {
boolean isROR=false;
String orgName = affiliation;
ExternalIdentifier externalIdentifier = ExternalIdentifier.ROR;
if (externalIdentifier.isValidIdentifier(affiliation)) {
isROR=true;
if(pidProvider instanceof DataCiteDOIProvider dcProvider) {
JsonObject jo = dcProvider.getExternalVocabularyValue(affiliation);
if(jo!=null) {
orgName = jo.getString("termName");
}
String orgName = getOrganizationFromRORField(affiliation, attributeMap);
XmlWriterUtil.writeFullElementWithAttributes(xmlw, "affiliation", attributeMap, StringEscapeUtils.escapeXml10(orgName));
}
xmlw.writeEndElement();
}

private String getOrganizationFromRORField(String nameOrRor, Map<String, String> attributeMap) {
boolean isROR=false;
String orgName = nameOrRor;
ExternalIdentifier externalIdentifier = ExternalIdentifier.ROR;
if (externalIdentifier.isValidIdentifier(nameOrRor)) {
isROR=true;
if(pidProvider instanceof DataCiteDOIProvider dcProvider) {
JsonObject jo = dcProvider.getExternalVocabularyValue(nameOrRor);
if(jo!=null) {
orgName = jo.getString("termName");
}
}

attributeMap.clear();
if (isROR) {
}

attributeMap.clear();
if (isROR) {

attributeMap.put("schemeURI", "https://ror.org");
attributeMap.put("affiliationIdentifierScheme", "ROR");
attributeMap.put("affiliationIdentifier", affiliation);
}
XmlWriterUtil.writeFullElementWithAttributes(xmlw, "affiliation", attributeMap, StringEscapeUtils.escapeXml10(orgName));
attributeMap.put("schemeURI", "https://ror.org");
attributeMap.put("affiliationIdentifierScheme", "ROR");
attributeMap.put("affiliationIdentifier", nameOrRor);
}
xmlw.writeEndElement();
return orgName;
}

/**
Expand Down Expand Up @@ -1493,8 +1498,10 @@ private void writeFundingReferences(XMLStreamWriter xmlw, DvObject dvObject) thr
}
if (!StringUtils.isBlank(funder)) {
fundingReferenceWritten = XmlWriterUtil.writeOpenTagIfNeeded(xmlw, "fundingReferences", fundingReferenceWritten);
Map<String, String> attributeMap = new HashMap<>();
funder = getOrganizationFromRORField(funder, attributeMap);
xmlw.writeStartElement("fundingReference"); // <fundingReference>
XmlWriterUtil.writeFullElement(xmlw, "funderName", StringEscapeUtils.escapeXml10(funder));
XmlWriterUtil.writeFullElementWithAttributes(xmlw, "funderName", attributeMap, StringEscapeUtils.escapeXml10(funder));
if (StringUtils.isNotBlank(awardNumber)) {
XmlWriterUtil.writeFullElement(xmlw, "awardNumber", StringEscapeUtils.escapeXml10(awardNumber));
}
Expand Down

0 comments on commit bde5147

Please sign in to comment.