From c05ccef28e734504e9bff79b1685c5f6a9d5e444 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Fri, 26 Jan 2024 11:41:20 +0200 Subject: [PATCH 1/3] 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()); From 962840d7385bb8853101b0485cc56ac1abaa3a46 Mon Sep 17 00:00:00 2001 From: amentis Date: Fri, 26 Jan 2024 12:17:01 +0200 Subject: [PATCH 2/3] change frontend blueprint description template group id --- .../core/model/dmp-blueprint/dmp-blueprint.ts | 6 ++---- .../editor/dmp-blueprint-editor.model.ts | 16 ++++++---------- .../editor/dmp-blueprint-editor.resolver.ts | 3 +-- .../editor/description-editor.resolver.ts | 4 ++-- .../dmp/dmp-editor-blueprint/dmp-editor.model.ts | 2 +- .../dmp-editor-blueprint/dmp-editor.resolver.ts | 3 +-- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts index 85d0c1d20..0c7b069c2 100644 --- a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts +++ b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts @@ -29,8 +29,7 @@ export interface DmpBlueprintDefinitionSection { } export interface DescriptionTemplatesInSection { - id: Guid; - descriptionTemplateId: Guid; + descriptionTemplateGroupId: Guid; label: string; minMultiplicity: number; maxMultiplicity: number; @@ -73,8 +72,7 @@ export interface DmpBlueprintDefinitionSectionPersist { } export interface DescriptionTemplatesInSectionPersist { - id: Guid; - descriptionTemplateId: Guid; + descriptionTemplateGroupId: Guid; label: string; minMultiplicity: number; maxMultiplicity: number; diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts index 7a8cf0fe1..08dc1c8f3 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.model.ts @@ -88,8 +88,8 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep createChildDescriptionTemplate(item: any, sectionIndex: number, index: number): UntypedFormGroup { const descriptionTemplate: DescriptionTemplatesInSectionEditorModel = new DescriptionTemplatesInSectionEditorModel(this.validationErrorModel); - descriptionTemplate.id = Guid.create(); - descriptionTemplate.descriptionTemplateId = item.id; + // descriptionTemplate.id = Guid.create(); + descriptionTemplate.descriptionTemplateGroupId = item.descriptionTemplateGroupId; descriptionTemplate.label = item.label; return descriptionTemplate.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].descriptionTemplates[' + index + '].' }); } @@ -419,8 +419,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist { } export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemplatesInSectionPersist { - id: Guid; - descriptionTemplateId: Guid; + descriptionTemplateGroupId: Guid; label: string; minMultiplicity: number; maxMultiplicity: number; @@ -432,8 +431,7 @@ export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemp ) { } fromModel(item: DescriptionTemplatesInSection): DescriptionTemplatesInSectionEditorModel { - this.id = item.id; - this.descriptionTemplateId = item.descriptionTemplateId; + this.descriptionTemplateGroupId = item.descriptionTemplateGroupId; this.label = item.label; this.minMultiplicity = item.minMultiplicity; this.maxMultiplicity = item.maxMultiplicity; @@ -454,8 +452,7 @@ export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemp } return this.formBuilder.group({ - id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], - descriptionTemplateId: [{ value: this.descriptionTemplateId, disabled: disabled }, context.getValidation('descriptionTemplateId').validators], + descriptionTemplateGroupId: [{ value: this.descriptionTemplateGroupId, disabled: disabled }, context.getValidation('descriptionTemplateGroupId').validators], label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], minMultiplicity: [{ value: this.minMultiplicity, disabled: disabled }, context.getValidation('minMultiplicity').validators], maxMultiplicity: [{ value: this.maxMultiplicity, disabled: disabled }, context.getValidation('maxMultiplicity').validators], @@ -470,8 +467,7 @@ export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemp const baseContext: ValidationContext = new ValidationContext(); const baseValidationArray: Validation[] = new Array(); - baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] }); - baseValidationArray.push({ key: 'descriptionTemplateId', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplateId`)] }); + baseValidationArray.push({ key: 'descriptionTemplateGroupId', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplateGroupId`)] }); baseValidationArray.push({ key: 'label', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] }); baseValidationArray.push({ key: 'minMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}minMultiplicity`)] }); baseValidationArray.push({ key: 'maxMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}maxMultiplicity`)] }); diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts index 4864105d4..fbc5a3e29 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.resolver.ts @@ -39,8 +39,7 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts index a96dabc02..4701ce51b 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts @@ -37,8 +37,8 @@ export class DescriptionEditorResolver extends BaseEditorResolver { [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), // [nameof(x => x.dmp), nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts index b78cf9eb6..6dc3f2c98 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts @@ -56,7 +56,7 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist { this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel(this.validationErrorModel).fromModel( { sectionId: section.id, - descriptionTemplateGroupId: blueprintDefinedDescriptionTemplate?.descriptionTemplateId, + descriptionTemplateGroupId: blueprintDefinedDescriptionTemplate?.descriptionTemplateGroupId, })); }); } else { diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts index 8b464d2e2..2b9e9ac2e 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts @@ -89,8 +89,7 @@ export class DmpEditorResolver extends BaseEditorResolver { (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), From 2726d232dd135e62412563ff0b753c337c615ef0 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Fri, 26 Jan 2024 12:42:46 +0200 Subject: [PATCH 3/3] upgrade blueprint xml --- .../enums/DmpBlueprintFieldCategory.java | 5 ++ .../types/dmpblueprint/DefinitionEntity.java | 30 +------ .../DescriptionTemplateEntity.java | 20 +---- .../types/dmpblueprint/ExtraFieldEntity.java | 12 --- .../types/dmpblueprint/FieldEntity.java | 31 +------ .../types/dmpblueprint/SectionEntity.java | 88 +++---------------- .../types/dmpblueprint/SystemFieldEntity.java | 13 --- .../managers/DataManagementPlanManager.java | 2 +- 8 files changed, 22 insertions(+), 179 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintFieldCategory.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintFieldCategory.java index 787a5cbbf..032d476e8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintFieldCategory.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintFieldCategory.java @@ -9,6 +9,11 @@ public enum DmpBlueprintFieldCategory implements DatabaseEnum { System((short) 0), Extra((short) 1); + public static class Names { + public static final String System = "system"; + public static final String Extra = "extra"; + } + private final Short value; DmpBlueprintFieldCategory(Short value) { diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DefinitionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DefinitionEntity.java index 7525006bf..26c80a43f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DefinitionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DefinitionEntity.java @@ -13,7 +13,7 @@ import java.util.List; @XmlRootElement(name = "root") @XmlAccessorType(XmlAccessType.FIELD) -public class DefinitionEntity implements XmlSerializable { +public class DefinitionEntity { @XmlElementWrapper(name = "sections") @XmlElement(name = "section") private List sections; @@ -24,32 +24,4 @@ public class DefinitionEntity implements XmlSerializable { public void setSections(List sections) { this.sections = sections; } - - @Override - public Element toXml(Document doc) { - Element root = doc.createElement("root"); - Element sections = doc.createElement("sections"); - for (SectionEntity section : this.sections) { - sections.appendChild(section.toXml(doc)); - } - root.appendChild(sections); - return root; - } - - @Override - public DefinitionEntity fromXml(Element item) { - this.sections = new LinkedList<>(); - Element sections = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "sections"); - if (sections != null) { - NodeList sectionElements = sections.getChildNodes(); - for (int temp = 0; temp < sectionElements.getLength(); temp++) { - Node sectionElement = sectionElements.item(temp); - if (sectionElement.getNodeType() == Node.ELEMENT_NODE) { - this.sections.add(new SectionEntity().fromXml((Element) sectionElement)); - } - } - } - return this; - } - } 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 d2421c670..eb1db220b 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 @@ -10,7 +10,7 @@ import org.w3c.dom.Element; import java.util.UUID; @XmlAccessorType(XmlAccessType.FIELD) -public class DescriptionTemplateEntity implements XmlSerializable { +public class DescriptionTemplateEntity { @XmlAttribute(name="descriptionTemplateGroupId") private UUID descriptionTemplateGroupId; @@ -50,22 +50,4 @@ public class DescriptionTemplateEntity implements XmlSerializable { +public abstract class FieldEntity { @XmlAttribute(name="id") private UUID id; - @XmlTransient + @XmlAttribute(name="category") private DmpBlueprintFieldCategory category; @XmlAttribute(name="label") @@ -83,30 +83,5 @@ public abstract class FieldEntity implements XmlSerializable { public void setRequired(boolean required) { this.required = required; } - protected abstract Element appendXmlChild(Element rootElement); - protected abstract FieldEntity fromXmlChild(Element item); - @Override - public Element toXml(Document doc) { - Element rootElement = doc.createElement("extraField"); - rootElement.setAttribute("id", this.getId().toString()); - rootElement.setAttribute("label", this.label); - rootElement.setAttribute("description", this.description); - rootElement.setAttribute("placeholder", this.placeholder); - rootElement.setAttribute("required", String.valueOf(this.required)); - rootElement.setAttribute("ordinal", String.valueOf(this.ordinal)); - this.appendXmlChild(rootElement); - return rootElement; - } - - @Override - public FieldEntity fromXml(Element item) { - this.id = UUID.fromString(item.getAttribute("id")); - this.label = item.getAttribute("label"); - this.description = item.getAttribute("description"); - this.placeholder = item.getAttribute("placeholder"); - this.required = Boolean.parseBoolean(item.getAttribute("required")); - this.ordinal = Integer.valueOf(item.getAttribute("ordinal")); - this.fromXmlChild(item); - return this; - } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java index 50d6c1e59..a1dd62736 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java @@ -1,6 +1,10 @@ package eu.eudat.commons.types.dmpblueprint; import eu.eudat.commons.enums.DmpBlueprintFieldCategory; +import eu.eudat.commons.enums.ReferenceTypeSourceType; +import eu.eudat.commons.types.referencetype.ReferenceTypeSourceBaseConfigurationEntity; +import eu.eudat.commons.types.referencetype.ReferenceTypeSourceExternalApiConfigurationEntity; +import eu.eudat.commons.types.referencetype.ReferenceTypeSourceStaticOptionConfigurationEntity; import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.commons.types.xml.XmlSerializable; import jakarta.xml.bind.annotation.*; @@ -15,7 +19,7 @@ import java.util.UUID; import java.util.stream.Collectors; @XmlAccessorType(XmlAccessType.FIELD) -public class SectionEntity implements XmlSerializable { +public class SectionEntity { @XmlAttribute(name="id") private UUID id; @@ -29,9 +33,13 @@ public class SectionEntity implements XmlSerializable { @XmlAttribute(name="ordinal") private Integer ordinal; - @XmlTransient + @XmlElementWrapper(name = "fields") + @XmlElements({ + @XmlElement(name = DmpBlueprintFieldCategory.Names.Extra, type = ExtraFieldEntity.class), + @XmlElement(name = DmpBlueprintFieldCategory.Names.System, type = SystemFieldEntity.class), + }) private List fields; - + @XmlAttribute(name="hasTemplates") private Boolean hasTemplates; @@ -88,78 +96,4 @@ public class SectionEntity implements XmlSerializable { this.descriptionTemplates = descriptionTemplates; } - @Override - public Element toXml(Document doc) { - Element rootElement = doc.createElement("section"); - rootElement.setAttribute("id", this.getId().toString()); - rootElement.setAttribute("label", this.label); - rootElement.setAttribute("description", this.description); - rootElement.setAttribute("ordinal", String.valueOf(this.ordinal)); - rootElement.setAttribute("hasTemplates", String.valueOf(this.hasTemplates)); - List temp = this.fields.stream().filter(f -> f.getCategory().equals(DmpBlueprintFieldCategory.System)).collect(Collectors.toList()); - List systemFieldsList = temp.stream().map(x-> (SystemFieldEntity)x).collect(Collectors.toList()); - Element systemFields = doc.createElement("systemFields"); - for (SystemFieldEntity systemField : systemFieldsList) { - systemFields.appendChild(systemField.toXml(doc)); - } - rootElement.appendChild(systemFields); - if (this.descriptionTemplates != null) { - Element descriptionTemplates = doc.createElement("descriptionTemplates"); - for (DescriptionTemplateEntity descriptionTemplate : this.descriptionTemplates) { - descriptionTemplates.appendChild(descriptionTemplate.toXml(doc)); - } - rootElement.appendChild(descriptionTemplates); - } - temp = this.fields.stream().filter(f -> f.getCategory().equals(DmpBlueprintFieldCategory.Extra)).collect(Collectors.toList()); - List extraFieldList = temp.stream().map(x-> (ExtraFieldEntity)x).collect(Collectors.toList()); - Element extraFields = doc.createElement("extraFields"); - for (ExtraFieldEntity extraField : extraFieldList) { - extraFields.appendChild(extraField.toXml(doc)); - } - rootElement.appendChild(extraFields); - - return rootElement; - } - - @Override - public SectionEntity fromXml(Element item) { - this.id = UUID.fromString(item.getAttribute("id")); - this.label = item.getAttribute("label"); - this.description = item.getAttribute("description"); - this.ordinal = Integer.valueOf(item.getAttribute("ordinal")); - this.hasTemplates = Boolean.valueOf(item.getAttribute("hasTemplates")); - this.fields = new LinkedList<>(); - Element systemFields = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "systemFields"); - if (systemFields != null) { - NodeList systemFieldElements = systemFields.getChildNodes(); - for (int temp = 0; temp < systemFieldElements.getLength(); temp++) { - Node systemFieldElement = systemFieldElements.item(temp); - if (systemFieldElement.getNodeType() == Node.ELEMENT_NODE) { - this.fields.add(new SystemFieldEntity().fromXml((Element) systemFieldElement)); - } - } - } - this.descriptionTemplates = new LinkedList<>(); - Element descriptionTemplates = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "descriptionTemplates"); - if (descriptionTemplates != null) { - NodeList descriptionTemplateElements = descriptionTemplates.getChildNodes(); - for (int temp = 0; temp < descriptionTemplateElements.getLength(); temp++) { - Node descriptionTemplateElement = descriptionTemplateElements.item(temp); - if (descriptionTemplateElement.getNodeType() == Node.ELEMENT_NODE) { - this.descriptionTemplates.add(new DescriptionTemplateEntity().fromXml((Element) descriptionTemplateElement)); - } - } - } - Element extraFields = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "extraFields"); - if (extraFields != null) { - NodeList extraFieldElements = extraFields.getChildNodes(); - for (int temp = 0; temp < extraFieldElements.getLength(); temp++) { - Node extraFieldElement = extraFieldElements.item(temp); - if (extraFieldElement.getNodeType() == Node.ELEMENT_NODE) { - this.fields.add(new ExtraFieldEntity().fromXml((Element) extraFieldElement)); - } - } - } - return this; - } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SystemFieldEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SystemFieldEntity.java index 6787af8d2..52a6a312f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SystemFieldEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SystemFieldEntity.java @@ -23,17 +23,4 @@ public class SystemFieldEntity extends FieldEntity { public void setType(DmpBlueprintSystemFieldType type) { this.type = type; } - - @Override - public Element appendXmlChild(Element rootElement) { - rootElement.setAttribute("type", String.valueOf(this.type.getValue())); - return rootElement; - } - - @Override - public SystemFieldEntity fromXmlChild(Element item) { - this.type = DmpBlueprintSystemFieldType.of(Short.parseShort(item.getAttribute("type"))); - this.setCategory(DmpBlueprintFieldCategory.System); - return this; - } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 7071a0afa..e2930155d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -1928,7 +1928,7 @@ public class DataManagementPlanManager { Element extraFields = xmlDoc.createElement("extraFields"); Map dmpProperties = new ObjectMapper().readValue(dmp.getProperties(), new TypeReference>() {}); - DefinitionEntity blueprint = new DefinitionEntity().fromXml(XmlBuilder.fromXml(this.queryFactory.query(DmpBlueprintQuery.class).ids(dmp.getBlueprintId()).first().getDefinition()).getDocumentElement()); + DefinitionEntity blueprint = new DefinitionEntity(); //new DefinitionEntity().fromXml(XmlBuilder.fromXml(this.queryFactory.query(DmpBlueprintQuery.class).ids(dmp.getBlueprintId()).first().getDefinition()).getDocumentElement()); blueprint.getSections().forEach(section -> { section.getFields().forEach(fieldModel -> {