diff --git a/service/src/main/java/gov/nasa/pds/api/registry/model/WyriwygBusinessObject.java b/service/src/main/java/gov/nasa/pds/api/registry/model/WyriwygBusinessObject.java index 08cdfd48..e64459bc 100644 --- a/service/src/main/java/gov/nasa/pds/api/registry/model/WyriwygBusinessObject.java +++ b/service/src/main/java/gov/nasa/pds/api/registry/model/WyriwygBusinessObject.java @@ -2,11 +2,15 @@ import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.TreeSet; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; import org.slf4j.Logger; @@ -111,7 +115,7 @@ public int setResponse(SearchHits hits, Summary summary, List fields) { WyriwygProductKeyValuePair kvp = new WyriwygProductKeyValuePair(); try { kvp.setKey(SearchUtil.openPropertyToJsonProperty(pair.getKey())); - kvp.setValue(String.valueOf(pair.getValue())); + kvp.setValue(getStringValueOf(pair.getValue())); product.addKeyValuePairsItem(kvp); } catch (UnsupportedSearchProperty e) { log.warn("openSearch property " + pair.getKey() + " is not supported, ignored"); @@ -125,4 +129,21 @@ public int setResponse(SearchHits hits, Summary summary, List fields) { this.products = products; return (int) (hits.getTotalHits().value); } + + private String getStringValueOf(Object o) { + String valueOf; + if (o instanceof Iterable) { + List stringRepresentations = new ArrayList<>(); + for (Object el : (Iterable) o ) { + stringRepresentations.add(String.valueOf(el)); + } + + String delimiter = "|"; + valueOf = String.join(delimiter, stringRepresentations); + } else { + valueOf = String.valueOf(o); + } + + return valueOf; + } }