Skip to content

Commit

Permalink
Merge pull request #6619 from IQSS/6570-search-api
Browse files Browse the repository at this point in the history
remove parentheses from dataset contact affiliation #6570
  • Loading branch information
kcondon authored Feb 6, 2020
2 parents 7968653 + e3a25fa commit c4e6065
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/release-notes/6570-search-api-contact-affiliation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
As reported in https://github.com/IQSS/dataverse/issues/6570 the affiliation for dataset contacts has been wrapped in parentheses in the JSON output from the Search API. These parentheses have now been removed. This is a backward incompatible change but it is hoped that it won't cause any problems for integrations and API users.
16 changes: 13 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,16 @@ public String getDescriptionHtmlEscaped() {
return MarkupChecker.escapeHtml(getDescription());
}

public List<String[]> getDatasetContacts(){
public List<String[]> getDatasetContacts() {
boolean getDisplayValues = true;
return getDatasetContacts(getDisplayValues);
}

/**
* @param getDisplayValues Instead of the retrieving pristine value in the
* database, run the value through special formatting.
*/
public List<String[]> getDatasetContacts(boolean getDisplayValues) {
List <String[]> retList = new ArrayList<>();
for (DatasetField dsf : this.getDatasetFields()) {
Boolean addContributor = true;
Expand All @@ -767,10 +776,11 @@ public List<String[]> getDatasetContacts(){
if (subField.isEmptyForDisplay()) {
addContributor = false;
}
// There is no use case yet for getting the non-display value for contributorName.
contributorName = subField.getDisplayValue();
}
if (subField.getDatasetFieldType().getName().equals(DatasetFieldConstant.datasetContactAffiliation)) {
contributorAffiliation = subField.getDisplayValue();
contributorAffiliation = getDisplayValues ? subField.getDisplayValue() : subField.getValue();
}

}
Expand All @@ -783,7 +793,7 @@ public List<String[]> getDatasetContacts(){
}
return retList;
}

public List<String[]> getDatasetProducers(){
List <String[]> retList = new ArrayList<>();
for (DatasetField dsf : this.getDatasetFields()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, bool
if (!dv.getDatasetContacts().isEmpty()) {
JsonArrayBuilder contacts = Json.createArrayBuilder();
NullSafeJsonBuilder nullSafeJsonBuilderInner = jsonObjectBuilder();
for (String contact[] : dv.getDatasetContacts()) {
for (String contact[] : dv.getDatasetContacts(false)) {
nullSafeJsonBuilderInner.add("name", contact[0]);
nullSafeJsonBuilderInner.add("affiliation", contact[1]);
contacts.add(nullSafeJsonBuilderInner);
Expand Down

0 comments on commit c4e6065

Please sign in to comment.