Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.EntitySorter


    void appendQueriesInternal(Collection queries) {

        DataNodeSyncQualifierDescriptor qualifierBuilder = new DataNodeSyncQualifierDescriptor();

        EntitySorter sorter = parent.getDomain().getEntitySorter();
        sorter.sortDbEntities(dbEntities, true);

        for (Iterator i = dbEntities.iterator(); i.hasNext();) {
            DbEntity dbEntity = (DbEntity) i.next();
            List objEntitiesForDbEntity = (List) objEntitiesByDbEntity.get(dbEntity);
            Map batches = new LinkedHashMap();

            for (Iterator j = objEntitiesForDbEntity.iterator(); j.hasNext();) {
                ObjEntity entity = (ObjEntity) j.next();

                qualifierBuilder.reset(entity, dbEntity);

                boolean isRootDbEntity = (entity.getDbEntity() == dbEntity);

                // remove object set for dependent entity, so that it does not show up
                // on post processing
                List objects = (List) objectsByEntity.get(entity);

                if (objects.isEmpty()) {
                    continue;
                }

                checkReadOnly(entity);

                if (isRootDbEntity) {
                    sorter.sortObjectsForEntity(entity, objects, true);
                }

                for (Iterator k = objects.iterator(); k.hasNext();) {
                    DataObject o = (DataObject) k.next();
                    ObjectDiff diff = parent.objectDiff(o.getObjectId());
View Full Code Here


    void appendQueriesInternal(Collection queries) {

        DataDomainDBDiffBuilder diffBuilder = new DataDomainDBDiffBuilder();

        EntitySorter sorter = parent.getDomain().getEntitySorter();
        sorter.sortDbEntities(dbEntities, false);

        Iterator i = dbEntities.iterator();
        while (i.hasNext()) {
            DbEntity dbEntity = (DbEntity) i.next();
            List objEntitiesForDbEntity = (List) objEntitiesByDbEntity.get(dbEntity);

            InsertBatchQuery batch = new InsertBatchQuery(dbEntity, 27);

            Iterator j = objEntitiesForDbEntity.iterator();
            while (j.hasNext()) {
                ObjEntity entity = (ObjEntity) j.next();

                diffBuilder.reset(entity, dbEntity);

                boolean isMasterDbEntity = (entity.getDbEntity() == dbEntity);

                // remove object set for dependent entity, so that it does not show up
                // on post processing
                List objects = (List) (isMasterDbEntity
                        ? objectsByEntity.get(entity)
                        : objectsByEntity.remove(entity));

                if (objects.isEmpty()) {
                    continue;
                }

                checkReadOnly(entity);

                if (isMasterDbEntity) {
                    createPermIdsForObjEntity(entity, objects);
                    sorter.sortObjectsForEntity(entity, objects, false);
                }

                for (Iterator k = objects.iterator(); k.hasNext();) {
                    DataObject o = (DataObject) k.next();
View Full Code Here

    void appendQueriesInternal(Collection queries) {

        DataDomainDBDiffBuilder diffBuilder = new DataDomainDBDiffBuilder();

        EntitySorter sorter = parent.getDomain().getEntitySorter();
        sorter.sortDbEntities(dbEntities, false);

        Iterator i = dbEntities.iterator();
        while (i.hasNext()) {
            DbEntity dbEntity = (DbEntity) i.next();
            List objEntitiesForDbEntity = (List) descriptorsByDbEntity.get(dbEntity);

            InsertBatchQuery batch = new InsertBatchQuery(dbEntity, 27);

            Iterator j = objEntitiesForDbEntity.iterator();
            while (j.hasNext()) {
                ClassDescriptor descriptor = (ClassDescriptor) j.next();

                diffBuilder.reset(descriptor.getEntity(), dbEntity);

                boolean isMasterDbEntity = (descriptor.getEntity().getDbEntity() == dbEntity);

                // remove object set for dependent entity, so that it does not show up
                // on post processing
                List objects = (List) (isMasterDbEntity ? objectsByDescriptor
                        .get(descriptor) : objectsByDescriptor.remove(descriptor));

                if (objects.isEmpty()) {
                    continue;
                }

                checkReadOnly(descriptor.getEntity());

                if (isMasterDbEntity) {
                    createPermIdsForObjEntity(descriptor, objects);
                    sorter.sortObjectsForEntity(descriptor.getEntity(), objects, false);
                }

                for (Iterator k = objects.iterator(); k.hasNext();) {
                    Persistent o = (Persistent) k.next();
View Full Code Here

    void appendQueriesInternal(Collection queries) {

        DataNodeSyncQualifierDescriptor qualifierBuilder = new DataNodeSyncQualifierDescriptor();

        EntitySorter sorter = parent.getDomain().getEntitySorter();
        sorter.sortDbEntities(dbEntities, true);

        for (Iterator i = dbEntities.iterator(); i.hasNext();) {
            DbEntity dbEntity = (DbEntity) i.next();
            List objEntitiesForDbEntity = (List) descriptorsByDbEntity.get(dbEntity);
            Map batches = new LinkedHashMap();

            for (Iterator j = objEntitiesForDbEntity.iterator(); j.hasNext();) {
                ClassDescriptor descriptor = (ClassDescriptor) j.next();

                qualifierBuilder.reset(descriptor.getEntity(), dbEntity);

                boolean isRootDbEntity = (descriptor.getEntity().getDbEntity() == dbEntity);

                // remove object set for dependent entity, so that it does not show up
                // on post processing
                List objects = (List) objectsByDescriptor.get(descriptor);

                if (objects.isEmpty()) {
                    continue;
                }

                checkReadOnly(descriptor.getEntity());

                if (isRootDbEntity) {
                    sorter.sortObjectsForEntity(descriptor.getEntity(), objects, true);
                }

                for (Iterator k = objects.iterator(); k.hasNext();) {
                    Persistent o = (Persistent) k.next();
                    ObjectDiff diff = parent.objectDiff(o.getObjectId());
View Full Code Here

            }
        }

        // sort table list
        if (tables.size() > 1) {
            EntitySorter sorter = new AshwoodEntitySorter();
            sorter.setEntityResolver(new EntityResolver(Collections.singleton(map)));
            sorter.sortDbEntities(tables, false);
        }

        this.dbEntitiesInInsertOrder = tables;
        this.dbEntitiesRequiringAutoPK = tablesWithAutoPk;
    }
View Full Code Here

            return;
        }

        // sort entities for insertion
        List sorted = new ArrayList(entities);
        EntitySorter sorter = new AshwoodEntitySorter();
        sorter.setEntityResolver(new EntityResolver(destinationNode.getDataMaps()));
        sorter.sortDbEntities(sorted, false);

        if (cleaningDestination) {
            // reverse insertion order for deletion
            List entitiesInDeleteOrder = new ArrayList(sorted.size());
            entitiesInDeleteOrder.addAll(sorted);
View Full Code Here

    assertNotNull(domain1);

    EventManager eventManager1 = domain1.getEventManager();
    assertNotNull(eventManager1);

    EntitySorter sorter1 = domain1.getEntitySorter();
    assertNotNull(sorter1);

    DataDomain domain2 = runtime.getDataDomain();
    assertNotNull(domain2);

    EventManager eventManager2 = domain2.getEventManager();
    assertNotNull(eventManager2);

    EntitySorter sorter2 = domain2.getEntitySorter();
    assertNotNull(sorter2);

    assertSame(domain1, domain2);
    assertSame(eventManager1, eventManager2);
    assertSame(sorter1, sorter2);
View Full Code Here

    assertNotNull(context1);
    assertTrue(context1 instanceof DataContext);

    DataDomain domain1 = (DataDomain) context1.getChannel();
    EventManager eventManager1 = domain1.getEventManager();
    EntitySorter sorter1 = domain1.getEntitySorter();

    ObjectContext context2 = runtime.getContext();
    assertNotNull(context2);
    assertTrue(context2 instanceof DataContext);
    DataDomain domain2 = (DataDomain) context2.getChannel();
    EventManager eventManager2 = domain2.getEventManager();
    EntitySorter sorter2 = domain2.getEntitySorter();

    assertNotSame(context1, context2);

    assertSame(domain1, domain2);
    assertSame(eventManager1, eventManager2);
View Full Code Here

    public void testAdapter() throws Exception {
        DataNode node = new DataNode();

        // entity sorter should have been created ... and since 1.2 shouldn't change no
        // matter what adapter we use.
        EntitySorter sorter = node.getEntitySorter();
        assertNotNull(sorter);
        assertNull(node.getAdapter());

        JdbcAdapter a1 = new JdbcAdapter();
        a1.setSupportsFkConstraints(true);
View Full Code Here

    void appendQueriesInternal(Collection queries) {

        DataDomainDBDiffBuilder diffBuilder = new DataDomainDBDiffBuilder();

        EntitySorter sorter = parent.getDomain().getEntitySorter();
        sorter.sortDbEntities(dbEntities, false);

        Iterator i = dbEntities.iterator();
        while (i.hasNext()) {
            DbEntity dbEntity = (DbEntity) i.next();
            List objEntitiesForDbEntity = (List) descriptorsByDbEntity.get(dbEntity);

            InsertBatchQuery batch = new InsertBatchQuery(dbEntity, 27);

            Iterator j = objEntitiesForDbEntity.iterator();
            while (j.hasNext()) {
                ClassDescriptor descriptor = (ClassDescriptor) j.next();

                diffBuilder.reset(descriptor.getEntity(), dbEntity);

                boolean isMasterDbEntity = (descriptor.getEntity().getDbEntity() == dbEntity);

                // remove object set for dependent entity, so that it does not show up
                // on post processing
                List objects = (List) (isMasterDbEntity ? objectsByDescriptor
                        .get(descriptor) : objectsByDescriptor.remove(descriptor));

                if (objects.isEmpty()) {
                    continue;
                }

                checkReadOnly(descriptor.getEntity());

                if (isMasterDbEntity) {
                    createPermIdsForObjEntity(descriptor, objects);
                    sorter.sortObjectsForEntity(descriptor.getEntity(), objects, false);
                }

                for (Iterator k = objects.iterator(); k.hasNext();) {
                    Persistent o = (Persistent) k.next();
View Full Code Here

TOP

Related Classes of org.apache.cayenne.map.EntitySorter

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.