public Description getDescription() { if (description != null) { return description; } return getEdimap().getDescription(); }
public Set<String> getMessageNames() { Set<String> names = new LinkedHashSet<String>(); names.add(definitionModel.getDescription().getName()); names.addAll(messageFiles.keySet()); return names; }
private static String getMessagePrefix(Edimap mappingModel) { return "EDI message processing failed [" + mappingModel.getDescription().getName() + "][" + mappingModel.getDescription().getVersion() + "]."; }
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."); return false; } }
public Edimap getMappingModel(String messageName) throws IOException { if(messageName.equals(definitionModel.getDescription().getName())) { return definitionModel; } else { return parseEdiMessage(messageName).getEdimap(); } }
private static void addModel(Edimap model, String pathPrefix, StringBuilder modelListBuilder, StringWriter messageEntryWriter, Archive archive) throws IOException { Description modelDesc = model.getDescription(); String messageEntryPath = pathPrefix + "/" + modelDesc.getName() + ".xml"; // Generate the mapping model for this message... messageEntryWriter.getBuffer().setLength(0); model.write(messageEntryWriter); // Add the generated mapping model to the archive... archive.addEntry(messageEntryPath, messageEntryWriter.toString()); // Add this messages archive entry to the mapping model list file... modelListBuilder.append("/" + messageEntryPath); modelListBuilder.append("!" + modelDesc.getName()); modelListBuilder.append("!" + modelDesc.getVersion()); modelListBuilder.append("!" + modelDesc.getNamespace()); modelListBuilder.append("\n"); }
/** * Set the edifact edimap from the mapping model InputStream. * * @throws org.dhatim.edisax.EDIParseException is thrown when EdifactModel * is unable to initialize edimap. * @throws org.dhatim.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 synchronized void parseSequence() throws EDIConfigurationException, IOException, SAXException { if (edimap != null) { return; } //To prevent circular dependency the name/url of all imported urls are stored in a dependency tree. //If a name/url already exists in a parent node, we have a circular dependency. DependencyTree<String> tree = new DependencyTree<String>(); EDIConfigDigester digester = new EDIConfigDigester(modelURI, importBaseURI); edimap = digester.digestEDIConfig(new StringReader(mappingConfig)); description = edimap.getDescription(); importFiles(tree.getRoot(), edimap, tree); }
commonPackage.setName(COMMON_PACKAGE_NAME); commonPackage.setNsPrefix("common"); commonPackage.setNsURI(commonModel.getDescription().getNamespace()); Collection<EClass> clzz = createCommonClasses(commonModel, commonClasses);
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() + ".");
/** * Digest attributes and child elements of Segments element. Populates Segments. * @param node the Segments element. * @param edimap the {@link org.dhatim.edisax.model.internal.Edimap} to populate. * @param namespacePrefix the prefix used to name elements in xml. * @throws org.dhatim.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++) { Node currentNode = nodes.item(i); digestSegmentGroup(currentNode, edimap.getSegments().getSegments(), namespacePrefix, segments); } }
public UnEdifactSpecificationReader(ZipInputStream specificationInStream, boolean useImport, boolean useShortName) throws IOException { this.useImport = useImport; this.useShortName = useShortName; definitionFiles = new HashMap<String, byte[]>(); messageFiles = new HashMap<String, byte[]>(); readDefinitionEntries(specificationInStream, new ZipDirectoryEntry("eded.", definitionFiles), new ZipDirectoryEntry("edcd.", definitionFiles), new ZipDirectoryEntry("edsd.", definitionFiles), new ZipDirectoryEntry("edmd.", "*", messageFiles)); if (versions.size() != 1) { if (versions.size() == 0) { throw new EdiParseException("Seems that we have a directory containing 0 parseable version inside: " + versions + ".\n All messages:\n\t" + messages); } throw new EdiParseException("Seems that we have a directory containing more than one parseable version inside: " + versions + ".\n All messages:\n\t" + messages); } String version = versions.iterator().next(); // Read Definition Configuration definitionModel = parseEDIDefinitionFiles(); addMissingDefinitions(definitionModel); definitionModel.getDescription().setNamespace(ControlBlockHandlerFactory.NAMESPACE_ROOT + ":un:" + version + ":common"); //Interchange envelope is inserted into the definitions. Handcoded at the moment. 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); } }
edimap.getDescription().setName(type); edimap.getDescription().setVersion(version + ":" + release + ":" + agency); edimap.getDescription().setNamespace(ControlBlockHandlerFactory.NAMESPACE_ROOT + ":" + agency.toLowerCase() + ":" + version.toLowerCase() + release.toLowerCase() + ":" + type.toLowerCase()); Import ediImport = new Import(); ediImport.setNamespace(agency); ediImport.setResource(definitionModel.getDescription().getName() + ".xml"); // TODO: Review with B�rd edimap.getImports().add(ediImport); } else {
private void write(Edimap edimap) { Element edimapEl = newElement("edimap", doc); 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); }
Description desc = mapModel.getDescription(); pkg.setName(desc.getName().toLowerCase()); pkg.setNsPrefix(desc.getName().toLowerCase()); annotate(pkg, "src", mapModel.getSrc().toASCIIString()); annotate(pkg, "description.name", mapModel.getDescription().getName()); annotate(pkg, "description.version", mapModel.getDescription() .getVersion()); annotate(pkg, "delimeters.segment", mapModel.getDelimiters()
Edimap ediMap = mappingModel.getEdimap(); Description description = ediMap.getDescription(); AttributesImpl attrs = new AttributesImpl(); String namespace = description.getNamespace();