2018-06-27 12:29:21 +02:00
|
|
|
package eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition;
|
2017-11-30 11:10:42 +01:00
|
|
|
|
2018-06-27 12:29:21 +02:00
|
|
|
import eu.eudat.models.data.components.commons.Multiplicity;
|
|
|
|
import eu.eudat.logic.utilities.interfaces.XmlSerializable;
|
|
|
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
2017-11-30 11:10:42 +01:00
|
|
|
import org.w3c.dom.Document;
|
|
|
|
import org.w3c.dom.Element;
|
|
|
|
import org.w3c.dom.Node;
|
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class FieldSet implements DatabaseViewStyleDefinition, XmlSerializable<FieldSet> {
|
|
|
|
private String id;
|
|
|
|
private int ordinal;
|
|
|
|
private List<Field> fields;
|
2018-10-18 11:34:11 +02:00
|
|
|
private String numbering;
|
2018-02-16 11:34:02 +01:00
|
|
|
private String title;
|
|
|
|
private String description;
|
|
|
|
private String extendedDescription;
|
2019-03-07 11:04:54 +01:00
|
|
|
private String additionalInformation;
|
2018-02-16 11:34:02 +01:00
|
|
|
private Multiplicity multiplicity;
|
|
|
|
private boolean hasCommentField;
|
|
|
|
private String commentFieldValue;
|
|
|
|
|
|
|
|
public List<Field> getFields() {
|
|
|
|
return fields;
|
|
|
|
}
|
|
|
|
public void setFields(List<Field> fields) {
|
|
|
|
this.fields = fields;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 Multiplicity getMultiplicity() {
|
|
|
|
return multiplicity;
|
|
|
|
}
|
|
|
|
public void setMultiplicity(Multiplicity 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;
|
|
|
|
}
|
|
|
|
|
2018-10-18 11:34:11 +02:00
|
|
|
public String getNumbering() {
|
|
|
|
return numbering;
|
|
|
|
}
|
|
|
|
public void setNumbering(String numbering) {
|
|
|
|
this.numbering = numbering;
|
|
|
|
}
|
|
|
|
|
2019-03-07 11:04:54 +01:00
|
|
|
public String getAdditionalInformation() {
|
|
|
|
return additionalInformation;
|
|
|
|
}
|
|
|
|
public void setAdditionalInformation(String additionalInformation) {
|
|
|
|
this.additionalInformation = additionalInformation;
|
|
|
|
}
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
@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);
|
|
|
|
|
2019-03-07 11:04:54 +01:00
|
|
|
Element additionalInformation = doc.createElement("additionalInformation");
|
|
|
|
additionalInformation.setTextContent(this.additionalInformation);
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
Element multiplicity = doc.createElement("multiplicity");
|
|
|
|
multiplicity.setAttribute("min", "" + this.multiplicity.getMin());
|
|
|
|
multiplicity.setAttribute("max", "" + this.multiplicity.getMax());
|
|
|
|
|
|
|
|
Element commentField = doc.createElement("commentField");
|
|
|
|
commentField.setAttribute("hasCommentField", "" + this.hasCommentField);
|
|
|
|
commentField.setAttribute("commentFieldValue", this.commentFieldValue);
|
|
|
|
|
2018-10-18 11:34:11 +02:00
|
|
|
Element numbering = doc.createElement("numbering");
|
|
|
|
numbering.setTextContent(this.numbering);
|
2018-02-16 11:34:02 +01:00
|
|
|
|
|
|
|
Element fieldsElement = doc.createElement("fields");
|
|
|
|
for (Field field : fields) {
|
2018-10-18 11:34:11 +02:00
|
|
|
field.setNumbering(this.numbering + "." + (this.fields.indexOf(field) + 1));
|
2018-02-16 11:34:02 +01:00
|
|
|
fieldsElement.appendChild(field.toXml(doc));
|
|
|
|
}
|
2018-10-18 11:34:11 +02:00
|
|
|
|
|
|
|
fieldSet.appendChild(numbering);
|
2018-02-16 11:34:02 +01:00
|
|
|
fieldSet.appendChild(commentField);
|
|
|
|
fieldSet.appendChild(fieldsElement);
|
|
|
|
fieldSet.appendChild(multiplicity);
|
|
|
|
fieldSet.appendChild(title);
|
|
|
|
fieldSet.appendChild(description);
|
|
|
|
fieldSet.appendChild(extendedDescription);
|
2019-03-07 11:04:54 +01:00
|
|
|
fieldSet.appendChild(additionalInformation);
|
2018-02-16 11:34:02 +01:00
|
|
|
return fieldSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FieldSet fromXml(Element element) {
|
|
|
|
this.id = element.getAttribute("id");
|
|
|
|
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
|
|
|
this.fields = new LinkedList();
|
2019-10-15 12:38:51 +02:00
|
|
|
Element title = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "title");
|
2018-02-16 11:34:02 +01:00
|
|
|
this.title = title.getTextContent();
|
2019-10-15 12:38:51 +02:00
|
|
|
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
|
2018-02-16 11:34:02 +01:00
|
|
|
this.description = description.getTextContent();
|
2019-10-15 12:38:51 +02:00
|
|
|
Element extendedDescription = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "extendedDescription");
|
2018-02-16 11:34:02 +01:00
|
|
|
this.extendedDescription = extendedDescription.getTextContent();
|
2019-10-15 12:38:51 +02:00
|
|
|
Element additionalInformation = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "additionalInformation");
|
2019-03-07 11:04:54 +01:00
|
|
|
if (additionalInformation != null)
|
|
|
|
this.additionalInformation = additionalInformation.getTextContent();
|
2019-10-15 12:38:51 +02:00
|
|
|
Element commentField = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "commentField");
|
2018-02-16 11:34:02 +01:00
|
|
|
this.hasCommentField = Boolean.parseBoolean(commentField.getAttribute("hasCommentField"));
|
|
|
|
this.commentFieldValue = commentField.getAttribute("commentFieldValue");
|
2019-10-15 12:38:51 +02:00
|
|
|
Element fields = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "fields");
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2018-10-18 11:34:11 +02:00
|
|
|
Element numbering = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "numbering");
|
|
|
|
if (numbering != null) this.numbering = numbering.getTextContent();
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
if (fields != null) {
|
|
|
|
NodeList fieldElements = fields.getChildNodes();
|
|
|
|
for (int temp = 0; temp < fieldElements.getLength(); temp++) {
|
|
|
|
Node fieldElement = fieldElements.item(temp);
|
|
|
|
if (fieldElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
|
|
this.fields.add(new Field().fromXml((Element) fieldElement));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.multiplicity = new Multiplicity();
|
2019-10-15 12:38:51 +02:00
|
|
|
Element multiplicity = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "multiplicity");
|
2018-02-16 11:34:02 +01:00
|
|
|
|
|
|
|
this.multiplicity.setMin(Integer.parseInt(multiplicity.getAttribute("min")));
|
|
|
|
this.multiplicity.setMax(Integer.parseInt(multiplicity.getAttribute("max")));
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2017-11-30 11:10:42 +01:00
|
|
|
}
|