private void addFields(List<Field> fields, Element segmentEl) { for(Field field : fields) { Element fieldEl = newElement("field", segmentEl, field); mapBeanProperties(field, fieldEl, "name", "xmltag", "nodeTypeRef", "truncatable", "maxLength", "minLength", "required", "dataType", "dataTypeParametersString|dataTypeParameters"); addComponents(field.getComponents(), fieldEl); } }
private void addComponents(List<Component> components, Element fieldEl) { for(Component component : components) { Element componentEl = newElement("component", fieldEl, component); mapBeanProperties(component, componentEl, "name", "xmltag", "nodeTypeRef", "truncatable", "maxLength", "minLength", "required", "dataType", "dataTypeParametersString|dataTypeParameters"); addSubComponents(component.getSubComponents(), componentEl); } }
private void addSubComponents(List<SubComponent> subComponents, Element componentEl) { for(SubComponent subComponent : subComponents) { Element subComponentEl = newElement("sub-component", componentEl, subComponent); mapBeanProperties(subComponent, subComponentEl, "name", "xmltag", "nodeTypeRef", "maxLength", "minLength", "required", "dataType", "dataTypeParametersString|dataTypeParameters"); } }
private void write(Edimap edimap) { Element edimapEl = newElement("edimap", doc); addImports(edimap.getImports(), edimapEl); addDescription(edimap.getDescription(), edimapEl); addDelimiters(edimap.getDelimiters(), edimapEl); SegmentGroup segments = edimap.getSegments(); Element segmentsEl = newElement("segments", edimapEl, segments); mapBeanProperties(segments, segmentsEl, "name", "xmltag"); addChildSegments(segments, segmentsEl); }
private void addChildSegments(SegmentGroup segmentGroup, Element parentSegment) { List<SegmentGroup> childSegments = segmentGroup.getSegments(); for(SegmentGroup childSegment : childSegments) { Element segmentEl; if(childSegment instanceof Segment) { segmentEl = newElement("segment", parentSegment, childSegment); mapBeanProperties(childSegment, segmentEl, "segcode", "nodeTypeRef", "description", "ignoreUnmappedFields", "truncatable"); addFields(((Segment)childSegment).getFields(), segmentEl); } else { segmentEl = newElement("segmentGroup", parentSegment, childSegment); } mapBeanProperties(childSegment, segmentEl, "name", "xmltag", "minOccurs", "maxOccurs"); addChildSegments(childSegment, segmentEl); } }
public static void write(Edimap edimap, Writer writer) throws IOException { try { EdimapWriter edimapWriter = new EdimapWriter(); edimapWriter.write(edimap); XmlUtil.serialize(edimapWriter.doc, true, writer); writer.flush(); } catch (ParserConfigurationException e) { IOException ioE = new IOException("Error constructing EDI Mapping Model"); ioE.initCause(e); throw ioE; } }
private void mapBeanProperties(Object bean, Element target, String... properties) { for(String property : properties) { String[] propertyTokens = property.split("\\|"); String propertyName; String attributeName; if(propertyTokens.length == 2) { propertyName = propertyTokens[0]; attributeName = propertyTokens[1]; } else { propertyName = property; attributeName = property; } Object value = getBeanValue(bean, propertyName); if(value != null) { target.setAttribute(attributeName, XmlUtil.removeEntities(value.toString())); } } }
private void write(Edimap edimap) { Element edimapEl = newElement("edimap", doc); addImports(edimap.getImports(), edimapEl); addDescription(edimap.getDescription(), edimapEl); addDelimiters(edimap.getDelimiters(), edimapEl); SegmentGroup segments = edimap.getSegments(); Element segmentsEl = newElement("segments", edimapEl, segments); mapBeanProperties(segments, segmentsEl, "name", "xmltag"); addChildSegments(segments, segmentsEl); }
private void addImports(List<Import> imports, Element edimapEl) { for(Import importInst : imports) { mapBeanProperties(importInst, newElement("import", edimapEl), "resource", "namespace", "truncatableComponents", "truncatableFields", "truncatableSegments"); } }
private void addChildSegments(SegmentGroup segmentGroup, Element parentSegment) { List<SegmentGroup> childSegments = segmentGroup.getSegments(); for(SegmentGroup childSegment : childSegments) { Element segmentEl; if(childSegment instanceof Segment) { segmentEl = newElement("segment", parentSegment, childSegment); mapBeanProperties(childSegment, segmentEl, "segcode", "nodeTypeRef", "description", "ignoreUnmappedFields", "truncatable"); addFields(((Segment)childSegment).getFields(), segmentEl); } else { segmentEl = newElement("segmentGroup", parentSegment, childSegment); } mapBeanProperties(childSegment, segmentEl, "name", "xmltag", "minOccurs", "maxOccurs"); addChildSegments(childSegment, segmentEl); } }
public static void write(Edimap edimap, Writer writer) throws IOException { try { EdimapWriter edimapWriter = new EdimapWriter(); edimapWriter.write(edimap); XmlUtil.serialize(edimapWriter.doc, true, writer); writer.flush(); } catch (ParserConfigurationException e) { IOException ioE = new IOException("Error constructing EDI Mapping Model"); ioE.initCause(e); throw ioE; } }
private void mapBeanProperties(Object bean, Element target, String... properties) { for(String property : properties) { String[] propertyTokens = property.split("\\|"); String propertyName; String attributeName; if(propertyTokens.length == 2) { propertyName = propertyTokens[0]; attributeName = propertyTokens[1]; } else { propertyName = property; attributeName = property; } Object value = getBeanValue(bean, propertyName); if(value != null) { target.setAttribute(attributeName, XmlUtil.removeEntities(value.toString())); } } }
private void write(Edimap edimap) { Element edimapEl = newElement("edimap", doc); addImports(edimap.getImports(), edimapEl); addDescription(edimap.getDescription(), edimapEl); addDelimiters(edimap.getDelimiters(), edimapEl); SegmentGroup segments = edimap.getSegments(); Element segmentsEl = newElement("segments", edimapEl, segments); mapBeanProperties(segments, segmentsEl, "name", "xmltag"); addChildSegments(segments, segmentsEl); }
private void addSubComponents(List<SubComponent> subComponents, Element componentEl) { for(SubComponent subComponent : subComponents) { Element subComponentEl = newElement("sub-component", componentEl, subComponent); mapBeanProperties(subComponent, subComponentEl, "name", "xmltag", "nodeTypeRef", "maxLength", "minLength", "required", "dataType", "dataTypeParametersString|dataTypeParameters"); } }
private void addChildSegments(SegmentGroup segmentGroup, Element parentSegment) { List<SegmentGroup> childSegments = segmentGroup.getSegments(); for(SegmentGroup childSegment : childSegments) { Element segmentEl; if(childSegment instanceof Segment) { segmentEl = newElement("segment", parentSegment, childSegment); mapBeanProperties(childSegment, segmentEl, "segcode", "nodeTypeRef", "description", "ignoreUnmappedFields", "truncatable"); addFields(((Segment)childSegment).getFields(), segmentEl); } else { segmentEl = newElement("segmentGroup", parentSegment, childSegment); } mapBeanProperties(childSegment, segmentEl, "name", "xmltag", "minOccurs", "maxOccurs"); addChildSegments(childSegment, segmentEl); } }
private void addComponents(List<Component> components, Element fieldEl) { for(Component component : components) { Element componentEl = newElement("component", fieldEl, component); mapBeanProperties(component, componentEl, "name", "xmltag", "nodeTypeRef", "truncatable", "maxLength", "minLength", "required", "dataType", "dataTypeParametersString|dataTypeParameters"); addSubComponents(component.getSubComponents(), componentEl); } }
private void addFields(List<Field> fields, Element segmentEl) { for(Field field : fields) { Element fieldEl = newElement("field", segmentEl, field); mapBeanProperties(field, fieldEl, "name", "xmltag", "nodeTypeRef", "truncatable", "maxLength", "minLength", "required", "dataType", "dataTypeParametersString|dataTypeParameters"); addComponents(field.getComponents(), fieldEl); } }
public static void write(Edimap edimap, Writer writer) throws IOException { try { EdimapWriter edimapWriter = new EdimapWriter(); edimapWriter.write(edimap); XmlUtil.serialize(edimapWriter.doc, true, writer); writer.flush(); } catch (ParserConfigurationException e) { IOException ioE = new IOException("Error constructing EDI Mapping Model"); ioE.initCause(e); throw ioE; } }
private void mapBeanProperties(Object bean, Element target, String... properties) { for(String property : properties) { String[] propertyTokens = property.split("\\|"); String propertyName; String attributeName; if(propertyTokens.length == 2) { propertyName = propertyTokens[0]; attributeName = propertyTokens[1]; } else { propertyName = property; attributeName = property; } Object value = getBeanValue(bean, propertyName); if(value != null) { target.setAttribute(attributeName, XmlUtil.removeEntities(value.toString())); } } }
private void write(Edimap edimap) { Element edimapEl = newElement("edimap", doc); addImports(edimap.getImports(), edimapEl); addDescription(edimap.getDescription(), edimapEl); addDelimiters(edimap.getDelimiters(), edimapEl); SegmentGroup segments = edimap.getSegments(); Element segmentsEl = newElement("segments", edimapEl, segments); mapBeanProperties(segments, segmentsEl, "name", "xmltag"); addChildSegments(segments, segmentsEl); }