Package org.milyn.edisax.model

Examples of org.milyn.edisax.model.EdifactModel$DependencyTree


*/
public class FieldRepeatTest extends TestCase {

  public void test() throws IOException, SAXException, EDIConfigurationException {
    MockContentHandler handler;
    EdifactModel msg1 = EDIParser.parseMappingModel(getClass().getResourceAsStream("edi-to-xml-mapping.xml"));
   
    EDIParser parser = new EDIParser();
    parser.setMappingModel(msg1);

    handler = new MockContentHandler();
View Full Code Here


        lookupNameBuilder.append(':');
      }
      lookupNameBuilder.append(nameComponents[i]);
    }
    String lookupName = lookupNameBuilder.toString().trim();
    EdifactModel result = content.get(lookupName);
    if (result == null) {
            synchronized (content) {
                result = content.get(lookupName);
            if (result == null) {
              content.putAll(demandLoading(nameComponents));
View Full Code Here

        }
    }

    private static boolean loadXMLMappingModel(String mappingModelFile, Map<String, EdifactModel> mappingModels, URI baseURI) throws EDIConfigurationException {
    try {
      EdifactModel model = EDIParser.parseMappingModel(mappingModelFile, baseURI);
      mappingModels.put(toLookupName(model.getEdimap().getDescription()), model);
      return true;
    } catch (IOException e) {
      return false;
    } catch (SAXException e) {
      logger.debug("Configured mapping model file '" + mappingModelFile + "' is not a valid Mapping Model xml file.");
View Full Code Here

  }

    public static void loadMappingModels(Map<String, EdifactModel> mappingModels, URI baseURI, List<String> rootMappingModels) throws IOException, SAXException, EDIConfigurationException {
        for (String rootMappingModel : rootMappingModels) {
            try {
                EdifactModel mappingModel = EDIParser.parseMappingModel(rootMappingModel, baseURI);

                mappingModel.setAssociateModels(mappingModels.values());
                mappingModels.put(toLookupName(mappingModel.getDescription()), mappingModel);
            } catch(Exception e) {
                throw new EDIConfigurationException("Error parsing EDI Mapping Model '" + rootMappingModel + "'.", e);
            }
        }
    }
View Full Code Here

    // Check make sure the parsed and validated model was cached...
    Hashtable mappingTable = EDIReader.getMappingTable(smooks.getApplicationContext());
    assertNotNull("No mapping table in context!", mappingTable);

        EdifactModel mappingModel_request1 = (EdifactModel) mappingTable.get(config);
        assertNotNull("No mapping model in mapping table!", mappingModel_request1);

    // Create 2nd parser using the same config, and run a parse through it...
    parser = new DOMParser(smooks.createExecutionContext(), config);
    parser.parse(new StreamSource(new ByteArrayInputStream(input)));
View Full Code Here

     * @throws EDIConfigurationException When edi-mapping-configuration is badly formatted.
     * @throws IOException When unable to read edi-mapping-configuration.
     * @throws SAXException When edi-mapping-configuration is badly formatted.
     */
    private Edimap readEDIConfig(InputStream inputStream) throws EDIConfigurationException, IOException, SAXException {
        EdifactModel edifactModel = new EdifactModel(inputStream);
        return edifactModel.getEdimap();
    }
View Full Code Here

        Properties interchangeProperties = EDIUtils.getInterchangeProperties(ediMappingModel);

        Map<String, EdifactModel> mappingModels = new LinkedHashMap<String, EdifactModel>();
        EDIUtils.loadMappingModels(ediMappingModel, mappingModels, URIResourceLocator.DEFAULT_BASE_URI);

        EdifactModel definitionsModel = mappingModels.get(EDIUtils.MODEL_SET_DEFINITIONS_DESCRIPTION_LOOKUP_NAME);
        String commonsPackageName = packageName + ".common";
        ClassModel definitionsClassModel = null;

        if(definitionsModel != null) {
            EJC ejc = new EJC();
            definitionsClassModel = ejc.compile(definitionsModel.getEdimap(), commonsPackageName, destDir.getAbsolutePath());

            // Get rid of the binding and edi mapping model configs for the commons...
            deleteFile(commonsPackageName, EJC.BINDINGCONFIG_XML);
            deleteFile(commonsPackageName, EJC.EDIMAPPINGCONFIG_XML);
        }
View Full Code Here

        try {
            String interchangeSegmentDefinitions = INTERCHANGE_DEFINITION_SHORTNAME;
            if (!useShortName) {
                interchangeSegmentDefinitions = INTERCHANGE_DEFINITION;
            }
            EdifactModel interchangeEnvelope = new EdifactModel(ClassUtil.getResourceAsStream(interchangeSegmentDefinitions, this.getClass()));
            definitionModel.getSegments().getSegments().addAll(interchangeEnvelope.getEdimap().getSegments().getSegments());
        } catch (Exception e) {
            throw new EdiParseException(e.getMessage(), e);
        }

    }
View Full Code Here

  private static final String NS = "http://smooks.org/edi/un/test.xsd";

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

            fail("Expected SAXException");
        }
    }
 
  public void test_parseMappingModel() throws IOException, SAXException, EDIConfigurationException {
    EdifactModel map = EDIParser.parseMappingModel(getClass().getResourceAsStream("edi-mapping_01.xml"));
   
    // Some basic checks on the model produced by xmlbeans...
   
    // Make sure xml character refs are rewritten on the delimiters
    assertEquals("\n", map.getDelimiters().getSegment());
    assertEquals("*", map.getDelimiters().getField());
    assertEquals("^", map.getDelimiters().getComponent());
    assertEquals("~", map.getDelimiters().getSubComponent());
   
    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());
View Full Code Here

TOP

Related Classes of org.milyn.edisax.model.EdifactModel$DependencyTree

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.