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