Package org.apache.jackrabbit.ocm.mapper.model

Examples of org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor


            eventType = this.parser.next();
        }
    }

    private ClassDescriptor parseClassDescriptor() throws XmlPullParserException {
        ClassDescriptor fd = new ClassDescriptor();

        /*
         * className CDATA #REQUIRED
         * jcrType CDATA #IMPLIED
         * jcrSuperTypes CDATA #IMPLIED
         * jcrMixinTypes CDATA #IMPLIED
         * extend CDATA #IMPLIED
         * abstract (true|false) "false"
         * interface (true|false) "false"
         * discriminator (true|false) "true"
         */

        fd.setClassName(this.getRequiredAttribute("className"));
        fd.setJcrType(this.getOptionalAttribute("jcrType"));
        fd.setJcrSuperTypes(this.getOptionalAttribute("jcrSuperTypes"));
        fd.setJcrMixinTypes(this.getOptionalAttribute("jcrMixinTypes", (String[]) null));

        fd.setExtend(this.getOptionalAttribute("extend"));

        fd.setAbstract(this.getOptionalAttribute("abstract", false));
        fd.setInterface(this.getOptionalAttribute("interface", false));
        fd.setDiscriminator(this.getOptionalAttribute("discriminator", true));

        return fd;
    }
View Full Code Here


    private List<String> solveReferences(List<String> errors, List<ClassDescriptor> rootClassDescriptors) {
        Set<ClassDescriptor> toRemove = new HashSet<ClassDescriptor>();
        for( ClassDescriptor cd : (Collection<ClassDescriptor>)this.descriptors.getClassDescriptorsByClassName().values() ) {

            if (null != cd.getExtend() && !"".equals(cd.getExtend())) {
                ClassDescriptor superClassDescriptor = this.descriptors.getClassDescriptorByName(cd.getExtend());

                if (superClassDescriptor == null) {
                    log.warn("Dropping class {}: Base class {} not registered", cd.getClassName(), cd.getExtend());
                    toRemove.add(cd);
//                    errors.add("Cannot find mapping for class "
//                        + cd.getExtend() + " referenced as extends from "
//                        + cd.getClassName());
                } else {
                    log.debug("Class {} extends {}", cd.getClassName(), cd.getExtend());
                    cd.setSuperClassDescriptor(superClassDescriptor);
                }
            } else {
                log.debug("Class {} is a root class", cd.getClassName());
                rootClassDescriptors.add(cd);
            }

            @SuppressWarnings("unchecked")
            Collection<String> interfaces = cd.getImplements();
            for (String interfaceName : interfaces) {
                ClassDescriptor interfaceClassDescriptor = this.descriptors.getClassDescriptorByName(interfaceName);

                if (interfaceClassDescriptor == null) {
                    log.warn("Dropping class {}: Interface class {} not registered", cd.getClassName(), interfaceName);
                    toRemove.add(cd);
//                        errors.add("Cannot find mapping for interface "
//                            + interfaceName + " referenced as implements from "
//                            + cd.getClassName());
                } else {
                    log.debug("Class " + cd.getClassName() + " implements "
                        + interfaceName);
                    //cd.setSuperClassDescriptor(interfaceClassDescriptor);
                    interfaceClassDescriptor.addDescendantClassDescriptor(cd);
                }

            }

        }
View Full Code Here

            eventType = this.parser.next();
        }
    }

    private ClassDescriptor parseClassDescriptor() throws XmlPullParserException {
        ClassDescriptor fd = new ClassDescriptor();

        /*
         * className CDATA #REQUIRED
         * jcrType CDATA #IMPLIED
         * jcrSuperTypes CDATA #IMPLIED
         * jcrMixinTypes CDATA #IMPLIED
         * extend CDATA #IMPLIED
         * abstract (true|false) "false"
         * interface (true|false) "false"
         * discriminator (true|false) "true"
         */

        fd.setClassName(this.getRequiredAttribute("className"));
        fd.setJcrType(this.getOptionalAttribute("jcrType"));
        fd.setJcrSuperTypes(this.getOptionalAttribute("jcrSuperTypes"));
        fd.setJcrMixinTypes(this.getOptionalAttribute("jcrMixinTypes", (String[]) null));

        fd.setExtend(this.getOptionalAttribute("extend"));

        fd.setAbstract(this.getOptionalAttribute("abstract", false));
        fd.setInterface(this.getOptionalAttribute("interface", false));
        fd.setDiscriminator(this.getOptionalAttribute("discriminator", true));

        return fd;
    }
