From e615c403d3c00a1d4b3ed371baaa6f15a7bd834d Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 14 Jun 2021 18:01:04 +0300 Subject: [PATCH] Final fix over storing array of data from Datasets --- .../data/user/components/datasetprofile/Field.java | 11 +---------- .../components/form-field/form-field.component.ts | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) 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 10576100b..917d85542 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 @@ -245,7 +245,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin StringBuilder valueBuilder = new StringBuilder(); valueBuilder.append("["); for (int i = 0; i < valueCollection.size(); i++) { - valueBuilder.append(parseString(valueCollection.stream().toArray()[i])); + valueBuilder.append("\"").append(valueCollection.toArray()[i]).append("\""); if (i < valueCollection.size() - 1) { valueBuilder.append(", "); } @@ -264,13 +264,4 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin public void toMap(Map fieldValues, int index) { fieldValues.put(this.id, this.value); } - - private String parseString(Object value) { - if (value instanceof String) { - if (((String)value).contains(",")) { - return "\"" + value + "\""; - } - } - return value.toString(); - } } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts index 1e6c9a79e..07be0c4c8 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts @@ -107,7 +107,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit { const originalValue = this.form.get('value').value; if (originalValue !== null && typeof originalValue === 'string') { let values = (this.form.get('value').value).slice(1, -1).split(', ').filter((value) => !value.includes('"')); - let specialValue = (this.form.get('value').value).split('"').filter((value) => !value.startsWith('[') && !value.endsWith(']') && !values.includes(value)); + let specialValue = (this.form.get('value').value).split('"').filter((value) => !value.startsWith('[') && !value.endsWith(']') && !values.includes(value) && value !== ', '); specialValue.forEach(value => values.push(value)); if (!originalValue.startsWith('[') && !originalValue.endsWith(']')) { values = undefined;