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

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


        this.retrieveBeanField(session, beanDescriptor, node, path, object, true);
      }
      // Check if the attribute is a collection
      else
      {
        CollectionDescriptor collectionDescriptor = classDescriptor.getCollectionDescriptor(attributeName);
        if (collectionDescriptor != null)
        {
          this.retrieveCollectionField(session, collectionDescriptor, node, object, true);
        }
        else
View Full Code Here


   */
  private void retrieveCollectionFields(Session session, ClassDescriptor classDescriptor, Node parentNode, Object object,
      boolean forceToRetrieve) {
    Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
    while (collectionDescriptorIterator.hasNext()) {
      CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
      this.retrieveCollectionField(session, collectionDescriptor, parentNode, object, forceToRetrieve);
    }
  }
View Full Code Here

  private void insertCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) {
    Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();

    while (collectionDescriptorIterator.hasNext()) {
      CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();

      if (!collectionDescriptor.isAutoInsert()) {
        continue;
      }

      CollectionConverter collectionConverter = this.getCollectionConverter(session, collectionDescriptor);
      Object collection = ReflectionUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
      ManageableObjects manageableCollection = ManageableObjectsUtil.getManageableObjects(collection);

      collectionConverter.insertCollection(session, objectNode, collectionDescriptor, manageableCollection);
    }
  }
View Full Code Here

  private void updateCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) {
    Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();

    while (collectionDescriptorIterator.hasNext()) {
      CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
      if (!collectionDescriptor.isAutoUpdate()) {
        continue;
      }

      CollectionConverter collectionConverter = this.getCollectionConverter(session, collectionDescriptor);
      Object collection = ReflectionUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
      ManageableObjects manageableCollection = ManageableObjectsUtil.getManageableObjects(collection);

      collectionConverter.updateCollection(session, objectNode, collectionDescriptor, manageableCollection);
    }
  }
View Full Code Here

  private void addCollectionDescriptor(MappingDescriptor mappingDescriptor, ClassDescriptor descriptor,
                                   java.lang.reflect.Field field, Collection collectionAnnotation) {

    Class targetClass = collectionAnnotation.elementClassName();
    CollectionDescriptor collectionDescriptor = new CollectionDescriptor();

    collectionDescriptor.setFieldName(field.getName());

    if (collectionAnnotation.jcrName() != null && ! collectionAnnotation.jcrName().equals(""))
    {
       collectionDescriptor.setJcrName(collectionAnnotation.jcrName());
    }
    else
    {
       collectionDescriptor.setJcrName(field.getName());
    }

    Node annotationNode = (Node) targetClass.getAnnotation(Node.class);
    collectionDescriptor.setProxy(collectionAnnotation.proxy());

    collectionDescriptor.setAutoInsert(collectionAnnotation.autoInsert());
    collectionDescriptor.setAutoRetrieve(collectionAnnotation.autoRetrieve());
    collectionDescriptor.setAutoUpdate(collectionAnnotation.autoUpdate());
    collectionDescriptor.setCollectionClassName(field.getType().getName());
    if (! collectionAnnotation.elementClassName().equals(Object.class))
    {
      collectionDescriptor.setElementClassName(collectionAnnotation.elementClassName().getName());
    }
    else
    {
      setElementClassName(collectionDescriptor, field.getGenericType());
    }

    collectionDescriptor.setJcrElementName(collectionAnnotation.jcrElementName());

    if (! collectionAnnotation.collectionClassName().equals(Object.class))
    {
      collectionDescriptor.setCollectionClassName(collectionAnnotation.collectionClassName().getName());
    }

    collectionDescriptor.setCollectionConverter(collectionAnnotation.collectionConverter().getName());
    if (annotationNode != null)
    {
        collectionDescriptor.setJcrType(annotationNode.jcrType());
    }
    collectionDescriptor.setJcrSameNameSiblings(collectionAnnotation.jcrSameNameSiblings());
    collectionDescriptor.setJcrAutoCreated(collectionAnnotation.jcrAutoCreated());
    collectionDescriptor.setJcrProtected(collectionAnnotation.jcrProtected());
    collectionDescriptor.setJcrOnParentVersion(collectionAnnotation.jcrOnParentVersion());
    collectionDescriptor.setJcrMandatory(collectionAnnotation.jcrMandatory());


    descriptor.addCollectionDescriptor(collectionDescriptor);
  }
View Full Code Here

      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"));
    } catch (JcrMappingException e) {
      e.printStackTrace();
      fail("Impossible to retrieve the converter " + e);
    }
  }
View Full Code Here

      assertFalse(beanDescriptor.isJcrMandatory());
      assertFalse(beanDescriptor.isJcrProtected());
      assertFalse(beanDescriptor.isJcrSameNameSiblings());
      assertEquals(beanDescriptor.getJcrOnParentVersion(), "IGNORE");

      CollectionDescriptor collectionDescriptor = classDescriptor2
          .getCollectionDescriptor("collection");
      assertNotNull(collectionDescriptor);
      assertEquals(collectionDescriptor.getJcrType(), "nt:unstructured");
      assertFalse(collectionDescriptor.isJcrAutoCreated());
      assertFalse(collectionDescriptor.isJcrMandatory());
      assertFalse(collectionDescriptor.isJcrProtected());
      assertFalse(collectionDescriptor.isJcrSameNameSiblings());
      assertEquals(collectionDescriptor.getJcrOnParentVersion(), "IGNORE");
     
      classDescriptor = mapper.getClassDescriptorByClass(OcmTestProperty.class);
      assertNotNull(classDescriptor);
      FieldDescriptor fieldDescriptor = classDescriptor.getFieldDescriptor("requiredWithConstraintsProp");
      assertNotNull(fieldDescriptor.getJcrValueConstraints());
View Full Code Here

        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);

        nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);
View Full Code Here

        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);

        nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);

        NodeType test13 = getSession().getWorkspace().getNodeTypeManager().getNodeType("ocm:test13");
View Full Code Here

        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);

        nodeTypeManagerImpl.createSingleNodeType(getSession(), classDescriptor);

        NodeType test11 = getSession().getWorkspace().getNodeTypeManager().getNodeType("ocm:test11");
View Full Code Here

TOP

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

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.