Merge remote-tracking branch 'origin/dmp-refactoring' into dmp-refactoring

This commit is contained in:
George Kalampokis 2024-01-26 12:55:08 +02:00
commit ac932ffb05
19 changed files with 65 additions and 289 deletions

View File

@ -9,6 +9,11 @@ public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
System((short) 0), System((short) 0),
Extra((short) 1); Extra((short) 1);
public static class Names {
public static final String System = "system";
public static final String Extra = "extra";
}
private final Short value; private final Short value;
DmpBlueprintFieldCategory(Short value) { DmpBlueprintFieldCategory(Short value) {

View File

@ -13,7 +13,7 @@ import java.util.List;
@XmlRootElement(name = "root") @XmlRootElement(name = "root")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DefinitionEntity implements XmlSerializable<DefinitionEntity> { public class DefinitionEntity {
@XmlElementWrapper(name = "sections") @XmlElementWrapper(name = "sections")
@XmlElement(name = "section") @XmlElement(name = "section")
private List<SectionEntity> sections; private List<SectionEntity> sections;
@ -24,32 +24,4 @@ public class DefinitionEntity implements XmlSerializable<DefinitionEntity> {
public void setSections(List<SectionEntity> sections) { public void setSections(List<SectionEntity> sections) {
this.sections = 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;
}
} }

View File

@ -10,12 +10,10 @@ import org.w3c.dom.Element;
import java.util.UUID; import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateEntity implements XmlSerializable<DescriptionTemplateEntity> { public class DescriptionTemplateEntity {
@XmlAttribute(name="id") @XmlAttribute(name="descriptionTemplateGroupId")
private UUID id; private UUID descriptionTemplateGroupId;
@XmlAttribute(name="descriptionTemplateId")
private UUID descriptionTemplateId;
@XmlAttribute(name="label") @XmlAttribute(name="label")
private String label; private String label;
@XmlAttribute(name="minMultiplicity") @XmlAttribute(name="minMultiplicity")
@ -23,18 +21,12 @@ public class DescriptionTemplateEntity implements XmlSerializable<DescriptionTem
@XmlAttribute(name="maxMultiplicity") @XmlAttribute(name="maxMultiplicity")
private Integer maxMultiplicity; private Integer maxMultiplicity;
public UUID getId() { public UUID getDescriptionTemplateGroupId() {
return id; return descriptionTemplateGroupId;
}
public void setId(UUID id) {
this.id = id;
} }
public UUID getDescriptionTemplateId() { public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
return descriptionTemplateId; this.descriptionTemplateGroupId = descriptionTemplateGroupId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
} }
public String getLabel() { public String getLabel() {
@ -58,24 +50,4 @@ public class DescriptionTemplateEntity implements XmlSerializable<DescriptionTem
this.maxMultiplicity = maxMultiplicity; this.maxMultiplicity = maxMultiplicity;
} }
@Override
public Element toXml(Document doc) {
Element rootElement = doc.createElement("descriptionTemplate");
rootElement.setAttribute("id", this.getId().toString());
rootElement.setAttribute("descriptionTemplateId", this.getDescriptionTemplateId().toString());
rootElement.setAttribute("label", this.label);
rootElement.setAttribute("minMultiplicity", String.valueOf(this.minMultiplicity));
rootElement.setAttribute("maxMultiplicity", String.valueOf(this.maxMultiplicity));
return rootElement;
}
@Override
public DescriptionTemplateEntity fromXml(Element item) {
this.id = UUID.fromString(item.getAttribute("id"));
this.descriptionTemplateId = UUID.fromString(item.getAttribute("descriptionTemplateId"));
this.label = item.getAttribute("label");
this.minMultiplicity = item.hasAttribute("minMultiplicity") && !item.getAttribute("minMultiplicity").equals("null") ? Integer.parseInt(item.getAttribute("minMultiplicity")) : null;
this.maxMultiplicity = item.hasAttribute("maxMultiplicity") && !item.getAttribute("minMultiplicity").equals("null") ? Integer.parseInt(item.getAttribute("maxMultiplicity")) : null;
return this;
}
} }

View File

@ -20,16 +20,4 @@ public class ExtraFieldEntity extends FieldEntity {
this.type = type; this.type = type;
} }
@Override
public Element appendXmlChild(Element rootElement) {
rootElement.setAttribute("type", String.valueOf(this.type.getValue()));
return rootElement;
}
@Override
public ExtraFieldEntity fromXmlChild(Element item) {
this.type = DmpBlueprintExtraFieldDataType.of(Short.parseShort(item.getAttribute("type")));
this.setCategory(DmpBlueprintFieldCategory.Extra);
return this;
}
} }

