change blueprint to user description template group id

This commit is contained in:
Efstratios Giannopoulos 2024-01-26 11:41:20 +02:00
parent 447059530d
commit c05ccef28e
6 changed files with 32 additions and 91 deletions

View File

@ -12,10 +12,8 @@ import java.util.UUID;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class DescriptionTemplateEntity implements XmlSerializable<DescriptionTemplateEntity> { public class DescriptionTemplateEntity implements XmlSerializable<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() {
@ -61,8 +53,7 @@ public class DescriptionTemplateEntity implements XmlSerializable<DescriptionTem
@Override @Override
public Element toXml(Document doc) { public Element toXml(Document doc) {
Element rootElement = doc.createElement("descriptionTemplate"); Element rootElement = doc.createElement("descriptionTemplate");
rootElement.setAttribute("id", this.getId().toString()); rootElement.setAttribute("descriptionTemplateGroupId", this.getDescriptionTemplateGroupId().toString());
rootElement.setAttribute("descriptionTemplateId", this.getDescriptionTemplateId().toString());
rootElement.setAttribute("label", this.label); rootElement.setAttribute("label", this.label);
rootElement.setAttribute("minMultiplicity", String.valueOf(this.minMultiplicity)); rootElement.setAttribute("minMultiplicity", String.valueOf(this.minMultiplicity));
rootElement.setAttribute("maxMultiplicity", String.valueOf(this.maxMultiplicity)); rootElement.setAttribute("maxMultiplicity", String.valueOf(this.maxMultiplicity));
@ -71,8 +62,7 @@ public class DescriptionTemplateEntity implements XmlSerializable<DescriptionTem
@Override @Override
public DescriptionTemplateEntity fromXml(Element item) { public DescriptionTemplateEntity fromXml(Element item) {
this.id = UUID.fromString(item.getAttribute("id")); this.descriptionTemplateGroupId = UUID.fromString(item.getAttribute("descriptionTemplateGroupId"));
this.descriptionTemplateId = UUID.fromString(item.getAttribute("descriptionTemplateId"));
this.label = item.getAttribute("label"); this.label = item.getAttribute("label");
this.minMultiplicity = item.hasAttribute("minMultiplicity") && !item.getAttribute("minMultiplicity").equals("null") ? Integer.parseInt(item.getAttribute("minMultiplicity")) : null; 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; this.maxMultiplicity = item.hasAttribute("maxMultiplicity") && !item.getAttribute("minMultiplicity").equals("null") ? Integer.parseInt(item.getAttribute("maxMultiplicity")) : null;

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());