215 lines
6.6 KiB
Java
215 lines
6.6 KiB
Java
package eu.eudat.file.transformer.entities.descriptiontemplate;
|
|
import eu.eudat.file.transformer.entities.common.DatabaseViewStyleDefinition;
|
|
import eu.eudat.file.transformer.entities.definition.DefinitionSerializable;
|
|
import eu.eudat.file.transformer.entities.xml.XmlBuilder;
|
|
import eu.eudat.file.transformer.entities.xml.XmlSerializable;
|
|
import eu.eudat.file.transformer.model.descriptiontemplatedefinition.FieldSet;
|
|
import eu.eudat.file.transformer.model.descriptiontemplatedefinition.Section;
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Element;
|
|
import org.w3c.dom.Node;
|
|
import org.w3c.dom.NodeList;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
|
|
public class SectionEntity implements DatabaseViewStyleDefinition, DefinitionSerializable<SectionEntity, Section> {
|
|
private String id;
|
|
private int ordinal;
|
|
private boolean defaultVisibility;
|
|
private String numbering;
|
|
private String page;
|
|
private String title;
|
|
private String description;
|
|
private String extendedDescription;
|
|
private List<SectionEntity> sections;
|
|
private List<FieldSetEntity> fieldSets;
|
|
private Boolean multiplicity;
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public int getOrdinal() {
|
|
return ordinal;
|
|
}
|
|
|
|
public void setOrdinal(int ordinal) {
|
|
this.ordinal = ordinal;
|
|
}
|
|
|
|
public boolean isDefaultVisibility() {
|
|
return defaultVisibility;
|
|
}
|
|
|
|
public void setDefaultVisibility(boolean defaultVisibility) {
|
|
this.defaultVisibility = defaultVisibility;
|
|
}
|
|
|
|
public String getPage() {
|
|
return page;
|
|
}
|
|
|
|
public void setPage(String page) {
|
|
this.page = page;
|
|
}
|
|
|
|
public String getTitle() {
|
|
return title;
|
|
}
|
|
|
|
public void setTitle(String title) {
|
|
this.title = title;
|
|
}
|
|
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
|
|
public void setDescription(String description) {
|
|
this.description = description;
|
|
}
|
|
|
|
public List<SectionEntity> getSections() {
|
|
return sections;
|
|
}
|
|
|
|
public void setSections(List<SectionEntity> sections) {
|
|
this.sections = sections;
|
|
}
|
|
|
|
public List<FieldSetEntity> getFieldSets() {
|
|
return fieldSets;
|
|
}
|
|
|
|
public void setFieldSets(List<FieldSetEntity> fieldSetEntities) {
|
|
this.fieldSets = fieldSetEntities;
|
|
}
|
|
|
|
public String getExtendedDescription() {
|
|
return extendedDescription;
|
|
}
|
|
|
|
public void setExtendedDescription(String extendedDescription) {
|
|
this.extendedDescription = extendedDescription;
|
|
}
|
|
|
|
public String getNumbering() {
|
|
return numbering;
|
|
}
|
|
|
|
public void setNumbering(String numbering) {
|
|
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");
|
|
rootElement.setAttribute("id", this.id);
|
|
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);
|
|
|
|
Element extendedDescription = doc.createElement("extendedDescription");
|
|
extendedDescription.setTextContent(this.extendedDescription);
|
|
|
|
Element numbering = doc.createElement("numbering");
|
|
numbering.setTextContent(this.numbering);
|
|
|
|
Element title = doc.createElement("title");
|
|
title.setTextContent(this.title);
|
|
|
|
if (sections != null) {
|
|
Element sections = doc.createElement("sections");
|
|
for (SectionEntity sectionEntity : this.sections) {
|
|
sectionEntity.setNumbering(this.numbering + "." + (this.sections.indexOf(sectionEntity) + 1));
|
|
sections.appendChild(sectionEntity.toXml(doc));
|
|
}
|
|
rootElement.appendChild(sections);
|
|
}
|
|
|
|
if (this.fieldSets != null) {
|
|
Element formGroups = doc.createElement("fieldSets");
|
|
for (FieldSetEntity fieldSetEntity : this.fieldSets) {
|
|
fieldSetEntity.setNumbering(this.numbering + "." + (this.fieldSets.indexOf(fieldSetEntity) + 1));
|
|
formGroups.appendChild(fieldSetEntity.toXml(doc));
|
|
}
|
|
rootElement.appendChild(formGroups);
|
|
}
|
|
|
|
rootElement.appendChild(numbering);
|
|
rootElement.appendChild(title);
|
|
rootElement.appendChild(extendedDescription);
|
|
rootElement.appendChild(description);
|
|
|
|
return rootElement;
|
|
}*/
|
|
|
|
public List<FieldEntity> getFieldById(String id){
|
|
List<FieldEntity> fieldEntities = new ArrayList<>();
|
|
if (id == null || id.isBlank()) return fieldEntities;
|
|
if (this.getFieldSets() != null){
|
|
for (FieldSetEntity fieldSetEntity: this.getFieldSets()) {
|
|
fieldEntities.addAll(fieldSetEntity.getFieldById(id));
|
|
}
|
|
}
|
|
if (this.getSections() != null){
|
|
for (SectionEntity sectionEntity: this.getSections()) {
|
|
fieldEntities.addAll(sectionEntity.getFieldById(id));
|
|
}
|
|
}
|
|
return fieldEntities;
|
|
}
|
|
|
|
@Override
|
|
public SectionEntity fromDefinition(Section object) {
|
|
this.id = object.getId();
|
|
this.ordinal = object.getOrdinal();
|
|
this.defaultVisibility = object.getDefaultVisibility();
|
|
this.page = object.getPage();
|
|
this.multiplicity = object.getMultiplicity();
|
|
|
|
this.description = object.getDescription();
|
|
|
|
this.extendedDescription = object.getExtendedDescription();
|
|
|
|
this.numbering = object.getNumbering();
|
|
|
|
this.title = object.getTitle();
|
|
|
|
if (object.getSections() != null) {
|
|
this.sections = new LinkedList<>();
|
|
for (Section section: object.getSections()) {
|
|
this.sections.add(new SectionEntity().fromDefinition(section));
|
|
}
|
|
}
|
|
|
|
|
|
if (object.getFieldSets() != null) {
|
|
this.fieldSets = new LinkedList<>();
|
|
for (FieldSet fieldSet: object.getFieldSets()) {
|
|
this.fieldSets.add(new FieldSetEntity().fromDefinition(fieldSet));
|
|
}
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}
|