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

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


  }

  private ClassDescriptor buildClassDescriptor(MappingDescriptor mappingDescriptor, Class clazz)
  {
    ClassDescriptor classDescriptor = null;

    Node nodeAnnotation =  (Node) clazz.getAnnotation(Node.class);
    if (nodeAnnotation != null)
    {
      classDescriptor = createClassDescriptor(clazz, nodeAnnotation);
View Full Code Here


  }

  private ClassDescriptor createClassDescriptor(Class clazz, Node nodeAnnotation)
  {
    ClassDescriptor classDescriptor = new ClassDescriptor();
    classDescriptor.setClassName(clazz.getName());
    classDescriptor.setJcrType(nodeAnnotation.jcrType());
    classDescriptor.setDiscriminator(nodeAnnotation.discriminator());
    if (nodeAnnotation.jcrSuperTypes() != null && ! nodeAnnotation.jcrSuperTypes().equals(""))
    {
         classDescriptor.setJcrSuperTypes(nodeAnnotation.jcrSuperTypes());
    }

    if (nodeAnnotation.jcrMixinTypes() != null && ! nodeAnnotation.jcrMixinTypes().equals(""))
    {
         classDescriptor.setJcrMixinTypes(nodeAnnotation.jcrMixinTypes());
    }

    Class ancestorClass = ReflectionUtils.getAncestorClass(clazz);
    if (ancestorClass != null)
    {
      classDescriptor.setExtend(ancestorClass.getName());
    }
     
    // TODO : Can we still support the extend param in the annotation @Node if we are using
    //        the reflection to get the ancestor class ? (see the previous if)
    if (nodeAnnotation.extend() != null && ! nodeAnnotation.extend().equals(Object.class))
    {
         classDescriptor.setExtend(nodeAnnotation.extend().getName());
    }

   
    classDescriptor.setAbstract(nodeAnnotation.isAbstract()||ReflectionUtils.isAbstractClass(clazz) );
    classDescriptor.setInterface(clazz.isInterface());
    return classDescriptor;
  }
View Full Code Here

        assertTrue(containsPropertyDefintion(test1.getPropertyDefinitions(), "ocm:testProperty"));
    }

    public void testCreateSingleNodeType() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.TestClass");
        classDescriptor.setJcrType("ocm:test2");
        classDescriptor.setJcrSuperTypes("nt:base");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("ocm:a");
        field1.setJcrType("String");
        field1.setJcrAutoCreated(true);
        field1.setJcrMandatory(true);
        field1.setJcrMultiple(true);
        classDescriptor.addFieldDescriptor(field1);

        FieldDescriptor field2 = new FieldDescriptor();
        field2.setFieldName("b");
        field2.setJcrName("ocm:b");
        field2.setJcrType("Long");
        field1.setJcrAutoCreated(false);
        field1.setJcrMandatory(true);
        field1.setJcrMultiple(false);
        classDescriptor.addFieldDescriptor(field2);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);

        NodeType testNodeType = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test2");
        assertNotNull(testNodeType);
View Full Code Here

        // TODO test all properties
    }

    public void testCreateSingleNodeTypeNoNamespace() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test3Class");
        classDescriptor.setJcrType("test3");
        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 test3 = session.getWorkspace().getNodeTypeManager().getNodeType("test3");
        assertNotNull(test3);
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.