Add multiplicity field on Sections

This commit is contained in:
George Kalampokis 2022-01-31 11:15:23 +02:00
parent 1c318ddff5
commit eaa0c67177
5 changed files with 55 additions and 0 deletions

View File

@ -18,6 +18,7 @@ public class Section {
private String extendedDescription;
private String title;
private List<Section> section;
private Boolean multiplicity;
@XmlAttribute(name = "id")
public String getId() {
@ -134,4 +135,13 @@ public class Section {
public void setSection(List<Section> section) {
this.section = section;
}
@XmlAttribute(name = "multiplicity")
public Boolean getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Boolean multiplicity) {
this.multiplicity = multiplicity;
}
}

View File

@ -18,6 +18,7 @@ public class Sections {
private String title;
private List<Section> section;
private FieldSets fieldSets;
private Boolean multiplicity;
@XmlAttribute(name = "id")
public String getId() {
@ -100,6 +101,15 @@ public class Sections {
this.fieldSets = fieldSets;
}
@XmlAttribute(name = "multiplicity")
public Boolean getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Boolean multiplicity) {
this.multiplicity = multiplicity;
}
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection() {
eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity = new eu.eudat.models.data.admin.components.datasetprofile.Section();
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionsListEntity = new LinkedList<>();
@ -118,6 +128,7 @@ public class Sections {
sectionEntity.setDescription(description);
sectionEntity.setPage(this.page);
sectionEntity.setFieldSets(toAdminCompositeModelSectionFieldSets());
sectionEntity.setMultiplicity(this.multiplicity);
sectionEntity.setSections(sectionsListEntity);

View File

@ -16,6 +16,7 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
private String id;
private String title;
private String description;
private Boolean multiplicity;
public List<Section> getSections() {
return sections;
@ -81,11 +82,20 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
this.ordinal = ordinal;
}
public Boolean getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Boolean multiplicity) {
this.multiplicity = multiplicity;
}
@Override
public eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section toDatabaseDefinition(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section item) {
if (this.id == null || this.id.isEmpty()) this.id = "section_" + RandomStringUtils.random(5, true, true);
item.setDefaultVisibility(this.defaultVisibility);
item.setDescription(this.description);
item.setMultiplicity(this.multiplicity);
if (this.fieldSets != null)
item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.fieldSets, eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.FieldSet.class));
item.setId(this.id);
@ -108,6 +118,7 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
this.page = item.getPage();
this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(), Section.class);
this.title = item.getTitle();
this.multiplicity = item.getMultiplicity();
}
@Override
@ -134,6 +145,7 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
shortenSection.setId(this.id);
shortenSection.setTitle(this.title);
shortenSection.setDescription(this.description);
shortenSection.setMultiplicity(this.multiplicity);
return shortenSection;
}

View File

@ -21,6 +21,7 @@ public class Section implements DatabaseViewStyleDefinition, XmlSerializable<Sec
private String extendedDescription;
private List<Section> sections;
private List<FieldSet> fieldSets;
private Boolean multiplicity;
public String getId() {
return id;
@ -102,6 +103,14 @@ public class Section implements DatabaseViewStyleDefinition, XmlSerializable<Sec
this.numbering = numbering;
}
public Boolean getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Boolean multiplicity) {
this.multiplicity = multiplicity;
}
@Override
public Element toXml(Document doc) {
Element rootElement = doc.createElement("section");
@ -109,6 +118,7 @@ public class Section implements DatabaseViewStyleDefinition, XmlSerializable<Sec
rootElement.setAttribute("ordinal", "" + this.ordinal);
rootElement.setAttribute("defaultVisibility", "" + this.defaultVisibility);
rootElement.setAttribute("page", "" + this.page);
rootElement.setAttribute("multiplicity", (this.multiplicity != null ? "" + this.multiplicity : "false"));
Element description = doc.createElement("description");
description.setTextContent(this.description);
@ -155,6 +165,7 @@ public class Section implements DatabaseViewStyleDefinition, XmlSerializable<Sec
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
this.defaultVisibility = Boolean.valueOf(element.getAttribute("defaultVisibility"));
this.page = element.getAttribute("page");
this.multiplicity = element.hasAttribute("multiplicity") ? Boolean.valueOf(element.getAttribute("multiplicity")) : false;
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
if (description != null) this.description = description.getTextContent();

View File

@ -19,6 +19,7 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
private String id;
private String title;
private String description;
private Boolean multiplicity;
public List<Section> getSections() {
Collections.sort(sections);
@ -94,6 +95,14 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
this.numbering = numbering;
}
public Boolean getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Boolean multiplicity) {
this.multiplicity = multiplicity;
}
@Override
public eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section toDatabaseDefinition(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section item) {
item.setDefaultVisibility(this.defaultVisibility);
@ -106,6 +115,7 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
if (this.sections != null)
item.setSections(new ModelBuilder().toViewStyleDefinition(this.sections, eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section.class));
item.setTitle(this.title);
item.setMultiplicity(this.multiplicity);
return item;
}
@ -120,6 +130,7 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
this.page = item.getPage();
this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(), Section.class);
this.title = item.getTitle();
this.multiplicity = item.getMultiplicity();
}
@Override