View Full Code Here

    private List<String> solveReferences(List<String> errors, List<ClassDescriptor> rootClassDescriptors) {
        Set<ClassDescriptor> toRemove = new HashSet<ClassDescriptor>();
        for( ClassDescriptor cd : (Collection<ClassDescriptor>)this.descriptors.getClassDescriptorsByClassName().values() ) {

            if (null != cd.getExtend() && !"".equals(cd.getExtend())) {
                ClassDescriptor superClassDescriptor = this.descriptors.getClassDescriptorByName(cd.getExtend());

                if (superClassDescriptor == null) {
                    log.warn("Dropping class {}: Base class {} not registered", cd.getClassName(), cd.getExtend());
                    toRemove.add(cd);
//                    errors.add("Cannot find mapping for class "
//                        + cd.getExtend() + " referenced as extends from "
//                        + cd.getClassName());
                } else {
                    log.debug("Class {} extends {}", cd.getClassName(), cd.getExtend());
                    cd.setSuperClassDescriptor(superClassDescriptor);
                }
            } else {
                log.debug("Class {} is a root class", cd.getClassName());
                rootClassDescriptors.add(cd);
            }

            Collection<String> interfaces = cd.getImplements();
            for (String interfaceName : interfaces) {
                ClassDescriptor interfaceClassDescriptor = this.descriptors.getClassDescriptorByName(interfaceName);

                if (interfaceClassDescriptor == null) {
                    log.warn("Dropping class {}: Interface class {} not registered", cd.getClassName(), interfaceName);
                    toRemove.add(cd);
//                        errors.add("Cannot find mapping for interface "
//                            + interfaceName + " referenced as implements from "
//                            + cd.getClassName());
                } else {
                    log.debug("Class " + cd.getClassName() + " implements "
                        + interfaceName);
                    //cd.setSuperClassDescriptor(interfaceClassDescriptor);
                    interfaceClassDescriptor.addDescendantClassDescriptor(cd);
                }

            }

        }
View Full Code Here

        assertEquals(test3.getSupertypes()[0].getName(), "nt:base");       
    }
   
    public void testCreateSingleNodeTypeNoJcrNodeTypeSet() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test4Class");
        classDescriptor.setJcrSuperTypes("nt:base");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("a");
        field1.setJcrType("String");
        classDescriptor.addFieldDescriptor(field1);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
       
        NodeType test4 = session.getWorkspace().getNodeTypeManager().getNodeType("test.Test4Class");
        assertNotNull(test4);
View Full Code Here

        assertEquals(test4.getSupertypes()[0].getName(), "nt:base");       
    }
   
    public void testCreateSingleNodeTypeIncompleteFieldDescriptorProperties() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test5Class");
        classDescriptor.setJcrType("ocm:test5");
        classDescriptor.setJcrSuperTypes("ocm:test2");
       
        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("abc");
        classDescriptor.addFieldDescriptor(field1);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
       
        NodeType test5 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test5");
        assertNotNull(test5);
View Full Code Here

        assertTrue(containsProperty("abc", test5.getPropertyDefinitions()));
    }
   
    public void testCreateSingleNodeTypeNtNamespace() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test6Class");
        classDescriptor.setJcrType("nt:test3");
        classDescriptor.setJcrSuperTypes("nt:base");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("a");
        field1.setJcrType("String");
        classDescriptor.addFieldDescriptor(field1);
       
        boolean failed = false;
       
        try
        {
View Full Code Here

        assertTrue(failed);
    }
   
    public void testCreateSingleNodeTypeWithPropertyForCollection() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test9Class");
        classDescriptor.setJcrType("ocm:test9");
        classDescriptor.setJcrSuperTypes("nt:base");
       
        CollectionDescriptor collection1 = new CollectionDescriptor();
        collection1.setFieldName("a");
        collection1.setJcrName("a");
        collection1.setJcrType("String");
       
        classDescriptor.addCollectionDescriptor(collection1);
       
        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
       
        NodeType test9 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test9");
        assertNotNull(test9);
View Full Code Here

        assertEquals(propDef.getRequiredType(), PropertyType.STRING);
    }
   
    public void testCreateSingleNodeTypeWithPropertyForBean() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test10Class");
        classDescriptor.setJcrType("ocm:test10");
        classDescriptor.setJcrSuperTypes("nt:base");
       
        BeanDescriptor bean1 = new BeanDescriptor();
        bean1.setFieldName("a");
        bean1.setJcrName("a");
        bean1.setJcrType("String");
        classDescriptor.addBeanDescriptor(bean1);
       
        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
       
        NodeType test10 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test10");
        assertNotNull(test10);
View Full Code Here

       
    }
   
    public void testCreateSingleNodeTypeWithPropertyForCollectionDefinitionConflict() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test13Class");
        classDescriptor.setJcrType("ocm:test13");
        classDescriptor.setJcrSuperTypes("nt:base");

        CollectionDescriptor collection1 = new CollectionDescriptor();
        collection1.setFieldName("a");
        collection1.setJcrName("a");
        collection1.setJcrType("String");           
        classDescriptor.addCollectionDescriptor(collection1);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
       
        NodeType test13 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test13");
        assertNotNull(test13);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor

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.