fixed error with fields missing
This commit is contained in:
parent
21df6ccdd1
commit
955f902a13
|
@ -8,6 +8,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
|||
import models.components.commons.DefaultValue;
|
||||
import models.components.commons.Multiplicity;
|
||||
import utilities.XmlSerializable;
|
||||
import utilities.builders.XmlBuilder;
|
||||
|
||||
public class Field implements DatabaseModelDefinition,XmlSerializable<Field>{
|
||||
|
||||
|
@ -75,12 +76,14 @@ public class Field implements DatabaseModelDefinition,XmlSerializable<Field>{
|
|||
this.datatype = item.getAttribute("datatype");
|
||||
|
||||
this.defaultValue = new DefaultValue();
|
||||
Element defaultValue = (Element)item.getElementsByTagName("defaultValue").item(0);
|
||||
Element defaultValue = (Element)XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "defaultValue");
|
||||
|
||||
this.defaultValue.setType(defaultValue.getAttribute("type"));
|
||||
this.defaultValue.setValue(defaultValue.getAttribute("value"));
|
||||
|
||||
this.multiplicity = new Multiplicity();
|
||||
Element multiplicity = (Element)item.getElementsByTagName("multiplicity").item(0);
|
||||
Element multiplicity = (Element)XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "multiplicity");
|
||||
|
||||
this.multiplicity.setMin(Integer.parseInt(multiplicity.getAttribute("min")));
|
||||
this.multiplicity.setMax(Integer.parseInt(multiplicity.getAttribute("max")));
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.w3c.dom.Node;
|
|||
import org.w3c.dom.NodeList;
|
||||
|
||||
import utilities.XmlSerializable;
|
||||
import utilities.builders.XmlBuilder;
|
||||
|
||||
public class FieldGroup implements DatabaseModelDefinition,XmlSerializable<FieldGroup>{
|
||||
private List<FieldSet> fieldSets;
|
||||
|
@ -36,7 +37,8 @@ public class FieldGroup implements DatabaseModelDefinition,XmlSerializable<Field
|
|||
@Override
|
||||
public FieldGroup fromXml(Element element) {
|
||||
this.fieldSets = new LinkedList();
|
||||
Element fieldSets = (Element)element.getElementsByTagName("fieldSets").item(0);
|
||||
Element fieldSets = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "fieldSets");
|
||||
|
||||
if(fieldSets!=null){
|
||||
NodeList fieldSetElements = fieldSets.getChildNodes();
|
||||
for (int temp = 0; temp < fieldSetElements.getLength(); temp++) {
|
||||
|
|
|
@ -74,7 +74,8 @@ public class FieldSet implements DatabaseModelDefinition,XmlSerializable<FieldSe
|
|||
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
||||
|
||||
this.fields = new LinkedList();
|
||||
Element fields = (Element)element.getElementsByTagName("fields").item(0);
|
||||
Element fields = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "fields");
|
||||
|
||||
if(fields!=null){
|
||||
NodeList fieldElements = fields.getChildNodes();
|
||||
for (int temp = 0; temp < fieldElements.getLength(); temp++) {
|
||||
|
@ -85,7 +86,8 @@ public class FieldSet implements DatabaseModelDefinition,XmlSerializable<FieldSe
|
|||
}
|
||||
}
|
||||
this.multiplicity = new Multiplicity();
|
||||
Element multiplicity = (Element)element.getElementsByTagName("multiplicity").item(0);
|
||||
Element multiplicity = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "multiplicity");
|
||||
|
||||
this.multiplicity.setMin(Integer.parseInt(multiplicity.getAttribute("min")));
|
||||
this.multiplicity.setMax(Integer.parseInt(multiplicity.getAttribute("max")));
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import models.components.commons.Visibility;
|
|||
import models.components.commons.datafield.FieldData;
|
||||
import utilities.XmlSerializable;
|
||||
import utilities.builders.ModelBuilder;
|
||||
import utilities.builders.XmlBuilder;
|
||||
|
||||
public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>{
|
||||
private String id;
|
||||
|
@ -112,24 +113,30 @@ public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>
|
|||
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
||||
this.defaultVisibility = Boolean.getBoolean(element.getAttribute("defaultVisibility"));
|
||||
|
||||
Element extendedDescription = (Element)element.getElementsByTagName("extendedDescription").item(0);
|
||||
Element extendedDescription = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "extendedDescription");
|
||||
|
||||
this.extendedDescription = extendedDescription.getTextContent();
|
||||
|
||||
Element description = (Element)element.getElementsByTagName("description").item(0);
|
||||
Element description = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
|
||||
|
||||
this.description = description.getTextContent();
|
||||
|
||||
Element title = (Element)element.getElementsByTagName("title").item(0);
|
||||
Element title = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "title");
|
||||
|
||||
this.title = title.getTextContent();
|
||||
|
||||
this.viewStyle = new ViewStyle();
|
||||
Element viewStyle = (Element)element.getElementsByTagName("viewStyle").item(0);
|
||||
Element viewStyle = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "viewStyle");
|
||||
|
||||
this.viewStyle.setRenderStyle(viewStyle.getAttribute("renderstyle"));
|
||||
this.viewStyle.setCssClass(viewStyle.getAttribute("cssClass"));
|
||||
|
||||
Element visibility = (Element)element.getElementsByTagName("visible").item(0);
|
||||
Element visibility = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "visible");
|
||||
|
||||
this.visible = new Visibility().fromXml(visibility);
|
||||
|
||||
Element dataElement = (Element)element.getElementsByTagName("data").item(0);
|
||||
Element dataElement = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "data");
|
||||
|
||||
this.data = new ModelBuilder().toFieldData(null, this.viewStyle.getRenderStyle());
|
||||
if(this.data!=null)this.data.fromXml(dataElement);
|
||||
return this;
|
||||
|
|
|
@ -118,7 +118,8 @@ public class FieldGroup implements DatabaseViewStyleDefinition,XmlSerializable<F
|
|||
this.description = description .getTextContent();
|
||||
|
||||
this.fieldSets = new LinkedList();
|
||||
Element fieldSets = (Element)element.getElementsByTagName("fieldsets").item(0);
|
||||
Element fieldSets = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "fieldsets");
|
||||
|
||||
if(fieldSets!=null){
|
||||
NodeList fieldSetElements = fieldSets.getChildNodes();
|
||||
for (int temp = 0; temp < fieldSetElements.getLength(); temp++) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.w3c.dom.NodeList;
|
|||
|
||||
import entities.xmlmodels.modeldefinition.DatabaseModelDefinition;
|
||||
import utilities.XmlSerializable;
|
||||
import utilities.builders.XmlBuilder;
|
||||
|
||||
public class FieldSet implements DatabaseViewStyleDefinition,XmlSerializable<FieldSet>{
|
||||
private String id;
|
||||
|
@ -58,7 +59,8 @@ public class FieldSet implements DatabaseViewStyleDefinition,XmlSerializable<Fie
|
|||
this.id = element.getAttribute("id");
|
||||
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
||||
this.fields = new LinkedList();
|
||||
Element fields = (Element)element.getElementsByTagName("fields").item(0);
|
||||
Element fields = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "fields");
|
||||
|
||||
if(fields!=null){
|
||||
NodeList fieldElements = fields.getChildNodes();
|
||||
for (int temp = 0; temp < fieldElements.getLength(); temp++) {
|
||||
|
|
|
@ -135,7 +135,7 @@ public class Section implements DatabaseViewStyleDefinition,XmlSerializable<Sect
|
|||
if(title!=null) this.title = title.getTextContent();
|
||||
|
||||
this.sections = new LinkedList<Section>();
|
||||
Element sections = (Element)element.getElementsByTagName("sections").item(0);
|
||||
Element sections = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
|
||||
if(sections!=null){
|
||||
NodeList sectionElements = sections.getChildNodes();
|
||||
for (int temp = 0; temp < sectionElements.getLength(); temp++) {
|
||||
|
@ -147,7 +147,8 @@ public class Section implements DatabaseViewStyleDefinition,XmlSerializable<Sect
|
|||
}
|
||||
|
||||
this.fieldGroups = new LinkedList<FieldGroup>();
|
||||
Element fieldGroups = (Element)element.getElementsByTagName("fieldGroups").item(0);
|
||||
Element fieldGroups = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "fieldGroups");
|
||||
|
||||
if(fieldGroups!=null){
|
||||
NodeList fieldGroupElements = fieldGroups.getChildNodes();
|
||||
for (int temp = 0; temp < fieldGroupElements.getLength(); temp++) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.w3c.dom.NodeList;
|
|||
|
||||
import entities.xmlmodels.modeldefinition.FieldSet;
|
||||
import utilities.XmlSerializable;
|
||||
import utilities.builders.XmlBuilder;
|
||||
|
||||
public class ViewStyleModel implements XmlSerializable<ViewStyleModel>{
|
||||
private List<Section> sections;
|
||||
|
@ -39,7 +40,7 @@ public class ViewStyleModel implements XmlSerializable<ViewStyleModel>{
|
|||
public ViewStyleModel fromXml(Element element) {
|
||||
|
||||
this.sections = new LinkedList();
|
||||
Element sections = (Element)element.getElementsByTagName("sections").item(0);
|
||||
Element sections = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
|
||||
if(sections!=null){
|
||||
NodeList sectionElements = sections.getChildNodes();
|
||||
for (int temp = 0; temp < sectionElements.getLength(); temp++) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package managers;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
@ -10,7 +11,8 @@ public class UserManager {
|
|||
Document viewStyleDoc = XmlBuilder.fromXml(profile.getViewstyle().getDefinition());
|
||||
Element root = (Element)viewStyleDoc.getDocumentElement();
|
||||
entities.xmlmodels.viewstyledefinition.ViewStyleModel viewstyle= new entities.xmlmodels.viewstyledefinition.ViewStyleModel().fromXml(root);
|
||||
|
||||
JSONObject jobject = new JSONObject(viewstyle);
|
||||
System.out.println(jobject.toString());
|
||||
Document profileDoc = XmlBuilder.fromXml(profile.getDefinition());
|
||||
root = (Element)profileDoc.getDocumentElement();
|
||||
entities.xmlmodels.modeldefinition.FieldGroup fieldGroup = new entities.xmlmodels.modeldefinition.FieldGroup().fromXml(root);
|
||||
|
|
|
@ -25,10 +25,7 @@ public class ModelBuilderCollector {
|
|||
fieldGroups.addAll(collectCompositeFields(section.getSections()));
|
||||
}
|
||||
fieldGroups.addAll(
|
||||
sections.stream()
|
||||
.map(itemSection->itemSection.getFieldGroups())
|
||||
.filter(x->x!=null)
|
||||
.flatMap(List::stream)
|
||||
section.getFieldGroups().stream()
|
||||
.map(group->group.getCompositeFields())
|
||||
.flatMap(List::stream)
|
||||
.collect(Collectors.toList())
|
||||
|
|
Loading…
Reference in New Issue