Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 306710 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/emf/internal/cdo/CDONotificationBuilder.java (-26 / +38 lines)
Lines 25-33 Link Here
25
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
25
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
26
import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
26
import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
27
import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
27
import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
28
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
29
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
28
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
30
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
29
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
30
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
31
import org.eclipse.emf.cdo.view.CDOView;
31
import org.eclipse.emf.cdo.view.CDOView;
32
32
33
import org.eclipse.emf.common.notify.Notification;
33
import org.eclipse.emf.common.notify.Notification;
Lines 62-67 Link Here
62
62
63
  private InternalCDORevision oldRevision;
63
  private InternalCDORevision oldRevision;
64
64
65
  private CDOListFeatureDelta patchedListDelta;
66
67
  private CDOListFeatureDelta unpatchedListDelta;
68
65
  /**
69
  /**
66
   * @since 3.0
70
   * @since 3.0
67
   */
71
   */
Lines 87-92 Link Here
87
    notification = null;
91
    notification = null;
88
    revision = null;
92
    revision = null;
89
    revisionLookedUp = false;
93
    revisionLookedUp = false;
94
    patchedListDelta = null;
95
    unpatchedListDelta = null;
90
96
91
    this.object = object;
97
    this.object = object;
92
    this.revisionDelta = revisionDelta;
98
    this.revisionDelta = revisionDelta;
Lines 108-115 Link Here
108
  public void visit(CDOAddFeatureDelta delta)
114
  public void visit(CDOAddFeatureDelta delta)
109
  {
115
  {
110
    EStructuralFeature feature = delta.getFeature();
116
    EStructuralFeature feature = delta.getFeature();
111
    add(new CDODeltaNotificationImpl(object, Notification.ADD, getEFeatureID(feature), getOldValue(feature),
117
    add(new CDODeltaNotificationImpl(object, Notification.ADD, getEFeatureID(feature), getOldValue(feature), delta
112
        delta.getValue(), delta.getIndex()));
118
        .getValue(), delta.getIndex()));
113
  }
119
  }
114
120
115
  public void visit(CDORemoveFeatureDelta delta)
121
  public void visit(CDORemoveFeatureDelta delta)
Lines 123-140 Link Here
123
          false);
129
          false);
124
    }
130
    }
125
131
126
    Object oldValue = revision == null ? null : revision.get(feature, index);
132
    // use patched index to retrieve object.
133
    int patchedIndex = ((CDORemoveFeatureDelta)patchedListDelta.getListChanges().get(
134
        unpatchedListDelta.getListChanges().indexOf(delta))).getIndex();
135
    Object oldValue = revision == null ? null : revision.get(feature, patchedIndex);
127
    if (oldValue instanceof CDOID)
136
    if (oldValue instanceof CDOID)
128
    {
137
    {
129
      CDOID id = (CDOID)oldValue;
138
      CDOID oldValueId = (CDOID)oldValue;
130
      oldValue = view.getObject(id, false);
139
      CDOObject cdoObject = findObjectByID(oldValueId);
131
      if (oldValue == null)
140
      if (cdoObject != null)
132
      {
141
      {
133
        CDOObject cdoObject = findDetachedObjectByID(id);
142
        oldValue = cdoObject;
134
        if (cdoObject != null)
135
        {
136
          oldValue = cdoObject;
137
        }
138
      }
143
      }
139
    }
144
    }
140
145
Lines 148-154 Link Here
148
    if (oldValue instanceof CDOID)
153
    if (oldValue instanceof CDOID)
