Package org.apache.cayenne.graph

Examples of org.apache.cayenne.graph.CompoundDiff


                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

    void postprocess() {

        if (!objectsByDescriptor.isEmpty()) {

            CompoundDiff result = parent.getResultDiff();
            Map<ObjectId, DataRow> modifiedSnapshots = parent
                    .getResultModifiedSnapshots();
            Collection<ObjectId> deletedIds = parent.getResultDeletedIds();

            for (Map.Entry<ClassDescriptor, List<Persistent>> entry : objectsByDescriptor
                    .entrySet()) {

                ClassDescriptor descriptor = entry.getKey();

                for (Persistent object : entry.getValue()) {
                    ObjectId id = object.getObjectId();

                    ObjectId finalId;

                    // record id change and update attributes for generated ids
                    if (id.isReplacementIdAttached()) {

                        Map<String, Object> replacement = id.getReplacementIdMap();
                        Iterator<Property> idProperties = descriptor.getIdProperties();
                        while (idProperties.hasNext()) {
                            AttributeProperty property = (AttributeProperty) idProperties
                                    .next();
                            Object value = replacement.get(property
                                    .getAttribute()
                                    .getDbAttributeName());

                            // TODO: andrus, 11/28/2006: this operation may be redundant
                            // if the id wasn't generated. We may need to optimize it...
                            if (value != null) {
                                property.writePropertyDirectly(object, null, value);
                            }
                        }

                        ObjectId replacementId = id.createReplacementId();

                        result.add(new NodeIdChangeOperation(id, replacementId));

                        // classify replaced permanent ids as "deleted", as
                        // DataRowCache has no notion of replaced id...
                        if (!id.isTemporary()) {
                            deletedIds.add(id);
View Full Code Here

    void postprocess() {

        if (!objectsByEntity.isEmpty()) {

            CompoundDiff result = parent.getResultDiff();
            Map modifiedSnapshots = parent.getResultModifiedSnapshots();
            Collection deletedIds = parent.getResultDeletedIds();

            Iterator it = objectsByEntity.values().iterator();
            while (it.hasNext()) {

                Iterator objects = ((Collection) it.next()).iterator();
                while (objects.hasNext()) {
                    DataObject object = (DataObject) objects.next();
                    ObjectId id = object.getObjectId();

                    DataRow dataRow = object.getDataContext().currentSnapshot(object);
                    dataRow.setReplacesVersion(object.getSnapshotVersion());
                    object.setSnapshotVersion(dataRow.getVersion());

                    // record id change
                    if (id.isReplacementIdAttached()) {
                        ObjectId replacementId = id.createReplacementId();
                        result.add(new NodeIdChangeOperation(id, replacementId));

                        // classify replaced permanent ids as "deleted", as
                        // DataRowCache has no notion of replaced id...
                        if (!id.isTemporary()) {
                            deletedIds.add(id);
View Full Code Here

     *
     * @since 1.1
     * @deprecated since 1.2 unused.
     */
    public synchronized void objectsCommitted() {
        postprocessAfterCommit(new CompoundDiff());
    }
View Full Code Here

    GraphDiff onContextRollback(ObjectContext originatingContext) {
        rollbackChanges();
        return (channel != null) ? channel.onSync(
                this,
                null,
                DataChannel.ROLLBACK_CASCADE_SYNC) : new CompoundDiff();
    }
View Full Code Here

        if (this != originatingContext && changes != null) {
            changes.apply(new ChildDiffLoader(this));
            fireDataChannelChanged(originatingContext, changes);
        }

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

                    : changes.isNoop();

            if (noop) {
                // need to clear phantom changes
                getObjectStore().postprocessAfterPhantomCommit();
                return new CompoundDiff();
            }

            if (isTransactionEventsEnabled()) {
                eventHandler = new DataContextFlushEventHandler(this);
                eventHandler.registerForDataContextEvents();
View Full Code Here

    EntityResolver resolver;
    CompoundDiff clientDiff;

    ServerToClientDiffConverter(EntityResolver resolver) {
        this.resolver = resolver;
        this.clientDiff = new CompoundDiff();
    }
View Full Code Here

     * (same as creation order).
     */
    private void resolveDiff() {
        if (resolvedDiff == null) {

            CompoundDiff diff = new CompoundDiff();
            Map changes = getChangesByObjectId();

            if (!changes.isEmpty()) {
                List allChanges = new ArrayList(changes.size() * 2);

                Iterator it = changes.values().iterator();
                while (it.hasNext()) {
                    ((ObjectDiff) it.next()).appendDiffs(allChanges);
                }

                Collections.sort(allChanges);
                diff.addAll(allChanges);
            }

            this.resolvedDiff = diff;
        }
    }
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.