Package org.milyn.edisax.model.internal

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


    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)) {
            int nameComponentIndex = namespace.lastIndexOf(":");
            if(nameComponentIndex != -1) {
                commonNS = namespace.substring(0, nameComponentIndex) + ":common";
                messageNSPrefix = description.getName().toLowerCase();
                attrs.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "c", "xmlns:c", "CDATA", commonNS);
                attrs.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, messageNSPrefix, "xmlns:" + messageNSPrefix, "CDATA", namespace);
            }
        }
View Full Code Here


     * Digest attributes of Description element and populate Description.
     * @param node the Description element.
     * @param edimap the {@link org.milyn.edisax.model.internal.Edimap} to populate.
     */
    private static void digestDescription(Node node, Edimap edimap) {
        Description description = new Description();
        edimap.setDescription(description);

        description.setName(getAttributeValue(node, "name"));
        description.setVersion(getAttributeValue(node, "version"));

        String namespace = getAttributeValue(node, "namespace");
        if (namespace != null) {
            description.setNamespace(namespace);
        } else {
            description.setNamespace(XMLConstants.NULL_NS_URI);
        }
    }
View Full Code Here

        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

        return archive;
    }

    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");
    }
View Full Code Here

        List<MessageDefinition> messageSetDefinitions = new ArrayList<MessageDefinition>();
        Set<Map.Entry<String, EdifactModel>> modelSet = mappingModels.entrySet();
        StringBuilder rootClassesListFileBuilder = new StringBuilder();
        for(Map.Entry<String, EdifactModel> model : modelSet) {
            Description description = model.getValue().getDescription();

            if(description.equals(EDIUtils.MODEL_SET_DEFINITIONS_DESCRIPTION_LOOKUP_NAME)) {
                // Already done (above).  Skip it...
                continue;
            }

            if(messages == null || messages.contains(description.getName())) {
                EJC ejc = new EJC();

                ejc.include(commonsPackageName);
                ejc.addEDIMessageAnnotation(true);
                if(definitionsClassModel != null) {
                    String messagePackageName = packageName + "." + description.getName();
                    ClassModel classModel = ejc.compile(model.getValue().getEdimap(), messagePackageName, destDir.getAbsolutePath(), definitionsClassModel.getClassesByNode());

                    // If this is an interchange, get rid of the edi mapping model config and the
                    // Factory class for the message folder...
                    if(interchangeProperties != null) {
                        MessageDefinition messageDef = new MessageDefinition(description.getName(), "/" + messagePackageName.replace('.', '/') + "/" + EJC.BINDINGCONFIG_XML);
                        messageSetDefinitions.add(messageDef);

                        deleteFile(messagePackageName, EJC.EDIMAPPINGCONFIG_XML);
                        deleteFile(messagePackageName, EDIUtils.encodeClassName(description.getName()) + "Factory.java");

                        JClass beanClass = classModel.getRootBeanConfig().getBeanClass();
                        rootClassesListFileBuilder.append(beanClass.getPackageName()).append(".").append(beanClass.getClassName()).append("\n");
                    }
                } else {
View Full Code Here

    }

    private Edimap createEdimap() {
        Edimap edimap = new Edimap();

        Description description = new Description();
        description.setName("Custom Config Reader");
        description.setVersion("1.0");
        edimap.setDescription(description);

        Delimiters delimiters = new Delimiters();
        delimiters.setSegment("'");
        delimiters.setField("+");
View Full Code Here

     * @throws EDIConfigurationException when edi-mapping-configuration is incorrect.
     */
    public static EdifactModel parseMappingModel(String mappingConfig, URI baseURI) throws IOException, SAXException, EDIConfigurationException {
        String[] mappingConfigTokens = mappingConfig.split("!");
        String ediMappingModel;
        Description mappingDescription = null;

        if(mappingConfigTokens.length == 1) {
            ediMappingModel = mappingConfigTokens[0];
        } else if(mappingConfigTokens.length == 3) {
            ediMappingModel = mappingConfigTokens[0];
            mappingDescription = new Description().setName(mappingConfigTokens[1]).setVersion(mappingConfigTokens[2]);           
        } else if(mappingConfigTokens.length == 4) {
            ediMappingModel = mappingConfigTokens[0];
            mappingDescription = new Description().setName(mappingConfigTokens[1]).setVersion(mappingConfigTokens[2]).setNamespace(mappingConfigTokens[3]);
        } else {
            throw new EDIConfigurationException("Invalid mapping model configuration '" + mappingConfig + "'.  Must contain either 1 or 3 tokens.");
        }

        if(isValidURI(ediMappingModel)) {
View Full Code Here

        controlSegmentParser.setNamespaceDeclarationStack(this.namespaceDeclarationStack);

        Edimap controlMap = new Edimap();
        EdifactModel controlModel = new EdifactModel(controlMap);

        controlMap.setDescription(new Description().setName("EDI Message Interchange Control Model").setVersion("N/A"));
        controlSegmentParser.setMappingModel(controlModel);
    }
View Full Code Here

   * @param mapModel
   * @return
   */
  public static EPackage mappingModelToEPackage(Edimap mapModel) {
    final EPackage pkg = EcoreFactory.eINSTANCE.createEPackage();
    Description desc = mapModel.getDescription();
    pkg.setName(desc.getName().toLowerCase());
    pkg.setNsPrefix(desc.getName().toLowerCase());
    pkg.setNsURI(desc.getNamespace());
    if (mapModel.getSrc() != null) {
      annotate(pkg, "src", mapModel.getSrc().toASCIIString());
    }
    annotate(pkg, "description.name", mapModel.getDescription().getName());
    annotate(pkg, "description.version", mapModel.getDescription()
View Full Code Here

            delimiters.setComponent(DELIMITER_DATA);
            delimiters.setSubComponent(DELIMITER_NOT_USED);
            delimiters.setEscape(ESCAPE);
            edimap.setDelimiters(delimiters);

            edimap.setDescription(new Description());
            edimap.getDescription().setName(type);
            edimap.getDescription().setVersion(version + ":" + release + ":" + agency);
            edimap.getDescription().setNamespace(ControlBlockHandlerFactory.NAMESPACE_ROOT + ":" + agency.toLowerCase() + ":" + version.toLowerCase() + release.toLowerCase() + ":" + type.toLowerCase());

            Map<String, Segment> segmentDefinitions = null;
View Full Code Here

TOP

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

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.