Package oracle.toplink.essentials.internal.ejb.cmp3.xml

Examples of oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper


     */
    public Set<String> buildPersistenceUnitClassSetFromXMLDocuments() {
        HashSet<String> classSet = new HashSet<String>();
       
        for (Map.Entry<URL, Document> urlToDoc : m_project.getMappingFiles().entrySet()) {
            XMLHelper helper = new XMLHelper(urlToDoc.getValue(), urlToDoc.getKey().getFile(), m_loader);
       
            // Process the package node.
            String defaultPkg = helper.getNodeValue(new String[] {XMLConstants.ENTITY_MAPPINGS, XMLConstants.PACKAGE, XMLConstants.TEXT});

            // Handle entities only unless otherwise specified to.
            classSet.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.ENTITY, defaultPkg));
            classSet.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.EMBEDDABLE, defaultPkg));
            classSet.addAll(buildEntityClassSetForNodeList(helper, XMLConstants.MAPPED_SUPERCLASS, defaultPkg));
View Full Code Here


     * Process the xml and fill in the project. Process the entity-mappings
     * information then process the entities.
     */
    private void processMappingFile(Document document, String fileName) {
        if (m_project.hasDescriptors()) {
            XMLHelper helper = new XMLHelper(document, fileName, m_loader);

            // Process the entity mappings ... this is a crude way of doing
            // things ... but hey ... the clock is ticking ...
            MetadataDescriptor desc = m_project.getDescriptors().iterator().next();
            XMLClassAccessor dummyAccessor = new XMLClassAccessor(new MetadataClass(desc.getJavaClass()), null, helper, this, desc);
            dummyAccessor.processEntityMappings();

            // Process the entity nodes for this xml document.
            NodeList entityNodes = helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.ENTITY);

            if (entityNodes != null) {
                for (int i = 0; i < entityNodes.getLength(); i++) {
                    Node entityNode = entityNodes.item(i);
                    Class entityClass = helper.getClassForNode(entityNode);
                    MetadataDescriptor descriptor = m_project.getDescriptor(entityClass);

                    // Process all descriptors that are in our project.
                    ClassAccessor accessor = descriptor.getClassAccessor();

View Full Code Here

        }

        // Iterate though the classes that are defined in XML.
        for (Map.Entry<URL, Document> urlToDoc : m_project.getMappingFiles().entrySet()) {
            //classSet.addAll(buildEntityClassSetFromXMLDocument(urlToDoc.getValue(), urlToDoc.getKey().getFile(), m_loader, includeMappedSuperclasses, includeEmbeddables));
            XMLHelper helper = new XMLHelper(urlToDoc.getValue(), urlToDoc.getKey().getFile(), m_loader);
       
            // Process the package node.
            String defaultPkg = helper.getNodeValue(new String[] {XMLConstants.ENTITY_MAPPINGS, XMLConstants.PACKAGE, XMLConstants.TEXT});

            // Add the entities to the entity and weavable class list.
            Set<String> xmlEntityClassNames = buildEntityClassSetForNodeList(helper, XMLConstants.ENTITY, defaultPkg);
            entityClassNames.addAll(xmlEntityClassNames);
            weavableClassNames.addAll(xmlEntityClassNames);
View Full Code Here

     public void processPersistenceUnitMetadata() {
        // For each orm xml instance document, process persistence unit
        // metadata/defaults and mapped superclasses.
        for (Map.Entry<URL, Document> mfDocPair : m_project.getMappingFiles().entrySet()) {
            // Initialize a helper for navigating the instance document.
            XMLHelper helper = new XMLHelper(mfDocPair.getValue(), mfDocPair.getKey().getFile(), m_loader);

            // Store all mapped-superclasses.
            NodeList nodes = helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.MAPPED_SUPERCLASS);

            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);
                Class cls = helper.getNodeValue(nodes.item(i), XMLConstants.ATT_CLASS, void.class);
                m_project.addMappedSuperclass(cls, node, helper);
            }

            // Store all embeddable classes.
            nodes = helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.EMBEDDABLE);

            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);
                Class cls = helper.getNodeValue(nodes.item(i), XMLConstants.ATT_CLASS, void.class);
                m_project.addEmbeddable(cls, node, helper);
            }

            // Look for a persistence-unit-metadata node.
            Node persistenceUnitMetadataNode = helper.getNode(new String[] {XMLConstants.ENTITY_MAPPINGS, XMLConstants.PU_METADATA});

            if (persistenceUnitMetadataNode != null) {
                MetadataPersistenceUnit persistenceUnit = new MetadataPersistenceUnit();

                // Process the xml-mapping-metadata-complete tag.
                persistenceUnit.setIsMetadataComplete(helper.getNode(persistenceUnitMetadataNode, XMLConstants.METADATA_COMPLETE) != null);

                // process persistence unit defaults
                Node persistenceUnitDefaultsNode = helper.getNode(persistenceUnitMetadataNode, XMLConstants.PU_DEFAULTS);

                if (persistenceUnitDefaultsNode != null) {
                    // Process the persistence unit access.
                    persistenceUnit.setAccess(helper.getNodeTextValue(persistenceUnitDefaultsNode, XMLConstants.ACCESS));

                    // Process the persitence unit schema.
                    persistenceUnit.setSchema(helper.getNodeTextValue(persistenceUnitDefaultsNode, XMLConstants.SCHEMA));

                    // Process the persistence unit catalog.
                    persistenceUnit.setCatalog(helper.getNodeTextValue(persistenceUnitDefaultsNode, XMLConstants.CATALOG));

                    // Process the persistence unit cascade-persist.
                    persistenceUnit.setIsCascadePersist(helper.getNode(persistenceUnitDefaultsNode, XMLConstants.CASCADE_PERSIST) != null);

                    // Process the default entity-listeners. No conflict
                    // checking will be done, that is, any and all
                    // default listeners will be added to the project.
                    NodeList listenerNodes = helper.getNodes(persistenceUnitDefaultsNode, XMLConstants.ENTITY_LISTENERS, XMLConstants.ENTITY_LISTENER);
                    if (listenerNodes != null) {
                        m_project.addDefaultListeners(listenerNodes, helper);
                    }
                }
View Full Code Here

        Class embeddableClass = embeddableDescriptor.getJavaClass();

        if (m_project.hasEmbeddable(embeddableClass)) {
            Node node = m_project.getEmbeddableNode(embeddableClass);
            XMLHelper helper = m_project.getEmbeddableHelper(embeddableClass);
            embeddableAccessor = new XMLClassAccessor(new MetadataClass(embeddableClass), node, helper, m_processor, embeddableDescriptor);
        } else if (MetadataHelper.isAnnotationPresent(Embeddable.class, embeddableClass, embeddableDescriptor)) {
            embeddableAccessor = new ClassAccessor(new MetadataClass(embeddableClass), m_processor, embeddableDescriptor);
        } else {
            m_validator.throwInvalidEmbeddedAttribute(getJavaClass(), m_accessibleObject.getName(), embeddableClass);
View Full Code Here

        // step #2: what's specified in <embeddable> element

        Class javaClass = descriptor.getJavaClass();

        if (m_project.hasEmbeddable(javaClass)) {
            XMLHelper helper = m_project.getEmbeddableHelper(javaClass);
            Node node = m_project.getEmbeddableNode(javaClass);
            // override pu-level value by <embeddable> level if any
            // Note, we pass the puLevel value as the default value
            access = helper.getNodeValue(node, XMLConstants.ATT_ACCESS, access);
        }

        AccessType accessType = UNDEFINED;

        if (access != null && access.length() != 0) {
View Full Code Here

        boolean metadataComplete = m_project.getPersistenceUnit() != null ? m_project.getPersistenceUnit().isMetadataComplete() : false;

        if (!metadataComplete) {
            // check <embeddable>
            if (m_project.hasEmbeddable(emClass)) {
                XMLHelper helper = m_project.getEmbeddableHelper(emClass);
                Node node = m_project.getEmbeddableNode(emClass);
                // check if metadata-complete at <embeddable> level
                metadataComplete = helper.getNodeValue(node, XMLConstants.ATT_METADATA_COMPLETE, false);
            }
        }

        return metadataComplete;
    }
View Full Code Here

        } else if (nodeName.equals(XMLConstants.EMBEDDED_ID)) {
            return new XMLEmbeddedIdAccessor(accessibleObject, node, this);
        } else if (nodeName.equals(XMLConstants.TRANSIENT)) {
            return new XMLTransientAccessor(accessibleObject, node, this);
        } else {
            return new XMLBasicAccessor(accessibleObject, node, this);
        }
    }
