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

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


  private void updateBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) {
    String jcrName = null;
    Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
    while (beanDescriptorIterator.hasNext())
    {
      BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
      if (!beanDescriptor.isAutoUpdate()) {
        continue;
      }

      jcrName = beanDescriptor.getJcrName();
      Object bean = ReflectionUtils.getNestedProperty(object, beanDescriptor.getFieldName());

      String converterClassName = null;
      if (null == beanDescriptor.getConverter() || "".equals(beanDescriptor.getConverter()))
      {
        converterClassName = DEFAULT_BEAN_CONVERTER;
      }
      else
      {
        converterClassName = beanDescriptor.getConverter();
      }

      Object[] param = {this.mapper, this, this.atomicTypeConverterProvider };
      BeanConverter beanConverter = (BeanConverter) ReflectionUtils.invokeConstructor(converterClassName, param);
      Class beanClass = ReflectionUtils.getPropertyType(object, beanDescriptor.getFieldName());
      // if the bean is null, remove existing node
      if ((bean == null))
      {

        beanConverter.remove(session, objectNode, beanDescriptor, mapper.getClassDescriptorByClass(beanClass), bean, classDescriptor, object);
View Full Code Here


    descriptor.addCollectionDescriptor(collectionDescriptor);
  }
 
  private void addBeanDescriptor(ClassDescriptor classDescriptor, String fieldName, Bean beanAnnotation) {
    BeanDescriptor beanDescriptor = new BeanDescriptor();
    beanDescriptor.setFieldName(fieldName);
    if (beanAnnotation.jcrName() != null && ! beanAnnotation.jcrName().equals(""))
    {
       beanDescriptor.setJcrName(beanAnnotation.jcrName());
    }
    else
    {
      beanDescriptor.setJcrName(fieldName);
    }
   
    beanDescriptor.setProxy(beanAnnotation.proxy());       
    beanDescriptor.setConverter(beanAnnotation.converter().getName());
    beanDescriptor.setAutoInsert(beanAnnotation.autoInsert());
    beanDescriptor.setAutoRetrieve(beanAnnotation.autoRetrieve());
    beanDescriptor.setAutoUpdate(beanAnnotation.autoUpdate());
    beanDescriptor.setJcrType(beanAnnotation.jcrType());
    beanDescriptor.setJcrAutoCreated(beanAnnotation.jcrAutoCreated());
    beanDescriptor.setJcrMandatory(beanAnnotation.jcrMandatory());
    beanDescriptor.setJcrOnParentVersion(beanAnnotation.jcrOnParentVersion());
    beanDescriptor.setJcrProtected(beanAnnotation.jcrProtected());                 
    beanDescriptor.setJcrSameNameSiblings(beanAnnotation.jcrSameNameSiblings());       

    classDescriptor.addBeanDescriptor(beanDescriptor);
  }
View Full Code Here

      FieldDescriptor fieldDescriptor = classDescriptor  .getFieldDescriptor("a1");
      assertNotNull("FieldDescriptor is null", fieldDescriptor);
      assertTrue("Invalid jcrName for field a1", fieldDescriptor.getJcrName().equals("a1"));

      BeanDescriptor beanDescriptor = classDescriptor.getBeanDescriptor("b");
      assertNotNull("BeanDescriptor is null", beanDescriptor);
      assertTrue("Invalid jcrName for field b", beanDescriptor  .getJcrName().equals("b"));     
      assertNotNull("Invalid bean default converter", beanDescriptor.getConverter());
     

      CollectionDescriptor collectionDescriptor = classDescriptor.getCollectionDescriptor("collection");
      assertNotNull("CollectionDescriptor is null", collectionDescriptor);
      assertTrue("Invalid jcrName for field collection",collectionDescriptor.getJcrName().equals("collection"));
View Full Code Here

          .getClassDescriptorByClass(A.class);
      assertNotNull("ClassDescriptor is null", classDescriptor2);
      assertTrue("Invalid classname", classDescriptor2.getClassName()
          .equals(A.class.getName()));

      BeanDescriptor beanDescriptor = classDescriptor2
          .getBeanDescriptor("b");
      assertNotNull(beanDescriptor);
      assertEquals(beanDescriptor.getFieldName(), "b");
      assertEquals(beanDescriptor.getJcrType(), "nt:unstructured");
      assertFalse(beanDescriptor.isJcrAutoCreated());
      assertFalse(beanDescriptor.isJcrMandatory());
      assertFalse(beanDescriptor.isJcrProtected());
      assertFalse(beanDescriptor.isJcrSameNameSiblings());
      assertEquals(beanDescriptor.getJcrOnParentVersion(), "IGNORE");

      CollectionDescriptor collectionDescriptor = classDescriptor2
          .getCollectionDescriptor("collection");
      assertNotNull(collectionDescriptor);
      assertEquals(collectionDescriptor.getJcrType(), "ocm:C");
View Full Code Here

      FieldDescriptor fieldDescriptor = classDescriptor  .getFieldDescriptor("a1");
      assertNotNull("FieldDescriptor is null", fieldDescriptor);
      assertTrue("Invalid jcrName for field a1", fieldDescriptor.getJcrName().equals("a1"));

      BeanDescriptor beanDescriptor = classDescriptor.getBeanDescriptor("b");
      assertNotNull("BeanDescriptor is null", beanDescriptor);
      assertTrue("Invalid jcrName for field b", beanDescriptor  .getJcrName().equals("b"));     
      assertNotNull("Invalid bean default converter", beanDescriptor.getConverter());
     

      CollectionDescriptor collectionDescriptor = classDescriptor.getCollectionDescriptor("collection");
      assertNotNull("CollectionDescriptor is null", collectionDescriptor);
      assertTrue("Invalid jcrName for field collection",collectionDescriptor.getJcrName().equals("collection"));
View Full Code Here

          .getClassDescriptorByClass(A.class);
      assertNotNull("ClassDescriptor is null", classDescriptor2);
      assertTrue("Invalid classname", classDescriptor2.getClassName()
          .equals(A.class.getName()));

      BeanDescriptor beanDescriptor = classDescriptor2
          .getBeanDescriptor("b");
      assertNotNull(beanDescriptor);
      assertEquals(beanDescriptor.getFieldName(), "b");
      assertEquals(beanDescriptor.getJcrType(), "nt:unstructured");
      assertFalse(beanDescriptor.isJcrAutoCreated());
      assertFalse(beanDescriptor.isJcrMandatory());
      assertFalse(beanDescriptor.isJcrProtected());
      assertFalse(beanDescriptor.isJcrSameNameSiblings());
      assertEquals(beanDescriptor.getJcrOnParentVersion(), "IGNORE");

      CollectionDescriptor collectionDescriptor = classDescriptor2
          .getCollectionDescriptor("collection");
      assertNotNull(collectionDescriptor);
      assertEquals(collectionDescriptor.getJcrType(), "ocm:C");
View Full Code Here

            }
    }
  }

  private void addBeanDescriptor(ClassDescriptor classDescriptor, String fieldName, Bean beanAnnotation) {
    BeanDescriptor beanDescriptor = new BeanDescriptor();
    beanDescriptor.setFieldName(fieldName);
    if (beanAnnotation.jcrName() != null && ! beanAnnotation.jcrName().equals(""))
    {
       beanDescriptor.setJcrName(beanAnnotation.jcrName());
    }
    else
    {
      beanDescriptor.setJcrName(fieldName);
    }

    beanDescriptor.setProxy(beanAnnotation.proxy());
    beanDescriptor.setConverter(beanAnnotation.converter().getName());
    beanDescriptor.setAutoInsert(beanAnnotation.autoInsert());
    beanDescriptor.setAutoRetrieve(beanAnnotation.autoRetrieve());
    beanDescriptor.setAutoUpdate(beanAnnotation.autoUpdate());
    beanDescriptor.setJcrType(beanAnnotation.jcrType());
    beanDescriptor.setJcrAutoCreated(beanAnnotation.jcrAutoCreated());
    beanDescriptor.setJcrMandatory(beanAnnotation.jcrMandatory());
    beanDescriptor.setJcrOnParentVersion(beanAnnotation.jcrOnParentVersion());
    beanDescriptor.setJcrProtected(beanAnnotation.jcrProtected());
    beanDescriptor.setJcrSameNameSiblings(beanAnnotation.jcrSameNameSiblings());

    classDescriptor.addBeanDescriptor(beanDescriptor);
  }
