190 lines
6.8 KiB
Java
190 lines
6.8 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.Field;
|
||
|
import eu.eudat.file.transformer.model.descriptiontemplatedefinition.FieldSet;
|
||
|
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 FieldSetEntity implements DatabaseViewStyleDefinition, DefinitionSerializable<FieldSetEntity, FieldSet> {
|
||
|
private String id;
|
||
|
private int ordinal;
|
||
|
private List<FieldEntity> fields;
|
||
|
private String numbering;
|
||
|
private String title;
|
||
|
private String description;
|
||
|
private String extendedDescription;
|
||
|
private String additionalInformation;
|
||
|
private MultiplicityEntity multiplicity;
|
||
|
private boolean hasCommentField;
|
||
|
// private String commentFieldValue; //TODO: DescriptionTemplate
|
||
|
|
||
|
public List<FieldEntity> getFields() {
|
||
|
return fields;
|
||
|
}
|
||
|
public void setFields(List<FieldEntity> fieldEntities) {
|
||
|
this.fields = fieldEntities;
|
||
|
}
|
||
|
|
||
|
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 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 String getExtendedDescription() {
|
||
|
return extendedDescription;
|
||
|
}
|
||
|
public void setExtendedDescription(String extendedDescription) {
|
||
|
this.extendedDescription = extendedDescription;
|
||
|
}
|
||
|
|
||
|
public MultiplicityEntity getMultiplicity() {
|
||
|
return multiplicity;
|
||
|
}
|
||
|
public void setMultiplicity(MultiplicityEntity multiplicity) {
|
||
|
this.multiplicity = multiplicity;
|
||
|
}
|
||
|
|
||
|
public boolean getHasCommentField() {
|
||
|
return hasCommentField;
|
||
|
}
|
||
|
public void setHasCommentField(boolean hasCommentField) {
|
||
|
this.hasCommentField = hasCommentField;
|
||
|
}
|
||
|
|
||
|
// public String getCommentFieldValue() {
|
||
|
// return commentFieldValue;
|
||
|
// }
|
||
|
// public void setCommentFieldValue(String commentFieldValue) {
|
||
|
// this.commentFieldValue = commentFieldValue;
|
||
|
// }
|
||
|
|
||
|
public String getNumbering() {
|
||
|
return numbering;
|
||
|
}
|
||
|
public void setNumbering(String numbering) {
|
||
|
this.numbering = numbering;
|
||
|
}
|
||
|
|
||
|
public String getAdditionalInformation() {
|
||
|
return additionalInformation;
|
||
|
}
|
||
|
public void setAdditionalInformation(String additionalInformation) {
|
||
|
this.additionalInformation = additionalInformation;
|
||
|
}
|
||
|
|
||
|
/* @Override
|
||
|
public Element toXml(Document doc) {
|
||
|
Element fieldSet = doc.createElement("fieldSet");
|
||
|
fieldSet.setAttribute("id", this.id);
|
||
|
fieldSet.setAttribute("ordinal", "" + this.ordinal);
|
||
|
Element title = doc.createElement("title");
|
||
|
title.setTextContent(this.title);
|
||
|
|
||
|
Element description = doc.createElement("description");
|
||
|
description.setTextContent(this.description);
|
||
|
|
||
|
Element extendedDescription = doc.createElement("extendedDescription");
|
||
|
extendedDescription.setTextContent(this.extendedDescription);
|
||
|
|
||
|
Element additionalInformation = doc.createElement("additionalInformation");
|
||
|
additionalInformation.setTextContent(this.additionalInformation);
|
||
|
|
||
|
Element multiplicity = doc.createElement("multiplicity");
|
||
|
multiplicity.setAttribute("min", "" + this.multiplicity.getMin());
|
||
|
multiplicity.setAttribute("max", "" + this.multiplicity.getMax());
|
||
|
multiplicity.setAttribute("placeholder", this.multiplicity.getPlaceholder());
|
||
|
multiplicity.setAttribute("tableView", String.valueOf(this.multiplicity.getTableView()));
|
||
|
|
||
|
Element commentField = doc.createElement("commentField");
|
||
|
commentField.setAttribute("hasCommentField", "" + this.hasCommentField);
|
||
|
// commentField.setAttribute("commentFieldValue", this.commentFieldValue);
|
||
|
|
||
|
Element numbering = doc.createElement("numbering");
|
||
|
numbering.setTextContent(this.numbering);
|
||
|
|
||
|
Element fieldsElement = doc.createElement("fields");
|
||
|
for (FieldEntity fieldEntity : fields) {
|
||
|
fieldEntity.setNumbering(this.numbering + "." + (this.fields.indexOf(fieldEntity) + 1));
|
||
|
fieldsElement.appendChild(fieldEntity.toXml(doc));
|
||
|
}
|
||
|
|
||
|
fieldSet.appendChild(numbering);
|
||
|
fieldSet.appendChild(commentField);
|
||
|
fieldSet.appendChild(fieldsElement);
|
||
|
fieldSet.appendChild(multiplicity);
|
||
|
fieldSet.appendChild(title);
|
||
|
fieldSet.appendChild(description);
|
||
|
fieldSet.appendChild(extendedDescription);
|
||
|
fieldSet.appendChild(additionalInformation);
|
||
|
return fieldSet;
|
||
|
}*/
|
||
|
|
||
|
public List<FieldEntity> getFieldById(String id){
|
||
|
if (this.getFields() == null || id == null || id.isBlank()) return new ArrayList<>();
|
||
|
|
||
|
return this.getFields().stream().filter(x-> id.equals(x.getId())).toList();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public FieldSetEntity fromDefinition(FieldSet object) {
|
||
|
this.id = object.getId();
|
||
|
this.ordinal = object.getOrdinal();
|
||
|
this.fields = new LinkedList();
|
||
|
this.title = object.getTitle();
|
||
|
this.description = object.getDescription();
|
||
|
this.extendedDescription = object.getExtendedDescription();
|
||
|
if (object.getAdditionalInformation() != null)
|
||
|
this.additionalInformation = object.getAdditionalInformation();
|
||
|
this.hasCommentField = object.getHasCommentField();
|
||
|
// this.commentFieldValue = commentField.getAttribute("commentFieldValue");
|
||
|
this.numbering = object.getNumbering();
|
||
|
|
||
|
if (object.getFields() != null) {
|
||
|
for (Field field: object.getFields()) {
|
||
|
this.fields.add(new FieldEntity().fromDefinition(field));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (object.getMultiplicity() != null) {
|
||
|
this.multiplicity = new MultiplicityEntity();
|
||
|
this.multiplicity.setMin(object.getMultiplicity().getMin());
|
||
|
this.multiplicity.setMax(object.getMultiplicity().getMax());
|
||
|
this.multiplicity.setPlaceholder(object.getMultiplicity().getPlaceholder());
|
||
|
this.multiplicity.setTableView(object.getMultiplicity().getTableView());
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
}
|