Package org.milyn.edisax.model.internal

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


    // Select the mapping model to use for this message...
    String[] fields = segmentReader.getCurrentSegmentFields();
    String messageName = fields[2];
    EdifactModel mappingModel = registry.getMappingModel(messageName, segmentReader.getDelimiters());
        Edimap ediMap = mappingModel.getEdimap();

        Description description = ediMap.getDescription();
        AttributesImpl attrs = new AttributesImpl();
        String namespace = description.getNamespace();
        String commonNS = null;
        String messageNSPrefix = null;
        if(namespace != null && !namespace.equals(XMLConstants.NULL_NS_URI)) {
View Full Code Here


        String ediNS = validator.getNamespaces().get(0).toString();

        validator.validate();

        Edimap edimap = new Edimap(modelURI);

        if(assertValidXSD(ediNS)) {
            digestXSDValidatedConfig(configDoc,  edimap, ediNS);
        } else {
            throw new SAXException("Cannot parse edi-message-mapping configuration.  Unsupported default Namespace '" + ediNS + "'.");
View Full Code Here

            throw ioE;
        }
    }

    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"));

        write(ediMap, writer);
    }
View Full Code Here

     * @throws EDIParseException Thrown when a cyclic dependency is detected.
     * @throws org.milyn.edisax.EDIConfigurationException is thrown when edi-message-mapping contains multiple or no namespace declaration.
     * @throws java.io.IOException is thrown when error occurs when parsing edi-message-mapping.
     */
    private void importFiles(Node<String> parent, Edimap edimap, DependencyTree<String> tree) throws SAXException, EDIConfigurationException, IOException {
        Edimap importedEdimap;
        Node<String> child, conflictNode;

        for (Import imp : edimap.getImports()) {
            URI importUri = imp.getResourceURI();
            Map<String, Segment> importedSegments = null;
View Full Code Here

     * @throws IllegalNameException when name of java-classes is illegal.
     * @throws ClassNotFoundException when error occurs while creating bindingfile.
     */
    public ClassModel compile(InputStream mappingModel, String beanPackage) throws EDIConfigurationException, IOException, SAXException, IllegalNameException, ClassNotFoundException {
        //Read edifact configuration
        Edimap edimap = readEDIConfig(mappingModel);

        return compile(edimap, beanPackage, (Map<MappingNode, JClass>)null);
    }
View Full Code Here

    public EdiDirectory getEdiDirectory(String... includeMessages) throws IOException {
        if(ediDirectory == null) {
            Set<String> includeMessageSet = null;
            String commonMessageName = getCommmonMessageName();
            Set<String> messages = getMessageNames();
            Edimap commonModel = null;
            List<Edimap> models = new ArrayList<Edimap>();

            if(includeMessages != null && includeMessages.length > 0) {
                includeMessageSet = new HashSet<String>(Arrays.asList(includeMessages));
            }

            for(String message : messages) {
                if (includeMessageSet != null && !message.equals(commonMessageName)) {
                    if (!includeMessageSet.contains(message)) {
                        // Skip this message...
                        continue;
                    }
                }

                Edimap model = getMappingModel(message);

                EdiConvertionTool.removeDuplicateSegments(model.getSegments());

                if(message.equals(commonMessageName)) {
                    if(commonModel == null) {
                        commonModel = model;
                    } else {
View Full Code Here

        return definitionModel;
    }

    private Edimap parseEDIDefinitionFiles() throws IOException, EdiParseException {

        Edimap edifactModel;
        Reader dataISR = null;
        Reader compositeISR = null;
        Reader segmentISR = null;
        try {
            dataISR = new InputStreamReader(new ByteArrayInputStream(definitionFiles.get("eded.")));
            compositeISR = new InputStreamReader(new ByteArrayInputStream(definitionFiles.get("edcd.")));
            segmentISR = new InputStreamReader(new ByteArrayInputStream(definitionFiles.get("edsd.")));

            edifactModel = UnEdifactDefinitionReader.parse(dataISR, compositeISR, segmentISR, useShortName);
            edifactModel.setDescription((Description) EDIUtils.MODEL_SET_DEFINITIONS_DESCRIPTION.clone());
            edifactModel.getSegments().setXmltag("DefinitionMap");
            edifactModel.setDelimiters(UNEdifactInterchangeParser.defaultUNEdifactDelimiters);
        } finally {
            if (dataISR != null) {
                dataISR.close();
            }
            if (compositeISR != null) {
View Full Code Here

  public void test() throws IOException, SAXException,
      EDIConfigurationException {
    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) {
View Full Code Here

  public Set<EPackage> generatePackages(EdiDirectory ediDirectory) {
    log.debug("Converting UN EDIFACT Model");
    Set<EPackage> result = new HashSet<EPackage>();

    // Creating common package
    Edimap commonModel = ediDirectory.getCommonModel();
    Map<String, EClass> commonClasses = new HashMap<String, EClass>();
    EPackage commonPackage = EcoreFactory.eINSTANCE.createEPackage();
    commonPackage.setName(COMMON_PACKAGE_NAME);
    commonPackage.setNsPrefix("common");
    commonPackage.setNsURI(commonModel.getDescription().getNamespace());
    Collection<EClass> clzz = createCommonClasses(commonModel,
        commonClasses);
    commonPackage.getEClassifiers().addAll(clzz);
    result.add(commonPackage);
View Full Code Here

    public void test_MILYN_475() throws IOException, EDIConfigurationException, SAXException {
        ZipInputStream zipInputStream = new ZipInputStream(getClass().getResourceAsStream("D08A.zip"));
        UnEdifactSpecificationReader specReader = new UnEdifactSpecificationReader(zipInputStream, false, false);
        ByteArrayOutputStream serializedMap = new ByteArrayOutputStream();

        Edimap jupreq = specReader.getMappingModel("JUPREQ");
        Writer writer = new OutputStreamWriter(serializedMap);

        jupreq.write(writer);

        EDIConfigDigester.digestConfig(new ByteArrayInputStream(serializedMap.toByteArray()));
    }
View Full Code Here

TOP

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

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.