Package org.milyn.edisax.model

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


*/
public class IgnoreUnmappedFieldsTest 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


    segmentReader.moveToNextSegment(false);

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

   * Parse the EDI message.
   * <p/>
   * Overridden so as to set the EDI to XML mapping model on the parser.
   */
  public void parse(InputSource ediSource) throws IOException, SAXException {
    EdifactModel edi2xmlMappingModel = getMappingModel();
   
    setMappingModel(edi2xmlMappingModel);
       
    // Set features...
    setFeature(FEATURE_VALIDATE, validate);       
View Full Code Here

   * @return The Mapping Model.
   * @throws IOException Error reading resource configuration data (the mapping model).
   * @throws SAXException Error parsing mapping model.
   */
  private EdifactModel getMappingModel() throws IOException, SAXException {
        EdifactModel edifactModel;
        Hashtable mappings = getMappingTable(applicationContext);

    synchronized (configuration) {
            edifactModel = (EdifactModel) mappings.get(configuration);
            if(edifactModel == null) {
        try {
                ContainerResourceLocator resourceLocator = applicationContext.getResourceLocator();

                    if(modelConfigData.startsWith("urn:") || modelConfigData.endsWith(".jar") || modelConfigData.endsWith(".zip")) {
                        throw new IOException("Unsupported mapping model config URI for basic EDI Parser '" + modelConfigData + "'.  Check that you are using the correct EDI parser.  You may need to configure an Interchange Parser, such as the UN/EDIFACT parser.");
                    }

                if(resourceLocator instanceof URIResourceLocator) {
                  // This will resolve config paths relative to the containing smooks config file....
                  edifactModel = EDIParser.parseMappingModel(modelConfigData, (resourceLocator).getBaseURI());
                } else {
                  edifactModel = EDIParser.parseMappingModel(modelConfigData, URIResourceLocator.getSystemBaseURI());
                }
            if(edifactModel == null) {
              logger.error("Invalid " + MODEL_CONFIG_KEY + " config value '" + modelConfigData + "'. Failed to locate EDI Mapping Model resource!");
            }
        } catch (IOException e) {
                    IOException newE = new IOException("Error parsing EDI mapping model [" + configuration.getStringParameter(MODEL_CONFIG_KEY) + "].  Target Profile(s) " + getTargetProfiles() + ".");
          newE.initCause(e);
          throw newE;
        } catch (SAXException e) {
          throw new SAXException("Error parsing EDI mapping model [" + configuration.getStringParameter(MODEL_CONFIG_KEY) + "].  Target Profile(s) " + getTargetProfiles() + ".", e);
        } catch (EDIConfigurationException e) {
                    throw new SAXException("Error parsing EDI mapping model [" + configuration.getStringParameter(MODEL_CONFIG_KEY) + "].  Target Profile(s) " + getTargetProfiles() + ".", e);
                }
                mappings.put(configuration, edifactModel);
        logger.debug("Parsed, validated and cached EDI mapping model [" + edifactModel.getEdimap().getDescription().getName() + ", Version " + edifactModel.getEdimap().getDescription().getVersion() + "].  Target Profile(s) " + getTargetProfiles() + ".");
      } else if(logger.isInfoEnabled()) {
        logger.debug("Found EDI mapping model [" + edifactModel.getEdimap().getDescription().getName() + ", Version " + edifactModel.getEdimap().getDescription().getVersion() + "] in the model cache.  Target Profile(s) " + getTargetProfiles() + ".");
      }
    }
   
    return edifactModel;
  }
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.