Skip to content

Commit b6d9eec

Browse files
authored
Merge pull request #11338 from GlobalDataverseCommunityConsortium/DANS-CSL
Clean up JSON CSL elements
2 parents d9d3357 + 87e8510 commit b6d9eec

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/main/java/edu/harvard/iq/dataverse/DataCitation.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -745,15 +745,16 @@ public JsonObject getCSLJsonFormat() {
745745
} else {
746746
itemBuilder.type(CSLType.DATASET);
747747
}
748-
itemBuilder.title(title).author((CSLName[]) cslAuthors.toArray(new CSLName[0])).issued(Integer.parseInt(year));
748+
itemBuilder.title(formatString(title,true)).author((CSLName[]) cslAuthors.toArray(new CSLName[0])).issued(Integer.parseInt(year));
749749
if (seriesTitles != null) {
750-
itemBuilder.containerTitle(seriesTitles.get(0));
750+
itemBuilder.containerTitle(formatString(seriesTitles.get(0), true));
751751
}
752752
itemBuilder.version(version).DOI(persistentId.asString());
753753
if (keywords != null) {
754-
itemBuilder.categories(keywords.toArray(new String[0]));
754+
itemBuilder
755+
.categories(keywords.stream().map(keyword -> formatString(keyword, true)).toArray(String[]::new));
755756
}
756-
itemBuilder.abstrct(description).publisher(publisher)
757+
itemBuilder.abstrct(formatString(description, true)).publisher(formatString(publisher, true))
757758
.URL(SystemConfig.getDataverseSiteUrlStatic() + "/citation?persistentId=" + persistentId.asString());
758759
JsonBuilder b = (new StringJsonBuilderFactory()).createJsonBuilder();
759760
return JsonUtil.getJsonObject((String) itemBuilder.build().toJson(b));
@@ -868,15 +869,15 @@ private void getAuthorsAndProducersFrom(DatasetVersion dsv) {
868869
boolean isOrg = "ROR".equals(author.getIdType());
869870
JsonObject authorJson = PersonOrOrgUtil.getPersonOrOrganization(an, false, !isOrg);
870871
if (!authorJson.getBoolean("isPerson")) {
871-
cslAuthors.add(new CSLNameBuilder().literal(authorJson.getString("fullName")).isInstitution(true).build());
872+
cslAuthors.add(new CSLNameBuilder().literal(formatString(authorJson.getString("fullName"), true)).isInstitution(true).build());
872873
} else {
873874
if (authorJson.containsKey("givenName") && authorJson.containsKey("familyName")) {
874-
String givenName = authorJson.getString("givenName");
875-
String familyName = authorJson.getString("familyName");
875+
String givenName = formatString(authorJson.getString("givenName"),true);
876+
String familyName = formatString(authorJson.getString("familyName"), true);
876877
cslAuthors.add(new CSLNameBuilder().given(givenName).family(familyName).isInstitution(false).build());
877878
} else {
878879
cslAuthors.add(
879-
new CSLNameBuilder().literal(authorJson.getString("fullName")).isInstitution(false).build());
880+
new CSLNameBuilder().literal(formatString(authorJson.getString("fullName"), true)).isInstitution(false).build());
880881
}
881882
}
882883
}

0 commit comments

Comments
 (0)