Skip to content

Commit

Permalink
Merge pull request #4331 from IQSS/4330-no-affiliation
Browse files Browse the repository at this point in the history
add null check for datasetAuthor.getAffiliation() #4330
  • Loading branch information
kcondon committed Nov 30, 2017
2 parents 0f36aa0 + fff836c commit 4648b6a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Expand Up @@ -1236,13 +1236,18 @@ public String getJsonLd() {
for (DatasetAuthor datasetAuthor : this.getDatasetAuthors()) {
JsonObjectBuilder author = Json.createObjectBuilder();
String name = datasetAuthor.getName().getValue();
String affiliation = datasetAuthor.getAffiliation().getValue();
DatasetField authorAffiliation = datasetAuthor.getAffiliation();
String affiliation = null;
if (authorAffiliation != null) {
affiliation = datasetAuthor.getAffiliation().getValue();
}
// We are aware of "givenName" and "familyName" but instead of a person it might be an organization such as "Gallup Organization".
//author.add("@type", "Person");
author.add("name", name);
// We are aware that the following error is thrown by https://search.google.com/structured-data/testing-tool
// "The property affiliation is not recognized by Google for an object of type Thing."
// Someone at Google has said this is ok.
// This logic could be moved into the `if (authorAffiliation != null)` block above.
if (!StringUtil.isEmpty(affiliation)) {
author.add("affiliation", affiliation);
}
Expand Down

0 comments on commit 4648b6a

Please sign in to comment.