From c05ccef28e734504e9bff79b1685c5f6a9d5e444 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Fri, 26 Jan 2024 11:41:20 +0200 Subject: [PATCH] change blueprint to user description template group id --- .../DescriptionTemplateEntity.java | 26 +++++----------- .../DescriptionTemplateImportExport.java | 22 ++++--------- .../DescriptionTemplateBuilder.java | 3 +- .../DescriptionTemplate.java | 22 ++++--------- .../DescriptionTemplatePersist.java | 31 +++++-------------- .../dmpblueprint/DmpBlueprintServiceImpl.java | 19 ++---------- 6 files changed, 32 insertions(+), 91 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DescriptionTemplateEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DescriptionTemplateEntity.java index 4b2407e12..d2421c670 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DescriptionTemplateEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DescriptionTemplateEntity.java @@ -12,10 +12,8 @@ import java.util.UUID; @XmlAccessorType(XmlAccessType.FIELD) public class DescriptionTemplateEntity implements XmlSerializable { - @XmlAttribute(name="id") - private UUID id; - @XmlAttribute(name="descriptionTemplateId") - private UUID descriptionTemplateId; + @XmlAttribute(name="descriptionTemplateGroupId") + private UUID descriptionTemplateGroupId; @XmlAttribute(name="label") private String label; @XmlAttribute(name="minMultiplicity") @@ -23,18 +21,12 @@ public class DescriptionTemplateEntity implements XmlSerializable specifications(DescriptionTemplatePersist item) { return Arrays.asList( this.spec() - .must(() -> this.isValidGuid(item.getId())) - .failOn(DescriptionTemplatePersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._id}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> this.isValidGuid(item.getDescriptionTemplateId())) - .failOn(DescriptionTemplatePersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateId}, LocaleContextHolder.getLocale())) + .must(() -> this.isValidGuid(item.getDescriptionTemplateGroupId())) + .failOn(DescriptionTemplatePersist._descriptionTemplateGroupId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateGroupId}, LocaleContextHolder.getLocale())) ); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java index d1ca20e0f..6788ce75e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java @@ -199,8 +199,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { if (persist == null) return data; - data.setId(persist.getId()); - data.setDescriptionTemplateId(persist.getDescriptionTemplateId()); + data.setDescriptionTemplateGroupId(persist.getDescriptionTemplateGroupId()); data.setLabel(persist.getLabel()); data.setMaxMultiplicity(persist.getMaxMultiplicity()); data.setMinMultiplicity(persist.getMinMultiplicity()); @@ -320,11 +319,6 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { this.reassignField(field); } } - if (model.getDescriptionTemplates() != null) { - for (DescriptionTemplate descriptionTemplate : model.getDescriptionTemplates()) { - this.reassignDescriptionTemplate(descriptionTemplate); - } - } } private void reassignField(Field model) { @@ -333,11 +327,6 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { model.setId(UUID.randomUUID()); } - private void reassignDescriptionTemplate(DescriptionTemplate model) { - if (model == null) - return; - model.setId(UUID.randomUUID()); - } //endregion @@ -404,8 +393,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { private DescriptionTemplateImportExport descriptionTemplateXmlToExport(DescriptionTemplateEntity entity) { DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport(); - xml.setId(entity.getId()); - xml.setDescriptionTemplateId(entity.getDescriptionTemplateId()); + xml.setDescriptionTemplateGroupId(entity.getDescriptionTemplateGroupId()); xml.setLabel(entity.getLabel()); xml.setMinMultiplicity(entity.getMinMultiplicity()); xml.setMaxMultiplicity(entity.getMaxMultiplicity()); @@ -503,8 +491,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { private DescriptionTemplatePersist xmlDescriptionTemplateToPersist(DescriptionTemplateImportExport importXml) { DescriptionTemplatePersist persist = new DescriptionTemplatePersist(); - persist.setId(importXml.getId()); - persist.setDescriptionTemplateId(importXml.getDescriptionTemplateId()); + persist.setDescriptionTemplateGroupId(importXml.getDescriptionTemplateGroupId()); persist.setLabel(importXml.getLabel()); persist.setMinMultiplicity(importXml.getMinMultiplicity()); persist.setMaxMultiplicity(importXml.getMaxMultiplicity());