149
    {
154
    {
150
      CDOID oldValueId = (CDOID)oldValue;
155
      CDOID oldValueId = (CDOID)oldValue;
151
      CDOObject cdoObject = findDetachedObjectByID(oldValueId);
156
      CDOObject cdoObject = findObjectByID(oldValueId);
152
      if (cdoObject != null)
157
      if (cdoObject != null)
153
      {
158
      {
154
        oldValue = cdoObject;
159
        oldValue = cdoObject;
Lines 165-171 Link Here
165
    if (oldValue instanceof CDOID)
170
    if (oldValue instanceof CDOID)
166
    {
171
    {
167
      CDOID oldValueId = (CDOID)oldValue;
172
      CDOID oldValueId = (CDOID)oldValue;
168
      CDOObject cdoObject = findDetachedObjectByID(oldValueId);
173
      CDOObject cdoObject = findObjectByID(oldValueId);
169
      if (cdoObject != null)
174
      if (cdoObject != null)
170
      {
175
      {
171
        oldValue = cdoObject;
176
        oldValue = cdoObject;
Lines 177-186 Link Here
177
182
178
  public void visit(CDOListFeatureDelta deltas)
183
  public void visit(CDOListFeatureDelta deltas)
179
  {
184
  {
180
    // patch the indices on a copy to avoid duplicate patching.
185
    unpatchedListDelta = deltas;
181
    CDOListFeatureDelta workDelta = (CDOListFeatureDelta)deltas.copy();
186
    patchedListDelta = (CDOListFeatureDelta)deltas.copy();
182
    patchIndices(workDelta);
187
    patchIndices(patchedListDelta);
183
    for (CDOFeatureDelta delta : workDelta.getListChanges())
188
    for (CDOFeatureDelta delta : deltas.getListChanges())
184
    {
189
    {
185
      delta.accept(this);
190
      delta.accept(this);
186
    }
191
    }
Lines 261-278 Link Here
261
      List<?> list = (List<?>)oldValue;
266
      List<?> list = (List<?>)oldValue;
262
      if (!list.isEmpty() && list.get(0) instanceof CDOID)
267
      if (!list.isEmpty() && list.get(0) instanceof CDOID)
263
      {
268
      {
264
        List<CDOObject> oldValueObjects = new ArrayList<CDOObject>(list.size());
269
        List<Object> oldValueObjects = new ArrayList<Object>(list.size());
265
270
266
        @SuppressWarnings("unchecked")
271
        @SuppressWarnings("unchecked")
267
        List<CDOID> ids = (List<CDOID>)list;
272
        List<CDOID> ids = (List<CDOID>)list;
268
273
269
        for (CDOID id : ids)
274
        for (CDOID id : ids)
270
        {
275
        {
271
          CDOObject oldObject = findDetachedObjectByID(id);
276
          CDOObject oldObject = findObjectByID(id);
272
          if (oldObject != null)
277
          oldValueObjects.add(oldObject != null ? oldObject : id);
273
          {
274
            oldValueObjects.add(oldObject);
275
          }
276
        }
278
        }
277
279
278
        oldValue = oldValueObjects;
280
        oldValue = oldValueObjects;
Lines 282-294 Link Here
282
    add(new CDODeltaNotificationImpl(object, Notification.REMOVE_MANY, getEFeatureID(feature), oldValue, null));
284
    add(new CDODeltaNotificationImpl(object, Notification.REMOVE_MANY, getEFeatureID(feature), oldValue, null));
283
  }
285
  }
284
286
287
  private CDOObject findObjectByID(CDOID id)
288
  {
289
    CDOObject oldObject = view.getObject(id, false);
290
    if (oldObject == null)
291
    {
292
      oldObject = findDetachedObjectByID(id);
293
    }
294
    return oldObject;
295
  }
296
285
  private CDOObject findDetachedObjectByID(CDOID id)
297
  private CDOObject findDetachedObjectByID(CDOID id)
286
  {
298
  {
287
    if (detachedObjects != null)
299
    if (detachedObjects != null)
288
    {
300
    {
289
      for (CDOObject object : detachedObjects)
301
      for (CDOObject object : detachedObjects)
290
      {
302
      {
291
        if (object.cdoID().equals(id))
303
        if (id.equals(object.cdoID()))
292
        {
304
        {
293
          return object;
305
          return object;
294
        }
306
        }
Lines 308-314 Link Here
308
      if (oldValue instanceof CDOID)
320
      if (oldValue instanceof CDOID)
309
      {
321
      {
310
        CDOID oldValueId = (CDOID)oldValue;
322
        CDOID oldValueId = (CDOID)oldValue;
311
        CDOObject cdoObject = findDetachedObjectByID(oldValueId);
323
        CDOObject cdoObject = findObjectByID(oldValueId);
312
        if (cdoObject != null)
324
        if (cdoObject != null)
313
        {
325
        {
314
          oldValue = cdoObject;
326
          oldValue = cdoObject;

Return to bug 306710