Package org.apache.cayenne.graph

Examples of org.apache.cayenne.graph.CompoundDiff


        Transaction transaction = Transaction.getThreadTransaction();
        if (transaction != null) {
            transaction.setRollbackOnly();
        }

        return new CompoundDiff();
    }
View Full Code Here


        Object mainMessage = channel.getRequestObjects().iterator().next();
        assertTrue(mainMessage instanceof GraphDiff);
    }

    public void testCommitChangesNew() {
        final CompoundDiff diff = new CompoundDiff();
        final Object newObjectId = new ObjectId("test", "key", "generated");
        final EventManager eventManager = new DefaultEventManager(0);

        // test that ids that are passed back are actually propagated to the right
        // objects...

        MockDataChannel channel = new MockDataChannel() {

            @Override
            public GraphDiff onSync(
                    ObjectContext originatingContext,
                    GraphDiff changes,
                    int syncType) {

                return diff;
            }

            // must provide a channel with working event manager
            @Override
            public EventManager getEventManager() {
                return eventManager;
            }
        };

        CayenneContext context = new CayenneContext(channel);
        ObjEntity entity = new ObjEntity("test_entity");
        entity.setClassName(MockPersistentObject.class.getName());

        DataMap dataMap = new DataMap("test");
        dataMap.addObjEntity(entity);
        Collection<DataMap> entities = Collections.singleton(dataMap);
        context.setEntityResolver(new EntityResolver(entities));
        Persistent object = context.newObject(MockPersistentObject.class);

        // record change here to make it available to the anonymous connector method..
        diff.add(new NodeIdChangeOperation(object.getObjectId(), newObjectId));

        // check that a generated object ID is assigned back to the object...
        assertNotSame(newObjectId, object.getObjectId());
        context.commitChanges();
        assertSame(newObjectId, object.getObjectId());
View Full Code Here

        }
    }

    GraphDiff onContextRollback(ObjectContext originatingContext) {
        rollbackChanges();
        return new CompoundDiff();
    }
View Full Code Here

            }

            fireDataChannelChanged(originatingContext, changes);
        }

        return (cascade) ? doCommitChanges(true) : new CompoundDiff();
    }
View Full Code Here

    }

    GraphDiff flush(DataContext context, GraphDiff changes) {

        if (changes == null) {
            return new CompoundDiff();
        }

        // TODO: Andrus, 3/13/2006 - support categorizing an arbitrary diff
        if (!(changes instanceof ObjectStoreGraphDiff)) {
            throw new IllegalArgumentException("Expected 'ObjectStoreGraphDiff', got: "
                    + changes.getClass().getName());
        }

        this.context = context;

        // ObjectStoreGraphDiff contains changes already categorized by objectId...
        this.changesByObjectId = ((ObjectStoreGraphDiff) changes).getChangesByObjectId();
        this.insertBucket = new DataDomainInsertBucket(this);
        this.deleteBucket = new DataDomainDeleteBucket(this);
        this.updateBucket = new DataDomainUpdateBucket(this);
        this.flattenedBucket = new DataDomainFlattenedBucket(this);

        this.queries = new ArrayList<Query>();
        this.resultIndirectlyModifiedIds = new HashSet<ObjectId>();

        preprocess(context, changes);

        if (queries.isEmpty()) {
            return new CompoundDiff();
        }

        this.resultDiff = new CompoundDiff();
        this.resultDeletedIds = new ArrayList<ObjectId>();
        this.resultModifiedSnapshots = new HashMap<ObjectId, DataRow>();

        runQueries();
View Full Code Here

        Transaction transaction = Transaction.getThreadTransaction();
        if (transaction != null) {
            transaction.setRollbackOnly();
        }

        return new CompoundDiff();
    }
View Full Code Here

        }
        else {
            if (channel != null) {
                channel.onSync(
                        this,
                        new CompoundDiff(),
                        DataChannel.ROLLBACK_CASCADE_SYNC);
            }
        }

    }
View Full Code Here

                getObjectStore().childContextSyncStarted();
                changes.apply(new ChildDiffLoader(this));
                fireDataChannelChanged(originatingContext, changes);
            }

            return (cascade) ? flushToParent(true) : new CompoundDiff();
        }
        finally {
            if (childContext) {
                getObjectStore().childContextSyncStopped();
            }
View Full Code Here

            }

            // merge changes from parent as well as changes caused by lifecycle event
            // callbacks/listeners...

            CompoundDiff diff = new CompoundDiff();

            diff.addAll(objectStore.getLifecycleEventInducedChanges());
            if (parentChanges != null) {
                diff.add(parentChanges);
            }

            // this event is caught by child DataContexts to update temporary
            // ObjectIds with permanent
            if (!diff.isNoop()) {
                fireDataChannelCommitted(getChannel(), diff);
            }

            return diff;
        }
View Full Code Here

    /**
     * Returns a combined GraphDiff for all recorded operations.
     */
    GraphDiff getDiffs() {
        return new CompoundDiff(immutableList(0, diffs.size()));
    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.graph.CompoundDiff

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.