View File

@ -13,11 +13,11 @@ import org.w3c.dom.Element;
import java.util.UUID; import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public abstract class FieldEntity implements XmlSerializable<FieldEntity> { public abstract class FieldEntity {
@XmlAttribute(name="id") @XmlAttribute(name="id")
private UUID id; private UUID id;
@XmlTransient @XmlAttribute(name="category")
private DmpBlueprintFieldCategory category; private DmpBlueprintFieldCategory category;
@XmlAttribute(name="label") @XmlAttribute(name="label")
@ -83,30 +83,5 @@ public abstract class FieldEntity implements XmlSerializable<FieldEntity> {
public void setRequired(boolean required) { public void setRequired(boolean required) {
this.required = 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;
}
} }

View File

@ -1,6 +1,10 @@
package eu.eudat.commons.types.dmpblueprint; package eu.eudat.commons.types.dmpblueprint;
import eu.eudat.commons.enums.DmpBlueprintFieldCategory; 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.XmlBuilder;
import eu.eudat.commons.types.xml.XmlSerializable; import eu.eudat.commons.types.xml.XmlSerializable;
import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.*;
@ -15,7 +19,7 @@ import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class SectionEntity implements XmlSerializable<SectionEntity> { public class SectionEntity {
@XmlAttribute(name="id") @XmlAttribute(name="id")
private UUID id; private UUID id;
@ -29,7 +33,11 @@ public class SectionEntity implements XmlSerializable<SectionEntity> {
@XmlAttribute(name="ordinal") @XmlAttribute(name="ordinal")
private Integer 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<FieldEntity> fields; private List<FieldEntity> fields;
@XmlAttribute(name="hasTemplates") @XmlAttribute(name="hasTemplates")
@ -88,78 +96,4 @@ public class SectionEntity implements XmlSerializable<SectionEntity> {
this.descriptionTemplates = descriptionTemplates; 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<FieldEntity> temp = this.fields.stream().filter(f -> f.getCategory().equals(DmpBlueprintFieldCategory.System)).collect(Collectors.toList());
List<SystemFieldEntity> 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<ExtraFieldEntity> 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;
}
} }

View File

@ -23,17 +23,4 @@ public class SystemFieldEntity extends FieldEntity {
public void setType(DmpBlueprintSystemFieldType type) { public void setType(DmpBlueprintSystemFieldType type) {
this.type = 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;
}
} }

View File

@ -9,10 +9,8 @@ import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateImportExport { public class DescriptionTemplateImportExport {
@XmlAttribute(name = "id") @XmlAttribute(name = "descriptionTemplateGroupId")
private UUID id; private UUID descriptionTemplateGroupId;
@XmlAttribute(name = "descriptionTemplateId")
private UUID descriptionTemplateId;
@XmlAttribute(name = "label") @XmlAttribute(name = "label")
private String label; private String label;
@XmlAttribute(name = "minMultiplicity") @XmlAttribute(name = "minMultiplicity")
@ -20,20 +18,12 @@ public class DescriptionTemplateImportExport {
@XmlAttribute(name = "maxMultiplicity") @XmlAttribute(name = "maxMultiplicity")
private int maxMultiplicity; private int maxMultiplicity;
public UUID getId() { public UUID getDescriptionTemplateGroupId() {
return id; return descriptionTemplateGroupId;
} }
public void setId(UUID id) { public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
this.id = id; this.descriptionTemplateGroupId = descriptionTemplateGroupId;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
} }
public String getLabel() { public String getLabel() {

View File

@ -45,8 +45,7 @@ public class DescriptionTemplateBuilder extends BaseBuilder<DescriptionTemplate,
for (DescriptionTemplateEntity d : data) { for (DescriptionTemplateEntity d : data) {
DescriptionTemplate m = new DescriptionTemplate(); DescriptionTemplate m = new DescriptionTemplate();
if (fields.hasField(this.asIndexer(DescriptionTemplate._label))) m.setLabel(d.getLabel()); if (fields.hasField(this.asIndexer(DescriptionTemplate._label))) m.setLabel(d.getLabel());
if (fields.hasField(this.asIndexer(DescriptionTemplate._descriptionTemplateId))) m.setDescriptionTemplateId(d.getDescriptionTemplateId()); if (fields.hasField(this.asIndexer(DescriptionTemplate._descriptionTemplateGroupId))) m.setDescriptionTemplateGroupId(d.getDescriptionTemplateGroupId());
if (fields.hasField(this.asIndexer(DescriptionTemplate._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(DescriptionTemplate._maxMultiplicity))) m.setMaxMultiplicity(d.getMaxMultiplicity()); if (fields.hasField(this.asIndexer(DescriptionTemplate._maxMultiplicity))) m.setMaxMultiplicity(d.getMaxMultiplicity());
if (fields.hasField(this.asIndexer(DescriptionTemplate._minMultiplicity))) m.setMinMultiplicity(d.getMinMultiplicity()); if (fields.hasField(this.asIndexer(DescriptionTemplate._minMultiplicity))) m.setMinMultiplicity(d.getMinMultiplicity());
models.add(m); models.add(m);

View File

@ -4,11 +4,9 @@ import java.util.UUID;
public class DescriptionTemplate { public class DescriptionTemplate {
public final static String _id = "id";
private UUID id;
public final static String _descriptionTemplateId = "descriptionTemplateId"; public final static String _descriptionTemplateGroupId = "descriptionTemplateGroupId";
private UUID descriptionTemplateId; private UUID descriptionTemplateGroupId;
public final static String _label = "label"; public final static String _label = "label";
private String label; private String label;
@ -19,20 +17,12 @@ public class DescriptionTemplate {
public final static String _maxMultiplicity = "maxMultiplicity"; public final static String _maxMultiplicity = "maxMultiplicity";
private Integer maxMultiplicity; private Integer maxMultiplicity;
public UUID getId() { public UUID getDescriptionTemplateGroupId() {
return id; return descriptionTemplateGroupId;
} }
public void setId(UUID id) { public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
this.id = id; this.descriptionTemplateGroupId = descriptionTemplateGroupId;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
} }
public String getLabel() { public String getLabel() {

View File

@ -16,13 +16,9 @@ import java.util.UUID;
public class DescriptionTemplatePersist { public class DescriptionTemplatePersist {
private UUID id = null; private UUID descriptionTemplateGroupId = null;
public static final String _id = "id"; public static final String _descriptionTemplateGroupId = "descriptionTemplateGroupId";
private UUID descriptionTemplateId = null;
public static final String _descriptionTemplateId = "descriptionTemplateId";
private String label = null; private String label = null;
@ -36,20 +32,12 @@ public class DescriptionTemplatePersist {
public static final String _maxMultiplicity = "maxMultiplicity"; public static final String _maxMultiplicity = "maxMultiplicity";
public UUID getId() { public UUID getDescriptionTemplateGroupId() {
return id; return descriptionTemplateGroupId;
} }
public void setId(UUID id) { public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
this.id = id; this.descriptionTemplateGroupId = descriptionTemplateGroupId;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
} }
public String getLabel() { public String getLabel() {
@ -98,11 +86,8 @@ public class DescriptionTemplatePersist {
protected List<Specification> specifications(DescriptionTemplatePersist item) { protected List<Specification> specifications(DescriptionTemplatePersist item) {
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.must(() -> this.isValidGuid(item.getId())) .must(() -> this.isValidGuid(item.getDescriptionTemplateGroupId()))
.failOn(DescriptionTemplatePersist._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._id}, LocaleContextHolder.getLocale())), .failOn(DescriptionTemplatePersist._descriptionTemplateGroupId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateGroupId}, LocaleContextHolder.getLocale()))
this.spec()
.must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
.failOn(DescriptionTemplatePersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateId}, LocaleContextHolder.getLocale()))
); );
} }
} }

View File

@ -199,8 +199,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
if (persist == null) if (persist == null)
return data; return data;
data.setId(persist.getId()); data.setDescriptionTemplateGroupId(persist.getDescriptionTemplateGroupId());
data.setDescriptionTemplateId(persist.getDescriptionTemplateId());
data.setLabel(persist.getLabel()); data.setLabel(persist.getLabel());
data.setMaxMultiplicity(persist.getMaxMultiplicity()); data.setMaxMultiplicity(persist.getMaxMultiplicity());
data.setMinMultiplicity(persist.getMinMultiplicity()); data.setMinMultiplicity(persist.getMinMultiplicity());
@ -320,11 +319,6 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
this.reassignField(field); this.reassignField(field);
} }
} }
if (model.getDescriptionTemplates() != null) {
for (DescriptionTemplate descriptionTemplate : model.getDescriptionTemplates()) {
this.reassignDescriptionTemplate(descriptionTemplate);
}
}
} }
private void reassignField(Field model) { private void reassignField(Field model) {
@ -333,11 +327,6 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
model.setId(UUID.randomUUID()); model.setId(UUID.randomUUID());
} }
private void reassignDescriptionTemplate(DescriptionTemplate model) {
if (model == null)
return;
model.setId(UUID.randomUUID());
}
//endregion //endregion
@ -404,8 +393,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
private DescriptionTemplateImportExport descriptionTemplateXmlToExport(DescriptionTemplateEntity entity) { private DescriptionTemplateImportExport descriptionTemplateXmlToExport(DescriptionTemplateEntity entity) {
DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport(); DescriptionTemplateImportExport xml = new DescriptionTemplateImportExport();
xml.setId(entity.getId()); xml.setDescriptionTemplateGroupId(entity.getDescriptionTemplateGroupId());
xml.setDescriptionTemplateId(entity.getDescriptionTemplateId());
xml.setLabel(entity.getLabel()); xml.setLabel(entity.getLabel());
xml.setMinMultiplicity(entity.getMinMultiplicity()); xml.setMinMultiplicity(entity.getMinMultiplicity());
xml.setMaxMultiplicity(entity.getMaxMultiplicity()); xml.setMaxMultiplicity(entity.getMaxMultiplicity());
@ -503,8 +491,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
private DescriptionTemplatePersist xmlDescriptionTemplateToPersist(DescriptionTemplateImportExport importXml) { private DescriptionTemplatePersist xmlDescriptionTemplateToPersist(DescriptionTemplateImportExport importXml) {
DescriptionTemplatePersist persist = new DescriptionTemplatePersist(); DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
persist.setId(importXml.getId()); persist.setDescriptionTemplateGroupId(importXml.getDescriptionTemplateGroupId());
persist.setDescriptionTemplateId(importXml.getDescriptionTemplateId());
persist.setLabel(importXml.getLabel()); persist.setLabel(importXml.getLabel());
persist.setMinMultiplicity(importXml.getMinMultiplicity()); persist.setMinMultiplicity(importXml.getMinMultiplicity());
persist.setMaxMultiplicity(importXml.getMaxMultiplicity()); persist.setMaxMultiplicity(importXml.getMaxMultiplicity());

View File

@ -1928,7 +1928,7 @@ public class DataManagementPlanManager {
Element extraFields = xmlDoc.createElement("extraFields"); Element extraFields = xmlDoc.createElement("extraFields");
Map<String, Object> dmpProperties = new ObjectMapper().readValue(dmp.getProperties(), new TypeReference<Map<String, Object>>() {}); Map<String, Object> dmpProperties = new ObjectMapper().readValue(dmp.getProperties(), new TypeReference<Map<String, Object>>() {});
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 -> { blueprint.getSections().forEach(section -> {
section.getFields().forEach(fieldModel -> { section.getFields().forEach(fieldModel -> {

View File

@ -29,8 +29,7 @@ export interface DmpBlueprintDefinitionSection {
} }
export interface DescriptionTemplatesInSection { export interface DescriptionTemplatesInSection {
id: Guid; descriptionTemplateGroupId: Guid;
descriptionTemplateId: Guid;
label: string; label: string;
minMultiplicity: number; minMultiplicity: number;
maxMultiplicity: number; maxMultiplicity: number;
@ -73,8 +72,7 @@ export interface DmpBlueprintDefinitionSectionPersist {
} }
export interface DescriptionTemplatesInSectionPersist { export interface DescriptionTemplatesInSectionPersist {
id: Guid; descriptionTemplateGroupId: Guid;
descriptionTemplateId: Guid;
label: string; label: string;
minMultiplicity: number; minMultiplicity: number;
maxMultiplicity: number; maxMultiplicity: number;

View File

@ -88,8 +88,8 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
createChildDescriptionTemplate(item: any, sectionIndex: number, index: number): UntypedFormGroup { createChildDescriptionTemplate(item: any, sectionIndex: number, index: number): UntypedFormGroup {
const descriptionTemplate: DescriptionTemplatesInSectionEditorModel = new DescriptionTemplatesInSectionEditorModel(this.validationErrorModel); const descriptionTemplate: DescriptionTemplatesInSectionEditorModel = new DescriptionTemplatesInSectionEditorModel(this.validationErrorModel);
descriptionTemplate.id = Guid.create(); // descriptionTemplate.id = Guid.create();
descriptionTemplate.descriptionTemplateId = item.id; descriptionTemplate.descriptionTemplateGroupId = item.descriptionTemplateGroupId;
descriptionTemplate.label = item.label; descriptionTemplate.label = item.label;
return descriptionTemplate.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].descriptionTemplates[' + index + '].' }); return descriptionTemplate.buildForm({ rootPath: 'definition.sections[' + sectionIndex + '].descriptionTemplates[' + index + '].' });
} }
@ -419,8 +419,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
} }
export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemplatesInSectionPersist { export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemplatesInSectionPersist {
id: Guid; descriptionTemplateGroupId: Guid;
descriptionTemplateId: Guid;
label: string; label: string;
minMultiplicity: number; minMultiplicity: number;
maxMultiplicity: number; maxMultiplicity: number;
@ -432,8 +431,7 @@ export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemp
) { } ) { }
fromModel(item: DescriptionTemplatesInSection): DescriptionTemplatesInSectionEditorModel { fromModel(item: DescriptionTemplatesInSection): DescriptionTemplatesInSectionEditorModel {
this.id = item.id; this.descriptionTemplateGroupId = item.descriptionTemplateGroupId;
this.descriptionTemplateId = item.descriptionTemplateId;
this.label = item.label; this.label = item.label;
this.minMultiplicity = item.minMultiplicity; this.minMultiplicity = item.minMultiplicity;
this.maxMultiplicity = item.maxMultiplicity; this.maxMultiplicity = item.maxMultiplicity;
@ -454,8 +452,7 @@ export class DescriptionTemplatesInSectionEditorModel implements DescriptionTemp
} }
return this.formBuilder.group({ return this.formBuilder.group({
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], descriptionTemplateGroupId: [{ value: this.descriptionTemplateGroupId, disabled: disabled }, context.getValidation('descriptionTemplateGroupId').validators],
descriptionTemplateId: [{ value: this.descriptionTemplateId, disabled: disabled }, context.getValidation('descriptionTemplateId').validators],
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
minMultiplicity: [{ value: this.minMultiplicity, disabled: disabled }, context.getValidation('minMultiplicity').validators], minMultiplicity: [{ value: this.minMultiplicity, disabled: disabled }, context.getValidation('minMultiplicity').validators],
maxMultiplicity: [{ value: this.maxMultiplicity, disabled: disabled }, context.getValidation('maxMultiplicity').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 baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>(); const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] }); baseValidationArray.push({ key: 'descriptionTemplateGroupId', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplateGroupId`)] });
baseValidationArray.push({ key: 'descriptionTemplateId', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplateId`)] });
baseValidationArray.push({ key: 'label', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] }); baseValidationArray.push({ key: 'label', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'minMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}minMultiplicity`)] }); baseValidationArray.push({ key: 'minMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}minMultiplicity`)] });
baseValidationArray.push({ key: 'maxMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}maxMultiplicity`)] }); baseValidationArray.push({ key: 'maxMultiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}maxMultiplicity`)] });

View File

@ -39,8 +39,7 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver {
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'), [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'), [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'), [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateGroupId)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'), [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'), [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'), [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),

View File

@ -37,8 +37,8 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'), [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'), [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'), [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'), // [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'), [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateGroupId)].join('.'),
// [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'), // [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
// [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'), // [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
// [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'), // [nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),

View File

@ -56,7 +56,7 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel(this.validationErrorModel).fromModel( this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel(this.validationErrorModel).fromModel(
{ {
sectionId: section.id, sectionId: section.id,
descriptionTemplateGroupId: blueprintDefinedDescriptionTemplate?.descriptionTemplateId, descriptionTemplateGroupId: blueprintDefinedDescriptionTemplate?.descriptionTemplateGroupId,
})); }));
}); });
} else { } else {

View File

@ -89,8 +89,7 @@ export class DmpEditorResolver extends BaseEditorResolver {
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateGroupId)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),