Package org.milyn.edisax.model.internal

Examples of org.milyn.edisax.model.internal.SegmentGroup


            version = getValue(breader, MESSAGE_VERSION);
            release = getValue(breader, MESSAGE_RELEASE);
            agency = getValue(breader, MESSAGE_AGENCY);

            edimap = new Edimap();
            SegmentGroup rootGroup = new SegmentGroup();
            rootGroup.setXmltag(XmlTagEncoder.encode(type));
            edimap.setSegments(rootGroup);

            Delimiters delimiters = new Delimiters();
            delimiters.setSegment(DELIMITER_SEGMENT);
            delimiters.setField(DELIMITER_COMPOSITE);
View Full Code Here


        while (line != null) {
            if (line.matches(SEGMENT_GROUP_START)) {
                Matcher matcher = Pattern.compile(SEGMENT_GROUP_START).matcher(line);
                matcher.matches();
                String id = getLineId(lineNo, matcher.group(1));
                SegmentGroup group = createGroup(id, matcher.group(2), matcher.group(3), matcher.group(4), definitions);
                parentGroup.getSegments().add(group);

                int result = parseNextSegment(reader, group, definitions, isSplitIntoImport, useShortName, segmentDefinitions, lineNo);
                if (result != 0) {
                    return result - 1;
View Full Code Here

    private String extractPlusCharacter(String value) {
        return value.replaceAll("[^\\+]", "");
    }

    private SegmentGroup createGroup(String id, String name, String mandatory, String maxOccurance, Map<String, String> definitions) {
        SegmentGroup group = new SegmentGroup();
        group.setXmltag(XmlTagEncoder.encode(name.trim()));
        String test = definitions.get(id);
       
        group.setDocumentation(test.trim());
        group.setMinOccurs(mandatory.equals("M") ? 1 : 0);
        group.setMaxOccurs(Integer.valueOf(maxOccurance));
        return group;
    }
View Full Code Here

     * @param edimap the {@link org.milyn.edisax.model.internal.Edimap} to populate.
     * @param namespacePrefix the prefix used to name elements in xml.
     * @throws org.milyn.edisax.EDIConfigurationException is thrown when values are badly formatted.
     */
    private void digestSegments(Node node, Edimap edimap, String namespacePrefix) throws EDIConfigurationException {
        SegmentGroup segments = new SegmentGroup();
        setValuesForMappingNode(node, segments, namespacePrefix, null);
        segments.setNamespace(edimap.getDescription().getNamespace());
        edimap.setSegments(segments);
        edimap.setIgnoreUnmappedSegments(getNodeValueAsBoolean(node, "ignoreUnmappedSegments"));

        NodeList nodes = node.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
View Full Code Here

    }

    private boolean digestSegmentGroup(Node currentNode, List<SegmentGroup> segmentGroupList, String namespacePrefix, MappingNode parent) throws EDIConfigurationException {

        if (currentNode.getNodeName().equalsIgnoreCase(namespacePrefix + "segmentGroup")) {
            SegmentGroup segment = new SegmentGroup();
            segment.setDocumentation(getNodeValue(currentNode, namespacePrefix + "documentation"));
            segmentGroupList.add(segment);
            digestSegment(currentNode, segment, namespacePrefix, parent);

            return true;
        } else if (currentNode.getNodeName().equalsIgnoreCase(namespacePrefix + "segment")) {
View Full Code Here

    }

    public static void write(Segment segment, Writer writer) throws IOException {
        Edimap ediMap = new Edimap();

        SegmentGroup segments = new SegmentGroup();
        segments.getSegments().add(segment);

        ediMap.setSegments(segments);
        ediMap.setDelimiters(UNEdifactInterchangeParser.defaultUNEdifactDelimiters);
        ediMap.setDescription(new Description().setName("TODO").setVersion("TODO"));
View Full Code Here

        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);
    }
View Full Code Here

    EdifactModel msg1 = EDIParser.parseMappingModel(getClass()
        .getResourceAsStream("edi-to-xml-mapping.xml"));
    assertNotNull(msg1);
    Edimap edimap = msg1.getEdimap();
    assertEquals(NS,edimap.getDescription().getNamespace());
    SegmentGroup group = edimap.getSegments();
    assertEquals(NS,group.getNamespace());
    List<SegmentGroup> segments = group.getSegments();
    for (SegmentGroup segment : segments) {
      assertEquals(NS,segment.getNamespace());
      if (segment instanceof Segment) {
        List<Field> fields = ((Segment)segment).getFields();
        for (Field field : fields) {
View Full Code Here

                + ExtendedMetaData.INSTANCE.getName(segmentRef)
                + ")" + " in " + parent.getName());
          }
        }
      } else if (arg0 instanceof SegmentGroup) {
        SegmentGroup grp = (SegmentGroup) arg0;
        EClass refClass = ECoreConversionUtils
            .segmentGroupToEClass(grp);
        EReference reference = ECoreConversionUtils
            .segmentGroupToEReference(grp, refClass);
        if (parent.getEStructuralFeature(reference.getName()) == null) {
          parent.getEStructuralFeatures().add(reference);
        }
        if (!result.add(refClass)) {
          throw new RuntimeException("Reference class "
              + refClass.getName() + " is duplicated in package");
        }
        processSegments(grp.getSegments(), commonClasses, result,
            refClass);
      }
    }
  }
View Full Code Here

    public ClassModel compile(Edimap edimap, String classPackage) throws IllegalNameException {
        model = new ClassModel();

        model.setEdimap(edimap);

        SegmentGroup segmentGroup = edimap.getSegments();

        pushNode(segmentGroup);

        JClass rootClass = new JClass(classPackage, EDIUtils.encodeClassName(segmentGroup.getJavaName()), getCurrentClassId()).setSerializable();
        BindingConfig rootBeanConfig = new BindingConfig(getCurrentClassId(), getCurrentNodePath(), rootClass, null, null);

        //Insert root class into classModel and its' corresponding xmltag-value.
        model.addCreatedClass(rootClass);
        model.setRootBeanConfig(rootBeanConfig);

        LOG.debug("Added root class [" + rootClass + "] to ClassModel.");

        addWriteMethod(rootBeanConfig);
        processSegmentGroups(segmentGroup.getSegments(), rootBeanConfig);

        LOG.debug("Finished parsing edi-configuration. All segments are added to ClassModel.");
        LOG.debug("ClassModel contains " + model.getCreatedClasses().size() + " classes.");

        // Attach the createdClassesByNode map... so we can use them if they
View Full Code Here

TOP

Related Classes of org.milyn.edisax.model.internal.SegmentGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.