2018-01-03 11:44:54 +01:00
|
|
|
package eu.eudat.entities.xmlmodels.datasetprofiledefinition;
|
2017-11-30 11:10:42 +01:00
|
|
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
import org.w3c.dom.Element;
|
|
|
|
import org.w3c.dom.Node;
|
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
import eu.eudat.utilities.XmlSerializable;
|
|
|
|
import eu.eudat.utilities.builders.XmlBuilder;
|
2017-11-30 11:10:42 +01:00
|
|
|
|
2018-01-19 10:31:05 +01:00
|
|
|
public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
|
|
|
|
private List<Section> sections;
|
|
|
|
private List<Page> pages;
|
|
|
|
|
|
|
|
public List<Section> getSections() {
|
|
|
|
return sections;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSections(List<Section> sections) {
|
|
|
|
this.sections = sections;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Page> getPages() {
|
|
|
|
return pages;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPages(List<Page> pages) {
|
|
|
|
this.pages = pages;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Element toXml(Document doc) {
|
|
|
|
Element root = doc.createElement("root");
|
|
|
|
Element sections = doc.createElement("sections");
|
|
|
|
Element pages = doc.createElement("pages");
|
|
|
|
for (Section section : this.sections) {
|
|
|
|
sections.appendChild(section.toXml(doc));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Page page : this.pages) {
|
|
|
|
pages.appendChild(page.toXml(doc));
|
|
|
|
}
|
|
|
|
|
|
|
|
root.appendChild(pages);
|
|
|
|
root.appendChild(sections);
|
|
|
|
return root;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ViewStyleModel fromXml(Element element) {
|
|
|
|
|
|
|
|
this.sections = new LinkedList();
|
|
|
|
Element sections = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
|
|
|
|
if (sections != null) {
|
|
|
|
NodeList sectionElements = sections.getChildNodes();
|
|
|
|
for (int temp = 0; temp < sectionElements.getLength(); temp++) {
|
|
|
|
Node sectionElement = sectionElements.item(temp);
|
|
|
|
if (sectionElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
|
|
this.sections.add(new Section().fromXml((Element) sectionElement));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.pages = new LinkedList<>();
|
|
|
|
Element pages = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"pages");
|
|
|
|
if(pages!=null){
|
2018-01-19 12:11:22 +01:00
|
|
|
NodeList pagesElements = pages.getChildNodes();
|
2018-01-19 10:31:05 +01:00
|
|
|
for (int temp = 0; temp < pagesElements.getLength(); temp++) {
|
|
|
|
Node pageElement = pagesElements.item(temp);
|
|
|
|
if (pageElement.getNodeType() == Node.ELEMENT_NODE) {
|
|
|
|
this.pages.add(new Page().fromXml((Element) pageElement));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-30 11:10:42 +01:00
|
|
|
}
|