2018-01-03 11:44:54 +01:00
|
|
|
package eu.eudat.entities.xmlmodels.datasetprofiledefinition;
|
2017-11-30 11:10:42 +01:00
|
|
|
|
2018-01-03 11:44:54 +01:00
|
|
|
import eu.eudat.models.components.commons.Multiplicity;
|
2018-03-01 10:14:10 +01:00
|
|
|
import eu.eudat.utilities.interfaces.XmlSerializable;
|
2018-02-16 11:34:02 +01:00
|
|
|
import eu.eudat.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;
|
|
|
|
private String title;
|
|
|
|
private String description;
|
|
|
|
private String extendedDescription;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 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);
|
|
|
|
|
|
|
|
|
|
|
|
Element fieldsElement = doc.createElement("fields");
|
|
|
|
for (Field field : fields) {
|
|
|
|
fieldsElement.appendChild(field.toXml(doc));
|
|
|
|
}
|
|
|
|
fieldSet.appendChild(commentField);
|
|
|
|
fieldSet.appendChild(fieldsElement);
|
|
|
|
fieldSet.appendChild(multiplicity);
|
|
|
|
fieldSet.appendChild(title);
|
|
|
|
fieldSet.appendChild(description);
|
|
|
|
fieldSet.appendChild(extendedDescription);
|
|
|
|
return fieldSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FieldSet fromXml(Element element) {
|
|
|
|
this.id = element.getAttribute("id");
|
|
|
|
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
|
|
|
this.fields = new LinkedList();
|
|
|
|
Element title = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "title");
|
|
|
|
this.title = title.getTextContent();
|
|
|
|
Element description = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
|
|
|
|
this.description = description.getTextContent();
|
|
|
|
Element extendedDescription = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "extendedDescription");
|
|
|
|
this.extendedDescription = extendedDescription.getTextContent();
|
|
|
|
Element commentField = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "commentField");
|
|
|
|
this.hasCommentField = Boolean.parseBoolean(commentField.getAttribute("hasCommentField"));
|
|
|
|
this.commentFieldValue = commentField.getAttribute("commentFieldValue");
|
|
|
|
Element fields = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "fields");
|
|
|
|
|
|
|
|
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();
|
|
|
|
Element multiplicity = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "multiplicity");
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
}
|