View Full Code Here

            } else {
                m_validator.throwInvalidCollectionTypeForRelationship(getJavaClass(), accessibleObject.getRawClass(), getAttributeName());
                return null;
            }
        } else if (nodeName.equals(XMLConstants.EMBEDDED)) {
            return new XMLEmbeddedAccessor(accessibleObject, node, this);
        } else if (nodeName.equals(XMLConstants.EMBEDDED_ID)) {
            return new XMLEmbeddedIdAccessor(accessibleObject, node, this);
        } else if (nodeName.equals(XMLConstants.TRANSIENT)) {
            return new XMLTransientAccessor(accessibleObject, node, this);
        } else {
View Full Code Here

                m_validator.throwInvalidCollectionTypeForRelationship(getJavaClass(), accessibleObject.getRawClass(), getAttributeName());
                return null;
            }
        } else if (nodeName.equals(XMLConstants.MANY_TO_MANY)) {
            if (MetadataHelper.isSupportedCollectionClass(accessibleObject.getRawClass())) {
                return new XMLManyToManyAccessor(accessibleObject, node, this);
            } else {
                m_validator.throwInvalidCollectionTypeForRelationship(getJavaClass(), accessibleObject.getRawClass(), getAttributeName());
                return null;
            }
        } else if (nodeName.equals(XMLConstants.EMBEDDED)) {
View Full Code Here

TOP

Related Classes of oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper

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.