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)
public class DescriptionTemplateEntity implements XmlSerializable<DescriptionTemplateEntity> {
@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<DescriptionTem
@XmlAttribute(name="maxMultiplicity")
private Integer maxMultiplicity;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
public UUID getDescriptionTemplateGroupId() {
return descriptionTemplateGroupId;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
this.descriptionTemplateGroupId = descriptionTemplateGroupId;
}
public String getLabel() {
@ -61,8 +53,7 @@ public class DescriptionTemplateEntity implements XmlSerializable<DescriptionTem
@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("descriptionTemplateGroupId", this.getDescriptionTemplateGroupId().toString());
rootElement.setAttribute("label", this.label);
rootElement.setAttribute("minMultiplicity", String.valueOf(this.minMultiplicity));
rootElement.setAttribute("maxMultiplicity", String.valueOf(this.maxMultiplicity));
@ -71,8 +62,7 @@ public class DescriptionTemplateEntity implements XmlSerializable<DescriptionTem
@Override
public DescriptionTemplateEntity fromXml(Element item) {
this.id = UUID.fromString(item.getAttribute("id"));
this.descriptionTemplateId = UUID.fromString(item.getAttribute("descriptionTemplateId"));
this.descriptionTemplateGroupId = UUID.fromString(item.getAttribute("descriptionTemplateGroupId"));
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;

View File

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

View File

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

View File

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

View File

@ -16,13 +16,9 @@ import java.util.UUID;
public class DescriptionTemplatePersist {
private UUID id = null;
private UUID descriptionTemplateGroupId = null;
public static final String _id = "id";
private UUID descriptionTemplateId = null;
public static final String _descriptionTemplateId = "descriptionTemplateId";
public static final String _descriptionTemplateGroupId = "descriptionTemplateGroupId";
private String label = null;
@ -36,20 +32,12 @@ public class DescriptionTemplatePersist {
public static final String _maxMultiplicity = "maxMultiplicity";
public UUID getId() {
return id;
public UUID getDescriptionTemplateGroupId() {
return descriptionTemplateGroupId;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
public void setDescriptionTemplateGroupId(UUID descriptionTemplateGroupId) {
this.descriptionTemplateGroupId = descriptionTemplateGroupId;
}
public String getLabel() {
@ -98,11 +86,8 @@ public class DescriptionTemplatePersist {
protected List<Specification> 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()))
);
}
}

View File

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