Package org.apache.cayenne.graph

Examples of org.apache.cayenne.graph.CompoundDiff


     * (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


    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

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

            CompoundDiff diff = new CompoundDiff();
            Map<Object, ObjectDiff> changes = getChangesByObjectId();

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

                for (final ObjectDiff objectDiff : changes.values()) {
                    objectDiff.appendDiffs(allChanges);
                }

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

            this.resolvedDiff = diff;
        }
    }
View Full Code Here

    }

    GraphDiff filter(GraphDiff in) {
        diffs = new ArrayList<GraphDiff>();
        in.apply(this);
        return new CompoundDiff(diffs);
    }
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

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

    }
View Full Code Here

        }
    }

    GraphDiff onContextRollback(ObjectContext originatingContext) {
        rollbackChanges();
        return new CompoundDiff();
    }
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

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.