Examples of CollectionDescriptor


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

  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

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

  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

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

                    }

                    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

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

  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

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

        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);
View Full Code Here

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

        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");
View Full Code Here

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

        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");
View Full Code Here

Examples of org.apache.ojb.broker.metadata.CollectionDescriptor

        if (implicitLocking)
        {
            Iterator i = cld.getCollectionDescriptors(true).iterator();
            while (i.hasNext())
            {
                CollectionDescriptor cds = (CollectionDescriptor) i.next();
                Object col = cds.getPersistentField().get(sourceObject);
                if (col != null)
                {
                    CollectionProxy proxy = ProxyHelper.getCollectionProxy(col);
                    if (proxy != null)
                    {
                        if (!proxy.isLoaded())
                        {
                            if (log.isDebugEnabled()) log.debug("adding self as listener to collection proxy");
                            proxy.addListener(this);
                            registeredCollectionProxies.add(proxy);
                            continue;
                        }
                    }
                    Iterator colIterator = BrokerHelper.getCollectionIterator(col);
                    Object item = null;
                    try
                    {
                        while (colIterator.hasNext())
                        {
                            item = colIterator.next();
                            RuntimeObject rt = new RuntimeObject(item, this);
                            if (rt.isProxy())
                            {
                                IndirectionHandler handler = ProxyHelper.getIndirectionHandler(item);
                                if (!handler.alreadyMaterialized())
                                {
                                    registerToIndirectionHandler(handler);
                                    continue;
                                }
                                else
                                {
                                    // @todo consider registering to hear when this is
                                    // derefernced instead of just loading here -bmc
                                    item = handler.getRealSubject();
                                }
                            }
                            if (!registrationList.contains(rt.getIdentity()))
                            {
                                lockAndRegister(rt, lockMode, registeredObjects);
                            }
                        }
                    }
                    catch (LockNotGrantedException e)
                    {
                        String eol = SystemUtils.LINE_SEPARATOR;
                        log.error("Lock not granted, while lock collection references[" +
                                eol + "current reference descriptor:" +
                                eol + cds.toXML() +
                                eol + "object to lock: " + item +
                                eol + "main object class: " + sourceObject.getClass().getName() +
                                eol + "]", e);
                        throw e;
                    }
View Full Code Here

Examples of org.apache.ojb.broker.metadata.CollectionDescriptor

    private void buildImageForCollectionReferences(Map imageMap, ClassDescriptor cld)
    {
        // register the 1:n and m:n references
        Iterator collections = cld.getCollectionDescriptors(true).iterator();
        CollectionDescriptor cds;
        while(collections.hasNext())
        {
            cds = (CollectionDescriptor) collections.next();
            Object collectionOrArray = cds.getPersistentField().get(myObj);
            Image.MultipleRef colRef = new Image.MultipleRef(this, cds, collectionOrArray);
            imageMap.put(cds, colRef);
        }
    }
View Full Code Here

Examples of org.apache.ojb.broker.metadata.CollectionDescriptor

    private void cascadeInsertCollectionReferences(ObjectEnvelope source, List descriptor, List alreadyPrepared)
    {
        // PersistenceBroker pb = getTransaction().getBroker();
        for(int i = 0; i < descriptor.size(); i++)
        {
            CollectionDescriptor col = (CollectionDescriptor) descriptor.get(i);
            Object collOrArray = col.getPersistentField().get(source.getObject());
            CollectionProxy proxy = ProxyHelper.getCollectionProxy(collOrArray);
            /*
            on insert we perform only materialized collection objects. This should be
            sufficient, because in method #cascadingDependents() we make sure that on
            move of unmaterialized collection objects the proxy was materialized if needed.
            */
            if(proxy == null && collOrArray != null)
            {
                Iterator it = BrokerHelper.getCollectionIterator(collOrArray);
                while(it.hasNext())
                {
                    Object colObj = it.next();
                    if(colObj != null)
                    {
                        RuntimeObject rt = new RuntimeObject(colObj, getTransaction());
                        Identity oid = rt.getIdentity();
                        /*
                        arminw:
                        only when the main object need insert we start with FK assignment
                        of the 1:n and m:n relations. If the main objects need update (was already persisted)
                        it should be handled by the object state detection in ObjectEnvelope
                        */
                        if(source.needsInsert())
                        {
                            /*
                            arminw:
                            TODO: what is the valid way to go, when the collection object itself is
                            a unmaterialized proxy object? Think in this case we should materialize the
                            object when the main object needs insert, because we have to assign the FK values
                            to the main object
                            */
                            colObj = ProxyHelper.getRealObject(colObj);
                            ObjectEnvelope oe = getByIdentity(oid);
                            if(oe == null)
                            {
                                getTransaction().lockAndRegister(rt, Transaction.WRITE, false, getTransaction().getRegistrationList());
                                oe = getByIdentity(oid);
                            }
                            if(col.isMtoNRelation())
                            {
                                // the main objects needs insert, thus add new m:n link
                                addM2NLinkEntry(col, source.getObject(), colObj);
                            }
                            else
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.