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

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


        assertEquals(propDef.getRequiredType(), PropertyType.STRING);
    }
   
    public void testCreateSingleNodeTypeWithPropertyForBeanDefinitionConflict() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test14Class");
        classDescriptor.setJcrType("ocm:test14");
        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 test14 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test14");
        assertNotNull(test14);
View Full Code Here


    }
   
    public void testCreateSingleNodeTypeWithChildNodeForCollection() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test11Class");
        classDescriptor.setJcrType("ocm:test11");
        classDescriptor.setJcrSuperTypes("nt:base");

        CollectionDescriptor collection1 = new CollectionDescriptor();
        collection1.setFieldName("a");
        collection1.setJcrName("b");
        collection1.setJcrType("nt:unstructured");
        classDescriptor.addCollectionDescriptor(collection1);

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

        assertEquals(nodeDef.getRequiredPrimaryTypes()[0].getName(), "nt:unstructured");
    }
   
    public void testCreateSingleNodeTypeWithChildNodeForBean() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test12Class");
        classDescriptor.setJcrType("ocm:test12");
        classDescriptor.setJcrSuperTypes("nt:base");

        BeanDescriptor bean1 = new BeanDescriptor();
        bean1.setFieldName("a");
        bean1.setJcrName("b");
        bean1.setJcrType("nt:unstructured");
        classDescriptor.addBeanDescriptor(bean1);

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

        assertEquals(nodeDef.getRequiredPrimaryTypes()[0].getName(), "nt:unstructured");
    }
   
    public void testCreateNodeTypes() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test6Class");
        classDescriptor.setJcrType("ocm:test6");
        classDescriptor.setJcrSuperTypes("nt:base");
       
        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("ocm:a");
        field1.setJcrType("String");
        classDescriptor.addFieldDescriptor(field1);

        FieldDescriptor field2 = new FieldDescriptor();
        field2.setFieldName("b");
        field2.setJcrName("ocm:b");
        field2.setJcrType("Long");
        classDescriptor.addFieldDescriptor(field2);
       
        ClassDescriptor classDescriptor2 = new ClassDescriptor();
        classDescriptor2.setClassName("test.Test7Class");
        classDescriptor2.setJcrType("ocm:test7");
        classDescriptor2.setJcrSuperTypes("nt:base");
       
        FieldDescriptor field3 = new FieldDescriptor();
        field3.setFieldName("a");
        field3.setJcrName("ocm:a");
        field3.setJcrType("String");
        classDescriptor2.addFieldDescriptor(field3);

        FieldDescriptor field4 = new FieldDescriptor();
        field4.setFieldName("b");
        field4.setJcrName("ocm:b");
        field4.setJcrType("Long");
        classDescriptor2.addFieldDescriptor(field4);
       
        ClassDescriptor[] classDescriptorArray = new ClassDescriptor[2];
        classDescriptorArray[0] = classDescriptor;
        classDescriptorArray[1] = classDescriptor2;
       
View Full Code Here

        assertNotNull(test7);
    }
   
    public void testRemoveSingleNodeType() throws Exception
    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test8Class");
        classDescriptor.setJcrType("ocm:test8");
        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 test8 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test8");
        assertNotNull(test8);
View Full Code Here

     * @see org.apache.jackrabbit.ocm.manager.ObjectContentManager#isPersistent(java.lang.Class)
     */
    public boolean isPersistent(final Class clazz) {

        try {
            ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(clazz);
            return true;
        } catch (IncorrectPersistentClassException e) {
            return false;
        }

View Full Code Here


    protected List solveReferences(List errors) {
        for(Iterator it = this.mappingDescriptor.getClassDescriptorsByClassName().entrySet().iterator(); it.hasNext(); ) {
            Map.Entry entry = (Map.Entry) it.next();
            ClassDescriptor cd = (ClassDescriptor) entry.getValue();

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

                if (null == superClassDescriptor)
                {
                    errors.add("Cannot find mapping for class "
                            + cd.getExtend()
                            + " referenced as extends from "
                            + cd.getClassName());
                }
                else
                {
                     log.debug("Class " +cd.getClassName() " extends " + cd.getExtend());
                    cd.setSuperClassDescriptor(superClassDescriptor);
                }
            }
            else
            {
                   rootClassDescriptors.add(cd);
            }
           
            Collection interfaces = cd.getImplements();
            if (interfaces.size() > 0)
            { 
                    for (Iterator iterator = interfaces.iterator(); iterator.hasNext();)
                    {
                              String interfaceName= (String) iterator.next();
                          ClassDescriptor interfaceClassDescriptor = this.mappingDescriptor.getClassDescriptorByName(interfaceName);

                          if (null == interfaceClassDescriptor)
                          {
                              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

     * @param classDescriptors the ancestor classdescriptors
     * @return
     */
    protected List  validateDescriptors(List errors, Collection classDescriptors ) {
        for(Iterator it = classDescriptors.iterator(); it.hasNext(); ) {
            ClassDescriptor classDescriptor = (ClassDescriptor) it.next();
            try {
                classDescriptor.afterPropertiesSet();
                if (classDescriptor.hasDescendants()) {
                    errors = validateDescriptors(errors, classDescriptor.getDescendantClassDescriptors());
                }
            }
            catch(JcrMappingException jme) {
                log.warn("Mapping of class " + classDescriptor.getClassName() + " is invalid", jme);
                errors.add(jme.getMessage());
            }
        }
        return errors;
    }   
View Full Code Here

    /**
    *
    * @see org.apache.jackrabbit.ocm.mapper.Mapper#getClassDescriptorByClass(java.lang.Class)
    */
   public ClassDescriptor getClassDescriptorByClass(Class clazz) {
     ClassDescriptor descriptor = mappingDescriptor.getClassDescriptorByName(clazz.getName());
     if (descriptor==null) {
      throw new IncorrectPersistentClassException("Class of type: " + clazz.getName() + " has no descriptor.");
     }
       return descriptor ;
   }
View Full Code Here

  
   /**
   * @see org.apache.jackrabbit.ocm.mapper.Mapper#getClassDescriptorByNodeType(String)
   */
  public ClassDescriptor getClassDescriptorByNodeType(String jcrNodeType) {
    ClassDescriptor descriptor = mappingDescriptor.getClassDescriptorByNodeType(jcrNodeType);
     if (descriptor==null) {
      throw new IncorrectPersistentClassException("Node type: " + jcrNodeType + " has no descriptor.");
     }
      return descriptor ;     
  }  
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.