From dcf88479bdb2eed7c75372fc8b7535bd6cff18ef Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 14 Jun 2021 14:21:27 +0300 Subject: [PATCH 1/5] Allow to store and retrieve combobox multivalues with commas --- .../user/components/datasetprofile/Field.java | 22 +++++++++++++++++++ .../form-field/form-field.component.ts | 8 ++++--- 2 files changed, 27 insertions(+), 3 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 bffd8d702..10576100b 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.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -239,6 +240,18 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } catch (JsonProcessingException e) { logger.error(e.getMessage(), e); } + } else if (this.value instanceof Collection) { + Collection valueCollection = (Collection) this.value; + StringBuilder valueBuilder = new StringBuilder(); + valueBuilder.append("["); + for (int i = 0; i < valueCollection.size(); i++) { + valueBuilder.append(parseString(valueCollection.stream().toArray()[i])); + if (i < valueCollection.size() - 1) { + valueBuilder.append(", "); + } + } + valueBuilder.append("]"); + fieldValues.put(this.id, valueBuilder.toString()); } else { fieldValues.put(this.id, this.value.toString()); } @@ -251,4 +264,13 @@ 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 a76cfcae8..1e6c9a79e 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 @@ -106,7 +106,9 @@ export class FormFieldComponent extends BaseComponent implements OnInit { if (this.form.get('data').value.multiList) { const originalValue = this.form.get('value').value; if (originalValue !== null && typeof originalValue === 'string') { - let values = (this.form.get('value').value).slice(1, -1).split(', '); + 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)); + specialValue.forEach(value => values.push(value)); if (!originalValue.startsWith('[') && !originalValue.endsWith(']')) { values = undefined; values = [originalValue]; @@ -385,8 +387,8 @@ export class FormFieldComponent extends BaseComponent implements OnInit { parseTags() { try{ - - + + let stringValue = this.form.get('value').value; if (typeof stringValue === 'string') { stringValue = (stringValue).replace(new RegExp('{', 'g'), '{"').replace(new RegExp('=', 'g'), '":"').replace(new RegExp(',', 'g'), '",').replace(new RegExp(', ', 'g'), ', "').replace(new RegExp('}', 'g'), '"}'); From e615c403d3c00a1d4b3ed371baaa6f15a7bd834d Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 14 Jun 2021 18:01:04 +0300 Subject: [PATCH 2/5] 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; From c193dd2c09b1090ba845190c38d7a4fd083574d2 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 14 Jun 2021 18:01:29 +0300 Subject: [PATCH 3/5] Fix numbering issue with word and PDF export --- .../utilities/documents/word/WordBuilder.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java index f13da5c5d..41675e624 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java @@ -135,34 +135,35 @@ public class WordBuilder { private void createPages(List datasetProfilePages, XWPFDocument mainDocumentPart, Boolean createListing, VisibilityRuleService visibilityRuleService) { datasetProfilePages.forEach(item -> { try { - createSections(item.getSections(), mainDocumentPart, ParagraphStyle.HEADER4, 0, createListing, visibilityRuleService); + createSections(item.getSections(), mainDocumentPart, ParagraphStyle.HEADER4, 0, createListing, visibilityRuleService, item.getOrdinal() + 1, null); } catch (Exception e) { logger.error(e.getMessage(), e); } }); } - private void createSections(List
sections, XWPFDocument mainDocumentPart, ParagraphStyle style, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) { + private void createSections(List
sections, XWPFDocument mainDocumentPart, ParagraphStyle style, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService, Integer page, String sectionString) { if (createListing) this.addListing(mainDocumentPart, indent, false, true); sections.forEach(section -> { + String tempSectionString = sectionString != null ? sectionString + "." + (section.getOrdinal() + 1) : "" + (section.getOrdinal() + 1); if (visibilityRuleService.isElementVisible(section.getId())) { if (!createListing) { - XWPFParagraph paragraph = addParagraphContent(section.getNumbering() + " " + section.getTitle(), mainDocumentPart, style, numId); + XWPFParagraph paragraph = addParagraphContent(page + "." + tempSectionString + " " + section.getTitle(), mainDocumentPart, style, numId); CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl(); number.setVal(BigInteger.valueOf(indent)); } - createSections(section.getSections(), mainDocumentPart, ParagraphStyle.HEADER5, 1, createListing, visibilityRuleService); - createCompositeFields(section.getCompositeFields(), mainDocumentPart, 2, createListing, visibilityRuleService); + createSections(section.getSections(), mainDocumentPart, ParagraphStyle.HEADER5, 1, createListing, visibilityRuleService, page, tempSectionString); + createCompositeFields(section.getCompositeFields(), mainDocumentPart, 2, createListing, visibilityRuleService, page, tempSectionString); } }); } - private void createCompositeFields(List
compositeFields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) { + private void createCompositeFields(List
compositeFields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService, Integer page, String section) { if (createListing) this.addListing(mainDocumentPart, indent, true, true); compositeFields.forEach(compositeField -> { if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) { if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty() && !createListing) { - XWPFParagraph paragraph = addParagraphContent(compositeField.getNumbering() + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER6, numId); + XWPFParagraph paragraph = addParagraphContent(page + "." + section + "." + (compositeField.getOrdinal() +1) + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER6, numId); CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl(); number.setVal(BigInteger.valueOf(indent)); } From 54b2661ebd19b9919157ba3aaacb26c81f2b26cf Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Tue, 15 Jun 2021 09:58:51 +0300 Subject: [PATCH 4/5] Ui fixes. * Fix issue on table of contents in dataset editor. Invalid fields that are hidden via visibility rules, are not computed in in the validity of the tocEntry. --- .../form-field/form-field.component.html | 68 +++++++++---------- .../table-of-contents-internal.html | 6 +- .../table-of-contents-internal.ts | 38 ++++++++--- .../table-of-contents.html | 2 +- 4 files changed, 67 insertions(+), 47 deletions(-) diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html index d8d11022f..08563bcd6 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.html @@ -17,16 +17,16 @@
-
+ -
-
+ + -
+ {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} @@ -45,46 +45,46 @@
-
+ -
-
+ + -
+ {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}
-
+ -
-
+ + -
+ {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}
-
+ -
-
+ + -
+ {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} @@ -138,18 +138,18 @@
-
+ -
-
+ + - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - -
+ + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }}
@@ -158,16 +158,16 @@
-
+ -
-
+ + -
+ {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} @@ -178,16 +178,16 @@
-
+ -
-
+ + -
+ {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} @@ -198,16 +198,16 @@
-
+ -
-
+ + -
+ {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT" | translate }} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html index 187b6cca6..f78625aa2 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents-internal/table-of-contents-internal.html @@ -10,7 +10,7 @@ [ngStyle]="calculateStyle(entry)" [ngClass]="calculateClass(entry)" > - + {{entry.numbering}}. {{entry.label}}