diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java index 917d85542..6fe3c7741 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java @@ -17,6 +17,7 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; import java.util.Collection; import java.util.LinkedList; import java.util.List; @@ -201,13 +202,10 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin @Override public void fromJsonObject(Map properties) { try { - JSONArray jsonArray = new JSONArray(properties.get(this.id).toString()); - List stringList = new LinkedList<>(); - for (int i = 0; i < jsonArray.length(); i++) { - stringList.add(jsonArray.getJSONObject(i).toString()); - } + ObjectMapper mapper = new ObjectMapper(); + List stringList = mapper.readValue(properties.get(this.id).toString(), LinkedList.class); this.value = stringList; - } catch (JSONException | NullPointerException e) { + } catch (JSONException | NullPointerException | IOException e) { this.value = (String) properties.get(this.id); } this.multiplicityItems = new LinkedList<>(); @@ -231,7 +229,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin @Override public void toMap(Map fieldValues) { if (this.value != null) { - if (this.viewStyle != null && this.viewStyle.getRenderStyle().equals("datasetIdentifier")) { + if ((this.viewStyle != null && this.viewStyle.getRenderStyle().equals("datasetIdentifier") || this.value instanceof Collection)) { ObjectMapper mapper = new ObjectMapper(); String valueString = null; try { @@ -240,7 +238,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } catch (JsonProcessingException e) { logger.error(e.getMessage(), e); } - } else if (this.value instanceof Collection) { + } /*else if (this.value instanceof Collection) { Collection valueCollection = (Collection) this.value; StringBuilder valueBuilder = new StringBuilder(); valueBuilder.append("["); @@ -252,7 +250,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } valueBuilder.append("]"); fieldValues.put(this.id, valueBuilder.toString()); - } else { + }*/ else { fieldValues.put(this.id, this.value.toString()); } } else {