Package org.milyn.edisax.model.internal

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


     * @throws org.milyn.edisax.EDIConfigurationException is thrown when values are badly formatted.
     */
    private void digestSegment(Node node, SegmentGroup segmentGroup, String namespacePrefix, MappingNode parent) throws EDIConfigurationException {

        if(segmentGroup instanceof Segment) {
            Segment segment = (Segment) segmentGroup;
            setValuesForSegment(segment, node, namespacePrefix, parent);

            NodeList nodes = node.getChildNodes();
            for (int i = 0; i < nodes.getLength(); i++) {
                Node currentNode = nodes.item(i);

                if (currentNode.getNodeName().equalsIgnoreCase(namespacePrefix + "field")) {
                    Field field = new Field();
                    segment.getFields().add(field);
                    digestField(currentNode, field, namespacePrefix, segment);
                } else {
                    digestSegmentGroup(currentNode, segment.getSegments(), namespacePrefix, segment);
                }
            }
        } else {
            segmentGroup.setMaxOccurs(getNodeValueAsInteger(node, "maxOccurs"));
            segmentGroup.setMinOccurs(getNodeValueAsInteger(node, "minOccurs"));
View Full Code Here


            segmentGroupList.add(segment);
            digestSegment(currentNode, segment, namespacePrefix, parent);

            return true;
        } else if (currentNode.getNodeName().equalsIgnoreCase(namespacePrefix + "segment")) {
            Segment segment = new Segment();
            segmentGroupList.add(segment);
            digestSegment(currentNode, segment, namespacePrefix, parent);

            return true;
        }
View Full Code Here

     * a value not located in the imported segment but with the namespace referencing the imported file.
     */
    private void applyImportOnSegment(Segment segment, Import imp, Map<String, Segment> importedSegments) throws EDIParseException {
        if (segment.getNodeTypeRef() != null && segment.getNodeTypeRef().startsWith(imp.getNamespace()+":")) {
            String key = segment.getNodeTypeRef().substring(segment.getNodeTypeRef().indexOf(':') + 1);
            Segment importedSegment = importedSegments.get(key);

            if (importedSegment == null) {
                throw new EDIParseException(edimap, "Referenced segment [" + key + "] does not exist in imported edi-message-mapping [" + imp.getResource() + "]");
            }
            insertImportedSegmentInfo(segment, importedSegment, imp.isTruncatableSegments(), imp.isTruncatableFields(), imp.isTruncatableComponents());
View Full Code Here

    private String getCommmonMessageName() {
        return EDIUtils.MODEL_SET_DEFINITIONS_DESCRIPTION.getName();
    }

    private void addMissingDefinitions(Edimap definitionModel) {
        Segment ugh = new Segment();
        Segment ugt = new Segment();

        ugh.setSegcode("UGH");
        ugh.setXmltag("UGH");
        ugh.addField(new Field("id", UNEdifact41ControlBlockHandlerFactory.NAMESPACE, true));

        ugt.setSegcode("UGT");
        ugt.setXmltag("UGT");
        ugt.addField(new Field("id", UNEdifact41ControlBlockHandlerFactory.NAMESPACE, true));

        definitionModel.getSegments().getSegments().add(ugh);
        definitionModel.getSegments().getSegments().add(ugt);
    }
View Full Code Here

  private void processSegments(List<SegmentGroup> segments,
      final Map<String, EClass> commonClasses, final Set<EClass> result,
      final EClass parent) {
    for (SegmentGroup arg0 : segments) {
      if (arg0 instanceof Segment) {
        Segment segment = (Segment) arg0;
        EClass clazz = null;
        if (segment.getNodeTypeRef() == null) {
          // Segment without reference
          clazz = ECoreConversionUtils.segmentToEClass(segment);
          if (!segment.getFields().isEmpty()) {
            commonClasses.put(segment.getSegcode(), clazz);
            Collection<EStructuralFeature> fields = processFields(
                segment.getFields(), commonClasses);
            clazz.getEStructuralFeatures().addAll(fields);
          }
          result.add(clazz);
        } else {
          // Segment with reference
View Full Code Here

  private Collection<EClass> createCommonClasses(Edimap commonModel,
      final Map<String, EClass> commonClasses) {
    Map<String, EClass> result = new HashMap<String, EClass>();
    for (SegmentGroup grp : commonModel.getSegments().getSegments()) {
      // No segment groups are allowed in common part
      Segment segment = (Segment) grp;
      EClass clazz = ECoreConversionUtils.segmentToEClass(segment);
      if (!segment.getFields().isEmpty()) {
        commonClasses.put(segment.getSegcode(), clazz);
        Collection<EStructuralFeature> fields = processFields(
            segment.getFields(), result);
        clazz.getEStructuralFeatures().addAll(fields);
      }
      result.put(clazz.getName(), clazz);
    }
    // Adding DocumentRoot
View Full Code Here

   
    assertEquals("message-x", map.getEdimap().getSegments().getXmltag());
    List<SegmentGroup> segments = map.getEdimap().getSegments().getSegments();
    assertEquals(2, segments.size());

        Segment segment = (Segment) segments.get(0);
        assertEquals(1, segment.getSegments().size());
    assertEquals(1, segment.getFields().size());

        segment = (Segment) segments.get(1);
        assertEquals(0, segment.getSegments().size());
    assertEquals(1, segment.getFields().size());
  }
View Full Code Here

        pushNode(segmentGroup);

        BindingConfig segGroupBinding = createChildAndConnectWithParent(parent, segmentGroup, segmentGroup.getMaxOccurs(), null);

        if (segmentGroup instanceof Segment) {
            Segment segment = (Segment) segmentGroup;
            processFields(segment.getFields(), segGroupBinding);
        }

        processSegmentGroups(segmentGroup.getSegments(), segGroupBinding);

        popNode();
View Full Code Here

        List<Segment> segments = new ArrayList<Segment>();

        BufferedReader _reader = new BufferedReader(reader);
        moveToNextPart(_reader);

        Segment segment = getSegment(_reader, composites, datas, useShortName);
        while (segment != null) {
            segments.add(segment);
            segment = getSegment(_reader, composites, datas, useShortName);
        }
View Full Code Here

            throw new EdiParseException("Unable to extract segment code and name for Segment from line [" + line + "].");
        }

        String description = getValue(reader, "Function:");

        Segment segment = new Segment();
        segment.setSegcode(segcode);
        segment.setName(name);
        if (useShortName) {
            segment.setXmltag(XmlTagEncoder.encode(segcode.trim()));
        } else {
            segment.setXmltag(XmlTagEncoder.encode(name.trim()));
        }
        segment.setDescription(description);
        segment.setTruncatable(true);

        line = readUntilValue(reader);

        Matcher matcher;
        while (line != null && !line.matches(ELEMENT_SEPARATOR)) {
View Full Code Here

TOP

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

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.