View Full Code Here

                    }

                    if (classDescriptor.getBeanDescriptors() != null) {
                        Iterator beanIterator = classDescriptor.getBeanDescriptors().iterator();
                        while (beanIterator.hasNext()) {
                            BeanDescriptor field = (BeanDescriptor) beanIterator.next();
                            if (this.isPropertyType(field.getJcrType())) {
                                final PropertyDefinitionTemplate pdt = getPropertyDefinition(ntm, session.getValueFactory(), field);
                                // add the just created pdt to the nodetypetemplate
                                propertyDefinitionTemplates.add(pdt);
                            } else {
                                final NodeDefinitionTemplate ndt = getNodeDefinition(ntm, session.getValueFactory(), field);
                                // add the just created pdt to the nodetypetemplate
                                nodeDefinitionTemplates.add(ndt);
                            }
                        }
                    }

                    if (classDescriptor.getCollectionDescriptors() != null) {
                        Iterator collectionIterator = classDescriptor.getCollectionDescriptors().iterator();
                        while (collectionIterator.hasNext()) {
                            CollectionDescriptor field = (CollectionDescriptor) collectionIterator.next();
                            if (this.isPropertyType(field.getJcrType())) {
                                final PropertyDefinitionTemplate pdt = getPropertyDefinition(ntm, session.getValueFactory(), field);
                                // add the just created pdt to the nodetypetemplate
                                propertyDefinitionTemplates.add(pdt);
                            } else {
                                final NodeDefinitionTemplate ndt = getNodeDefinition(ntm, session.getValueFactory(), field);
View Full Code Here

    try {
      classDescriptor = getClassDescriptor(object.getClass());
      String pathFieldName = classDescriptor.getPathFieldDescriptor().getFieldName();
      path = (String) ReflectionUtils.getNestedProperty(object, pathFieldName);
      Node node = session.getNode(path);
      BeanDescriptor beanDescriptor = classDescriptor.getBeanDescriptor(attributeName);
      if (beanDescriptor != null)
      {
        this.retrieveBeanField(session, beanDescriptor, node, object, true);
      }
      // Check if the attribute is a collection
View Full Code Here

  private void retrieveBeanFields(Session session, ClassDescriptor classDescriptor, Node node, Object object,
      boolean forceToRetrieve) {
    Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
    while (beanDescriptorIterator.hasNext()) {
      BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
      this.retrieveBeanField(session, beanDescriptor, node, object, forceToRetrieve);
    }
  }
View Full Code Here

TOP

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

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.