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 251544 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java (-167 / +63 lines)
Lines 48-59 Link Here
48
import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
48
import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
49
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
49
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
50
import org.eclipse.emf.ecore.util.InternalEList;
50
import org.eclipse.emf.ecore.util.InternalEList;
51
import org.eclipse.emf.ecore.util.NotifyingInternalEListImpl;
52
51
53
import java.io.IOException;
52
import java.io.IOException;
54
import java.io.InputStream;
53
import java.io.InputStream;
55
import java.io.OutputStream;
54
import java.io.OutputStream;
56
import java.util.Collection;
57
import java.util.Iterator;
55
import java.util.Iterator;
58
import java.util.Map;
56
import java.util.Map;
59
57
Lines 257-275 Link Here
257
  @SuppressWarnings("unchecked")
255
  @SuppressWarnings("unchecked")
258
  public EList<EObject> getContents()
256
  public EList<EObject> getContents()
259
  {
257
  {
260
    if (FSMUtil.isTransient(this))
261
    {
262
      EList<EObject> transientContents = (EList<EObject>)eSettings[EresourcePackage.CDO_RESOURCE__CONTENTS];
263
      if (transientContents == null)
264
      {
265
        transientContents = new TransientContents<EObject>();
266
        eSettings[EresourcePackage.CDO_RESOURCE__CONTENTS] = transientContents;
267
        // throw new ImplementationError();
268
      }
269
270
      return transientContents;
271
    }
272
273
    return (EList<EObject>)eGet(EresourcePackage.Literals.CDO_RESOURCE__CONTENTS, true);
258
    return (EList<EObject>)eGet(EresourcePackage.Literals.CDO_RESOURCE__CONTENTS, true);
274
  }
259
  }
275
260
Lines 846-852 Link Here
846
  {
831
  {
847
    if (eStructuralFeature == EresourcePackage.eINSTANCE.getCDOResource_Contents())
832
    if (eStructuralFeature == EresourcePackage.eINSTANCE.getCDOResource_Contents())
848
    {
833
    {
849
      return new PersistentContents(eStructuralFeature);
834
      return new ContentsCDOList(eStructuralFeature);
850
    }
835
    }
851
836
852
    return super.createList(eStructuralFeature);
837
    return super.createList(eStructuralFeature);
Lines 857-875 Link Here
857
   * 
842
   * 
858
   * @ADDED
843
   * @ADDED
859
   * @author Eike Stepper
844
   * @author Eike Stepper
845
   * @since 2.0
860
   */
846
   */
861
  protected class PersistentContents extends CDOStoreEList<Object>
847
  protected class ContentsCDOList extends BasicEStoreEList<Object>
862
  {
848
  {
863
    private static final long serialVersionUID = 1L;
849
    private static final long serialVersionUID = 1L;
864
850
865
    @SuppressWarnings("deprecation")
851
    public ContentsCDOList(EStructuralFeature eStructuralFeature)
866
    public PersistentContents(EStructuralFeature eStructuralFeature)
867
    {
852
    {
868
      super(eStructuralFeature);
853
      super(CDOResourceImpl.this, eStructuralFeature);
869
      if (!cdoView().hasUniqueResourceContents())
870
      {
871
        kind &= ~IS_UNIQUE;
872
      }
873
    }
854
    }
874
855
875
    /**
856
    /**
Lines 880-887 Link Here
880
    @Override
861
    @Override
881
    public boolean contains(Object object)
862
    public boolean contains(Object object)
882
    {
863
    {
883
      return size() <= 4 ? super.contains(object) : object instanceof InternalEObject
864
      if (size() <= 4)
884
          && ((InternalEObject)object).eDirectResource() == CDOResourceImpl.this;
865
      {
866
        return super.contains(object);
867
      }
868
869
      return object instanceof InternalEObject && ((InternalEObject)object).eDirectResource() == CDOResourceImpl.this;
885
    }
870
    }
886
871
887
    /**
872
    /**
Lines 890-902 Link Here
890
    @Override
875
    @Override
891
    public NotificationChain inverseAdd(Object object, NotificationChain notifications)
876
    public NotificationChain inverseAdd(Object object, NotificationChain notifications)
892
    {
877
    {
893
      CDOTransactionImpl transaction = cdoView().toTransaction();
878
      if (FSMUtil.isTransient(CDOResourceImpl.this))
894
      InternalCDOObject cdoObject = FSMUtil.adapt(object, transaction);
895
      notifications = cdoObject.eSetResource(CDOResourceImpl.this, notifications);
896
      // Attach here instead of i CDOObjectImpl.eSetResource because EMF does it also here
897
      if (FSMUtil.isTransient(cdoObject))
898
      {
879
      {
899
        attached(cdoObject, transaction);
880
        InternalEObject eObject = (InternalEObject)object;
881
        notifications = eObject.eSetResource(CDOResourceImpl.this, notifications);
882
      }
883
      else
884
      {
885
        CDOTransactionImpl transaction = cdoView().toTransaction();
886
        InternalCDOObject cdoObject = FSMUtil.adapt(object, transaction);
887
        notifications = cdoObject.eSetResource(CDOResourceImpl.this, notifications);
888
889
        // Attach here instead of in CDOObjectImpl.eSetResource because EMF does it also here
890
        if (FSMUtil.isTransient(cdoObject))
891
        {
892
          attached(cdoObject, transaction);
893
        }
900
      }
894
      }
901
895
902
      return notifications;
896
      return notifications;
Lines 908-1077 Link Here
908
    @Override
902
    @Override
909
    public NotificationChain inverseRemove(Object object, NotificationChain notifications)
903
    public NotificationChain inverseRemove(Object object, NotificationChain notifications)
910
    {
904
    {
911
      InternalEObject eObject = (InternalEObject)object;
905
      if (FSMUtil.isTransient(CDOResourceImpl.this))
912
      detached(eObject);
906
      {
913
      return eObject.eSetResource(null, notifications);
907
        InternalEObject eObject = (InternalEObject)object;
914
    }
908
        notifications = eObject.eSetResource(null, notifications);
915
  }
909
      }
916
910
      else
917
  /**
911
      {
918
   * TODO Change superclass to NotifyingInternalEListImpl when EMF 2.3 is out of maintenance
912
        InternalEObject eObject = (InternalEObject)object;
919
   * <p>
913
        detached(eObject);
920
   * TODO Reuse {@link ResourceImpl.ContentsEList}!!! --> Bugzilla!
914
        notifications = eObject.eSetResource(null, notifications);
921
   * 
915
      }
922
   * @ADDED
923
   * @author Eike Stepper
924
   */
925
  protected class TransientContents<E extends Object & EObject> extends NotifyingInternalEListImpl<E>
926
  {
927
    private static final long serialVersionUID = 1L;
928
929
    public TransientContents()
930
    {
931
    }
932
933
    public TransientContents(Collection<? extends E> collection)
934
    {
935
      super(collection);
936
    }
937
916
938
    public TransientContents(int initialCapacity)
917
      return notifications;
939
    {
940
      super(initialCapacity);
941
    }
918
    }
942
919
943
    /**
920
    /**
944
     * Optimization taken from ResourceImpl.EContentList.contains
945
     * 
946
     * @since 2.0
921
     * @since 2.0
947
     */
922
     */
948
    @Override
923
    protected void loaded()
949
    public boolean contains(Object object)
950
    {
951
      return size <= 4 ? super.contains(object) : object instanceof InternalEObject
952
          && ((InternalEObject)object).eDirectResource() == CDOResourceImpl.this;
953
    }
954
955
    @Override
956
    public Object getNotifier()
957
    {
958
      return CDOResourceImpl.this;
959
    }
960
961
    @Override
962
    public int getFeatureID()
963
    {
924
    {
964
      return EresourcePackage.CDO_RESOURCE__CONTENTS;
925
      if (!isLoaded())
926
      {
927
        Notification notification = setLoaded(true);
928
        if (notification != null)
929
        {
930
          eNotify(notification);
931
        }
932
      }
965
    }
933
    }
966
934
967
    @Override
935
    /**
968
    protected boolean isNotificationRequired()
936
     * @since 2.0
937
     */
938
    protected void modified()
969
    {
939
    {
970
      return eNotificationRequired();
940
      if (isTrackingModification())
941
      {
942
        setModified(true);
943
      }
971
    }
944
    }
972
945
946
    /**
947
     * @since 2.0
948
     */
973
    @Override
949
    @Override
974
    protected boolean useEquals()
950
    protected boolean useEquals()
975
    {
951
    {
976
      return false;
952
      return false;
977
    }
953
    }
978
954
979
    @Override
980
    protected boolean hasInverse()
981
    {
982
      return true;
983
    }
984
985
    @Override
986
    protected boolean isUnique()
987
    {
988
      return true;
989
    }
990
991
    /**
955
    /**
992
     * @since 2.0
956
     * @since 2.0
993
     */
957
     */
994
    /*
995
     * IMPORTANT: Compile errors in this method might indicate an old version of EMF. Legacy support is only enabled for
996
     * EMF with fixed bug #247130. These compile errors do not affect native models!
997
     */
998
    public InternalEList<E> readWriteFiringList()
999
    {
1000
      return this;
1001
    }
1002
1003
    @Override
1004
    public NotificationChain inverseAdd(E object, NotificationChain notifications)
1005
    {
1006
      InternalEObject eObject = (InternalEObject)object;
1007
      notifications = eObject.eSetResource(CDOResourceImpl.this, notifications);
1008
      // CDOResourceImpl.this.attached(eObject);
1009
      return notifications;
1010
    }
1011
1012
    @Override
1013
    public NotificationChain inverseRemove(E object, NotificationChain notifications)
1014
    {
1015
      InternalEObject eObject = (InternalEObject)object;
1016
      // CDOResourceImpl.this.detached(eObject);
1017
      return eObject.eSetResource(null, notifications);
1018
    }
1019
1020
    @Override
1021
    protected void didAdd(int index, E object)
1022
    {
1023
      super.didAdd(index, object);
1024
      modified();
1025
    }
1026
1027
    @Override
958
    @Override
1028
    protected void didRemove(int index, E object)
959
    protected boolean hasInverse()
1029
    {
1030
      super.didRemove(index, object);
1031
      modified();
1032
    }
1033
1034
    @Override
1035
    protected void didSet(int index, E newObject, E oldObject)
1036
    {
1037
      super.didSet(index, newObject, oldObject);
1038
      modified();
1039
    }
1040
1041
    @Override
1042
    protected void didClear(int oldSize, Object[] oldData)
1043
    {
960
    {
1044
      if (oldSize == 0)
961
      return true;
1045
      {
1046
        loaded();
1047
      }
1048
      else
1049
      {
1050
        super.didClear(oldSize, oldData);
1051
      }
1052
    }
962
    }
1053
963
1054
    /**
964
    /**
1055
     * @since 2.0
965
     * @since 2.0
1056
     */
966
     */
1057
    protected void loaded()
967
    @Override
1058
    {
968
    protected boolean isUnique()
1059
      if (!isLoaded())
1060
      {
1061
        Notification notification = setLoaded(true);
1062
        if (notification != null)
1063
        {
1064
          eNotify(notification);
1065
        }
1066
      }
1067
    }
1068
1069
    protected void modified()
1070
    {
969
    {
1071
      if (isTrackingModification())
970
      return true;
1072
      {
1073
        setModified(true);
1074
      }
1075
    }
971
    }
1076
  }
972
  }
1077
} // CDOResourceImpl
973
} // CDOResourceImpl
(-)src/org/eclipse/emf/cdo/CDOView.java (-26 lines)
Lines 165-196 Link Here
165
  public boolean hasConflict();
165
  public boolean hasConflict();
166
166
167
  /**
167
  /**
168
   * @see #setUniqueResourceContents(boolean)
169
   * @deprecated This performance tweak is not necessary with EMF 2.5 anymore and is likely to be removed when CDO
170
   *             reaches 2.0. In the meantime it can be safely used.
171
   */
172
  @Deprecated
173
  public boolean hasUniqueResourceContents();
174
175
  /**
176
   * Specifies whether the contents list of resources will be unique or not.
177
   * <p>
178
   * This property is transient in that it does not stick with resources outside of the scope of this view. Especially
179
   * it will not be persisted with resources in the repository. Each new view will start with <code>true</code> as a
180
   * default value. Changing to <code>false</code> will subsequently apply to all resources being loaded or created.
181
   * <p>
182
   * Notice that the resource contents is a containment list and as such <b>must be</b> unique. Setting this property to
183
   * <code>false</code> is only recommended for performance optimization when uniqueness is granted by other means.
184
   * Violating the uniqueness constraint will result in unpredictable behaviour and possible corruption of the
185
   * repository!
186
   * 
187
   * @deprecated This performance tweak is not necessary with EMF 2.5 anymore and is likely to be removed when CDO
188
   *             reaches 2.0. In the meantime it can be safely used.
189
   */
190
  @Deprecated
191
  public void setUniqueResourceContents(boolean uniqueResourceContents);
192
193
  /**
194
   * Returns <code>true</code> if the {@link CDOObject objects} in this view will notify their
168
   * Returns <code>true</code> if the {@link CDOObject objects} in this view will notify their
195
   * {@link org.eclipse.emf.common.notify.Adapter adapters} about the fact that they are <em>invalidated</em> (due to
169
   * {@link org.eclipse.emf.common.notify.Adapter adapters} about the fact that they are <em>invalidated</em> (due to
196
   * remote changes), <code>false</code> otherwise.
170
   * remote changes), <code>false</code> otherwise.
(-)src/org/eclipse/emf/internal/cdo/CDOViewImpl.java (-14 lines)
Lines 100-107 Link Here
100
100
101
  private CDOURIHandler uriHandler = new CDOURIHandler(this);
101
  private CDOURIHandler uriHandler = new CDOURIHandler(this);
102
102
103
  private boolean uniqueResourceContents = true;
104
105
  private boolean invalidationNotificationEnabled;
103
  private boolean invalidationNotificationEnabled;
106
104
107
  private CDORevisionPrefetchingPolicy revisionPrefetchingPolicy;
105
  private CDORevisionPrefetchingPolicy revisionPrefetchingPolicy;
Lines 225-242 Link Here
225
    return false;
223
    return false;
226
  }
224
  }
227
225
228
  @Deprecated
229
  public boolean hasUniqueResourceContents()
230
  {
231
    return uniqueResourceContents;
232
  }
233
234
  @Deprecated
235
  public void setUniqueResourceContents(boolean uniqueResourceContents)
236
  {
237
    this.uniqueResourceContents = uniqueResourceContents;
238
  }
239
240
  /**
226
  /**
241
   * @since 2.0
227
   * @since 2.0
242
   */
228
   */
(-)src/org/eclipse/emf/internal/cdo/CDOXATransactionCommitContext.java (-2 / +1 lines)
Lines 30-36 Link Here
30
import java.util.HashMap;
30
import java.util.HashMap;
31
import java.util.List;
31
import java.util.List;
32
import java.util.Map;
32
import java.util.Map;
33
import java.util.Set;
34
import java.util.concurrent.Callable;
33
import java.util.concurrent.Callable;
35
34
36
/**
35
/**
Lines 112-118 Link Here
112
    return delegateCommitContext.getNewResources();
111
    return delegateCommitContext.getNewResources();
113
  }
112
  }
114
113
115
  public Set<CDOID> getDetachedObjects()
114
  public Map<CDOID, CDOObject> getDetachedObjects()
116
  {
115
  {
117
    return delegateCommitContext.getDetachedObjects();
116
    return delegateCommitContext.getDetachedObjects();
118
  }
117
  }
(-)src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java (-22 / +19 lines)
Lines 399-409 Link Here
399
    return null;
399
    return null;
400
  }
400
  }
401
401
402
  private boolean isDetached(CDOID id)
403
  {
404
    return lastSavepoint.getSharedDetachedObjects().contains(id);
405
  }
406
407
  /**
402
  /**
408
   * @since 2.0
403
   * @since 2.0
409
   */
404
   */
Lines 416-422 Link Here
416
      return null;
411
      return null;
417
    }
412
    }
418
413
419
    if (isDetached(id))
414
    if (id.isTemporary() && isDetached(id))
420
    {
415
    {
421
      FSMUtil.validate(id, null);
416
      FSMUtil.validate(id, null);
422
    }
417
    }
Lines 424-429 Link Here
424
    return super.getObject(id, loadOnDemand);
419
    return super.getObject(id, loadOnDemand);
425
  }
420
  }
426
421
422
  private boolean isDetached(CDOID id)
423
  {
424
    return lastSavepoint.getSharedDetachedObjects().contains(id);
425
  }
426
427
  /**
427
  /**
428
   * @since 2.0
428
   * @since 2.0
429
   */
429
   */
Lines 505-511 Link Here
505
        }
505
        }
506
      }
506
      }
507
507
508
      // Rollback every persisted objects
508
      // Rollback all persisted objects
509
      Map<CDOID, CDOObject> detachedObjects = itrSavepoint.getDetachedObjects();
509
      Map<CDOID, CDOObject> detachedObjects = itrSavepoint.getDetachedObjects();
510
      if (!detachedObjects.isEmpty())
510
      if (!detachedObjects.isEmpty())
511
      {
511
      {
Lines 519-536 Link Here
519
          {
519
          {
520
            InternalCDOObject internalDirtyObject = (InternalCDOObject)entryDirty.getValue();
520
            InternalCDOObject internalDirtyObject = (InternalCDOObject)entryDirty.getValue();
521
            cleanObject(internalDirtyObject, getRevision(entryDirty.getKey(), true));
521
            cleanObject(internalDirtyObject, getRevision(entryDirty.getKey(), true));
522
            registerObject(internalDirtyObject);
523
          }
522
          }
524
        }
523
        }
525
      }
524
      }
526
525
527
      for (Entry<CDOID, CDOObject> entryDirtyObject : itrSavepoint.getDirtyObjects().entrySet())
526
      for (Entry<CDOID, CDOObject> entryDirtyObject : itrSavepoint.getDirtyObjects().entrySet())
528
      {
527
      {
529
        // Rollback every persisted objects
528
        // Rollback all persisted objects
530
        if (!entryDirtyObject.getKey().isTemporary())
529
        if (!entryDirtyObject.getKey().isTemporary())
531
        {
530
        {
532
          InternalCDOObject internalDirtyObject = (InternalCDOObject)entryDirtyObject.getValue();
531
          InternalCDOObject internalDirtyObject = (InternalCDOObject)entryDirtyObject.getValue();
533
          // cleanObject(internalDirtyObject, getRevision(entryDirtyObject.getKey(), true));
534
          CDOStateMachine.INSTANCE.rollback(internalDirtyObject);
532
          CDOStateMachine.INSTANCE.rollback(internalDirtyObject);
535
        }
533
        }
536
      }
534
      }
Lines 585-594 Link Here
585
    for (Entry<CDOID, CDOObject> entryNewObject : newObjMaps.entrySet())
583
    for (Entry<CDOID, CDOObject> entryNewObject : newObjMaps.entrySet())
586
    {
584
    {
587
      InternalCDOObject object = (InternalCDOObject)entryNewObject.getValue();
585
      InternalCDOObject object = (InternalCDOObject)entryNewObject.getValue();
588
      if (!isObjectRegistered(entryNewObject.getKey()))
589
      {
590
        registerObject(object);
591
      }
592
586
593
      // Go back to the previous state
587
      // Go back to the previous state
594
      cleanObject(object, (InternalCDORevision)object.cdoRevision());
588
      cleanObject(object, (InternalCDORevision)object.cdoRevision());
Lines 648-655 Link Here
648
    }
642
    }
649
643
650
    // deregister object
644
    // deregister object
651
    deregisterObject(object);
652
653
    if (object.cdoState() == CDOState.NEW)
645
    if (object.cdoState() == CDOState.NEW)
654
    {
646
    {
655
      Map<CDOID, ? extends CDOObject> map = object instanceof CDOResource ? getLastSavepoint().getNewResources()
647
      Map<CDOID, ? extends CDOObject> map = object instanceof CDOResource ? getLastSavepoint().getNewResources()
Lines 658-663 Link Here
658
      // Determine if we added object
650
      // Determine if we added object
659
      if (map.containsKey(object.cdoID()))
651
      if (map.containsKey(object.cdoID()))
660
      {
652
      {
653
        // deregister object
654
        deregisterObject(object);
661
        map.remove(object.cdoID());
655
        map.remove(object.cdoID());
662
      }
656
      }
663
      else
657
      else
Lines 1017-1023 Link Here
1017
1011
1018
    private Map<CDOID, CDORevisionDelta> revisionDeltas;
1012
    private Map<CDOID, CDORevisionDelta> revisionDeltas;
1019
1013
1020
    private Set<CDOID> detachedObjects;
1014
    private Map<CDOID, CDOObject> detachedObjects;
1021
1015
1022
    private List<CDOPackage> newPackages;
1016
    private List<CDOPackage> newPackages;
1023
1017
Lines 1027-1033 Link Here
1027
      newResources = transaction.getNewResources();
1021
      newResources = transaction.getNewResources();
1028
      newObjects = transaction.getNewObjects();
1022
      newObjects = transaction.getNewObjects();
1029
      dirtyObjects = transaction.getDirtyObjects();
1023
      dirtyObjects = transaction.getDirtyObjects();
1030
      detachedObjects = transaction.getDetachedObjects().keySet();
1024
      detachedObjects = transaction.getDetachedObjects();
1031
      revisionDeltas = transaction.getRevisionDeltas();
1025
      revisionDeltas = transaction.getRevisionDeltas();
1032
      newPackages = transaction.analyzeNewPackages();
1026
      newPackages = transaction.analyzeNewPackages();
1033
    }
1027
    }
Lines 1052-1058 Link Here
1052
      return newResources;
1046
      return newResources;
1053
    }
1047
    }
1054
1048
1055
    public Set<CDOID> getDetachedObjects()
1049
    public Map<CDOID, CDOObject> getDetachedObjects()
1056
    {
1050
    {
1057
      return detachedObjects;
1051
      return detachedObjects;
1058
    }
1052
    }
Lines 1109-1117 Link Here
1109
          postCommit(getNewResources(), result);
1103
          postCommit(getNewResources(), result);
1110
          postCommit(getNewObjects(), result);
1104
          postCommit(getNewObjects(), result);
1111
          postCommit(getDirtyObjects(), result);
1105
          postCommit(getDirtyObjects(), result);
1106
          for (Entry<CDOID, CDOObject> entry : getDetachedObjects().entrySet())
1107
          {
1108
            removeObject(entry.getKey());
1109
          }
1112
1110
1113
          CDOSessionImpl session = getTransaction().getSession();
1111
          CDOSessionImpl session = getTransaction().getSession();
1114
1115
          for (CDOPackage newPackage : newPackages)
1112
          for (CDOPackage newPackage : newPackages)
1116
          {
1113
          {
1117
            ((InternalCDOPackage)newPackage).setPersistent(true);
1114
            ((InternalCDOPackage)newPackage).setPersistent(true);
Lines 1120-1126 Link Here
1120
          ChangeSubscriptionManager changeSubscriptionManager = getTransaction().getChangeSubscriptionManager();
1117
          ChangeSubscriptionManager changeSubscriptionManager = getTransaction().getChangeSubscriptionManager();
1121
          changeSubscriptionManager.handleNewObjects(getNewObjects().values());
1118
          changeSubscriptionManager.handleNewObjects(getNewObjects().values());
1122
          changeSubscriptionManager.handleNewObjects(getNewResources().values());
1119
          changeSubscriptionManager.handleNewObjects(getNewResources().values());
1123
          changeSubscriptionManager.handleDetachedObjects(getDetachedObjects());
1120
          changeSubscriptionManager.handleDetachedObjects(getDetachedObjects().keySet());
1124
1121
1125
          long timeStamp = result.getTimeStamp();
1122
          long timeStamp = result.getTimeStamp();
1126
1123
Lines 1135-1141 Link Here
1135
1132
1136
          if (!dirtyIDs.isEmpty() || !getDetachedObjects().isEmpty())
1133
          if (!dirtyIDs.isEmpty() || !getDetachedObjects().isEmpty())
1137
          {
1134
          {
1138
            Set<CDOID> detachedIDs = new HashSet<CDOID>(getDetachedObjects());
1135
            Set<CDOID> detachedIDs = new HashSet<CDOID>(getDetachedObjects().keySet());
1139
            Collection<CDORevisionDelta> deltasCopy = new ArrayList<CDORevisionDelta>(deltas);
1136
            Collection<CDORevisionDelta> deltasCopy = new ArrayList<CDORevisionDelta>(deltas);
1140
            session.handleCommitNotification(timeStamp, dirtyIDs, detachedIDs, deltasCopy, getTransaction());
1137
            session.handleCommitNotification(timeStamp, dirtyIDs, detachedIDs, deltasCopy, getTransaction());
1141
          }
1138
          }
(-)src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java (-249 / +200 lines)
Lines 34-39 Link Here
34
import org.eclipse.emf.common.notify.Adapter;
34
import org.eclipse.emf.common.notify.Adapter;
35
import org.eclipse.emf.common.notify.Notification;
35
import org.eclipse.emf.common.notify.Notification;
36
import org.eclipse.emf.common.notify.NotificationChain;
36
import org.eclipse.emf.common.notify.NotificationChain;
37
import org.eclipse.emf.common.util.BasicEList;
37
import org.eclipse.emf.common.util.BasicEMap;
38
import org.eclipse.emf.common.util.BasicEMap;
38
import org.eclipse.emf.common.util.ECollections;
39
import org.eclipse.emf.common.util.ECollections;
39
import org.eclipse.emf.common.util.EList;
40
import org.eclipse.emf.common.util.EList;
Lines 49-55 Link Here
49
import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
50
import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
50
import org.eclipse.emf.ecore.resource.Resource;
51
import org.eclipse.emf.ecore.resource.Resource;
51
import org.eclipse.emf.ecore.resource.Resource.Internal;
52
import org.eclipse.emf.ecore.resource.Resource.Internal;
52
import org.eclipse.emf.ecore.util.DelegatingEcoreEList;
53
import org.eclipse.emf.ecore.util.DelegatingFeatureMap;
53
import org.eclipse.emf.ecore.util.DelegatingFeatureMap;
54
import org.eclipse.emf.ecore.util.EcoreEList;
54
import org.eclipse.emf.ecore.util.EcoreEList;
55
import org.eclipse.emf.ecore.util.EcoreEMap;
55
import org.eclipse.emf.ecore.util.EcoreEMap;
Lines 77-86 Link Here
77
77
78
  private InternalCDORevision revision;
78
  private InternalCDORevision revision;
79
79
80
  /**
81
   * CDO used this list instead of eSettings for transient objects. EMF used eSettings as cache. CDO deactivated the
82
   * cache but EMF still used eSettings to store list wrappers. CDO needs another place to store the real list with the
83
   * actual data (transient mode) and accessible through EStore. This allows CDO to always use the same instance of the
84
   * list wrapper.
85
   */
86
  private transient Object cdoSettings[];
87
80
  public CDOObjectImpl()
88
  public CDOObjectImpl()
81
  {
89
  {
82
    state = CDOState.TRANSIENT;
90
    state = CDOState.TRANSIENT;
83
    eContainer = null;
91
    eContainer = null;
92
    cdoSettings = null;
84
  }
93
  }
85
94
86
  public CDOID cdoID()
95
  public CDOID cdoID()
Lines 98-103 Link Here
98
    return revision;
107
    return revision;
99
  }
108
  }
100
109
110
  /**
111
   * @since 2.0
112
   */
113
  protected Object[] cdoSettings()
114
  {
115
    if (cdoSettings == null)
116
    {
117
      int size = eClass().getFeatureCount() - eStaticFeatureCount();
118
      cdoSettings = size == 0 ? ENO_SETTINGS : new Object[size];
119
    }
120
121
    return cdoSettings;
122
  }
123
124
  /**
125
   * @since 2.0
126
   */
127
  protected Object[] cdoBasicSettings()
128
  {
129
    return cdoSettings;
130
  }
131
101
  public CDOClass cdoClass()
132
  public CDOClass cdoClass()
102
  {
133
  {
103
    return getCDOClass(this);
134
    return getCDOClass(this);
Lines 201-213 Link Here
201
232
202
  public void cdoInternalPostLoad()
233
  public void cdoInternalPostLoad()
203
  {
234
  {
235
    // Reset EMAP objects
204
    if (eSettings != null)
236
    if (eSettings != null)
205
    {
237
    {
206
      // Make sure transient feature are kept but persisted value are not cached.
238
      // Make sure transient features are kept but persisted values are not cached.
207
      EClass eClass = eClass();
239
      EClass eClass = eClass();
208
      for (int i = 0; i < eClass.getFeatureCount(); i++)
240
      for (int i = 0; i < eClass.getFeatureCount(); i++)
209
      {
241
      {
210
        EStructuralFeature eFeature = cdoInternalDynamicFeature(i);
242
        EStructuralFeature eFeature = cdoInternalDynamicFeature(i);
243
211
        // We need to keep the existing list if possible.
244
        // We need to keep the existing list if possible.
212
        if (!eFeature.isTransient() && eSettings[i] instanceof InternalCDOLoadable)
245
        if (!eFeature.isTransient() && eSettings[i] instanceof InternalCDOLoadable)
213
        {
246
        {
Lines 230-249 Link Here
230
   */
263
   */
231
  public void cdoInternalCleanup()
264
  public void cdoInternalCleanup()
232
  {
265
  {
233
    if (eSettings != null)
266
    // Do nothing
234
    {
235
      // Make sure transient feature are kept but persisted value are not cached.
236
      EClass eClass = eClass();
237
      for (int i = 0; i < eClass.getFeatureCount(); i++)
238
      {
239
        EStructuralFeature eFeature = cdoInternalDynamicFeature(i);
240
        // We need to keep the existing list if possible.
241
        if (!eFeature.isTransient())
242
        {
243
          eSettings[i] = null;
244
        }
245
      }
246
    }
247
  }
267
  }
248
268
249
  public void cdoInternalPostAttach()
269
  public void cdoInternalPostAttach()
Lines 256-261 Link Here
256
    CDOViewImpl view = cdoView();
276
    CDOViewImpl view = cdoView();
257
    revision.setContainerID(eContainer == null ? CDOID.NULL : cdoView().convertObjectToID(eContainer, true));
277
    revision.setContainerID(eContainer == null ? CDOID.NULL : cdoView().convertObjectToID(eContainer, true));
258
    revision.setContainingFeatureID(eContainerFeatureID);
278
    revision.setContainingFeatureID(eContainerFeatureID);
279
259
    Resource directResource = eDirectResource();
280
    Resource directResource = eDirectResource();
260
    if (directResource instanceof CDOResource)
281
    if (directResource instanceof CDOResource)
261
    {
282
    {
Lines 263-270 Link Here
263
      revision.setResourceID(cdoResource.cdoID());
284
      revision.setResourceID(cdoResource.cdoID());
264
    }
285
    }
265
286
266
    eSettings();
267
268
    EClass eClass = eClass();
287
    EClass eClass = eClass();
269
    for (int i = 0; i < eClass.getFeatureCount(); i++)
288
    for (int i = 0; i < eClass.getFeatureCount(); i++)
270
    {
289
    {
Lines 274-279 Link Here
274
        populateRevisionFeature(view, revision, eFeature, eSettings, i);
293
        populateRevisionFeature(view, revision, eFeature, eSettings, i);
275
      }
294
      }
276
    }
295
    }
296
297
    cdoSettings = null;
277
  }
298
  }
278
299
279
  @SuppressWarnings("unchecked")
300
  @SuppressWarnings("unchecked")
Lines 287-293 Link Here
287
      TRACER.format("Populating feature {0}", cdoFeature);
308
      TRACER.format("Populating feature {0}", cdoFeature);
288
    }
309
    }
289
310
290
    Object setting = eSettings[i];
311
    Object setting = cdoBasicSettings() != null ? cdoSettings()[i] : null;
291
    if (setting == null)
312
    if (setting == null)
292
    {
313
    {
293
      setting = eFeature.getDefaultValue();
314
      setting = eFeature.getDefaultValue();
Lines 330-342 Link Here
330
351
331
      revision.set(cdoFeature, 0, setting);
352
      revision.set(cdoFeature, 0, setting);
332
    }
353
    }
333
334
    if (eSettings != null)
335
    {
336
      eSettings[i] = null;
337
    }
338
  }
354
  }
339
355
356
  /**
357
   * It is really important for accessing the data to go through {@link #cdoStore()}. {@link #eStore()} will redirect
358
   * you to the transient data.
359
   */
340
  public void cdoInternalPostDetach()
360
  public void cdoInternalPostDetach()
341
  {
361
  {
342
    if (TRACER.isEnabled())
362
    if (TRACER.isEnabled())
Lines 346-360 Link Here
346
366
347
    CDOViewImpl view = cdoView();
367
    CDOViewImpl view = cdoView();
348
    super.eSetDirectResource(cdoDirectResource());
368
    super.eSetDirectResource(cdoDirectResource());
349
    eContainer = eStore().getContainer(this);
369
350
    eContainerFeatureID = getStore().getContainingFeatureID(this);
370
    CDOStore store = cdoStore();
371
    eContainer = store.getContainer(this);
372
    eContainerFeatureID = store.getContainingFeatureID(this);
351
    if (eContainer != null && eContainmentFeature().isResolveProxies())
373
    if (eContainer != null && eContainmentFeature().isResolveProxies())
352
    {
374
    {
353
      adjustOppositeReference(eContainer, eContainmentFeature());
375
      adjustOppositeReference(eContainer, eContainmentFeature());
354
    }
376
    }
355
377
356
    // Ensure that the internal eSettings array is initialized;
378
    // Ensure that the internal eSettings array is initialized;
357
    eSettings();
379
    resetSettings();
358
380
359
    EClass eClass = eClass();
381
    EClass eClass = eClass();
360
    for (int i = 0; i < eClass.getFeatureCount(); i++)
382
    for (int i = 0; i < eClass.getFeatureCount(); i++)
Lines 367-373 Link Here
367
    }
389
    }
368
  }
390
  }
369
391
370
  @SuppressWarnings("unchecked")
392
  private void resetSettings()
393
  {
394
    cdoSettings = null;
395
    cdoSettings();
396
  }
397
371
  private void depopulateRevisionFeature(CDOViewImpl view, InternalCDORevision revision, EStructuralFeature eFeature,
398
  private void depopulateRevisionFeature(CDOViewImpl view, InternalCDORevision revision, EStructuralFeature eFeature,
372
      Object[] eSettings, int i)
399
      Object[] eSettings, int i)
373
  {
400
  {
Lines 379-395 Link Here
379
    EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)eFeature;
406
    EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)eFeature;
380
    EReference oppositeReference = cdoID().isTemporary() ? null : internalFeature.getEOpposite();
407
    EReference oppositeReference = cdoID().isTemporary() ? null : internalFeature.getEOpposite();
381
408
409
    CDOStore cdoStore = cdoStore();
410
    EStore eStore = eStore();
382
    if (eFeature.isMany())
411
    if (eFeature.isMany())
383
    {
412
    {
384
      eSettings[i] = null;
413
385
      InternalEList<Object> setting = (InternalEList<Object>)eGet(eFeature, true);
414
      int size = cdoStore.size(this, eFeature);
386
      int size = eStore().size(this, eFeature);
387
      for (int index = 0; index < size; index++)
415
      for (int index = 0; index < size; index++)
388
      {
416
      {
389
        // Do not trigger events
417
        // Do not trigger events
390
        // Do not trigger inverse updates
418
        // Do not trigger inverse updates
391
        Object object = eStore().get(this, eFeature, index);
419
        Object object = cdoStore.get(this, eFeature, index);
392
        setting.basicAdd(object, null);
420
        eStore.add(this, eFeature, index, object);
393
        if (oppositeReference != null)
421
        if (oppositeReference != null)
394
        {
422
        {
395
          adjustOppositeReference((InternalEObject)object, oppositeReference);
423
          adjustOppositeReference((InternalEObject)object, oppositeReference);
Lines 398-407 Link Here
398
    }
426
    }
399
    else
427
    else
400
    {
428
    {
401
      eSettings[i] = eStore().get(this, eFeature, 0);
429
      Object object = cdoStore.get(this, eFeature, EStore.NO_INDEX);
430
      eStore.set(this, eFeature, EStore.NO_INDEX, object);
402
      if (oppositeReference != null)
431
      if (oppositeReference != null)
403
      {
432
      {
404
        adjustOppositeReference((InternalEObject)eSettings[i], oppositeReference);
433
        adjustOppositeReference((InternalEObject)object, oppositeReference);
405
      }
434
      }
406
    }
435
    }
407
  }
436
  }
Lines 534-540 Link Here
534
        public EStoreEcoreEMap()
563
        public EStoreEcoreEMap()
535
        {
564
        {
536
          super((EClass)eType, eType.getInstanceClass(), null);
565
          super((EClass)eType, eType.getInstanceClass(), null);
537
          delegateEList = new CDOStoreEList<BasicEMap.Entry<Object, Object>>(eStructuralFeature)
566
          delegateEList = new BasicEStoreEList<BasicEMap.Entry<Object, Object>>(CDOObjectImpl.this, eStructuralFeature)
538
          {
567
          {
539
            private static final long serialVersionUID = 1L;
568
            private static final long serialVersionUID = 1L;
540
569
Lines 576-582 Link Here
576
605
577
        private void checkListForReading()
606
        private void checkListForReading()
578
        {
607
        {
579
          CDOStateMachine.INSTANCE.read(CDOObjectImpl.this);
608
          if (!FSMUtil.isTransient(CDOObjectImpl.this))
609
          {
610
            CDOStateMachine.INSTANCE.read(CDOObjectImpl.this);
611
          }
580
        }
612
        }
581
613
582
        /**
614
        /**
Lines 641-647 Link Here
641
      return new EStoreEcoreEMap();
673
      return new EStoreEcoreEMap();
642
    }
674
    }
643
675
644
    return new CDOStoreEList<Object>(eStructuralFeature);
676
    return super.createList(eStructuralFeature);
645
  }
677
  }
646
678
647
  @Override
679
  @Override
Lines 659-665 Link Here
659
    }
691
    }
660
    else if (resource instanceof CDOResourceImpl || resource == null)
692
    else if (resource instanceof CDOResourceImpl || resource == null)
661
    {
693
    {
662
      getStore().setContainer(this, (CDOResourceImpl)resource, eInternalContainer(), eContainerFeatureID());
694
      cdoStore().setContainer(this, (CDOResourceImpl)resource, eInternalContainer(), eContainerFeatureID());
663
    }
695
    }
664
    else
696
    else
665
    {
697
    {
Lines 678-760 Link Here
678
      return super.eDirectResource();
710
      return super.eDirectResource();
679
    }
711
    }
680
712
681
    return (Resource.Internal)getStore().getResource(this);
713
    return (Resource.Internal)cdoStore().getResource(this);
682
  }
714
  }
683
715
684
  /**
716
  /**
685
   * Don't cache non-transient features in this CDOObject's {@link #eSettings()}.
717
   * @since 2.0
686
   */
718
   */
687
  @Override
719
  @Override
688
  protected boolean eIsCaching()
720
  public InternalEObject.EStore eStore()
689
  {
690
    return false;
691
  }
692
693
  @Override
694
  public Object dynamicGet(int dynamicFeatureID)
695
  {
696
    if (FSMUtil.isTransient(this))
697
    {
698
      if (eSettings == null)
699
      {
700
        return null;
701
      }
702
703
      return eSettings[dynamicFeatureID];
704
    }
705
706
    // Delegate to CDOStore
707
    return super.dynamicGet(dynamicFeatureID);
708
  }
709
710
  @Override
711
  public boolean eIsSet(EStructuralFeature feature)
712
  {
721
  {
713
    if (FSMUtil.isTransient(this))
722
    if (FSMUtil.isTransient(this))
714
    {
723
    {
715
      // TODO What about defaultValues != null?
724
      return CDOStoreSettingsImpl.INSTANCE;
716
      if (eSettings == null)
717
      {
718
        return false;
719
      }
720
721
      return eSettings[eDynamicFeatureID(feature)] != null;
722
    }
725
    }
723
726
724
    // Delegate to CDOStore
727
    return cdoStore();
725
    return super.eIsSet(feature);
726
  }
727
728
  @Override
729
  public void dynamicSet(int dynamicFeatureID, Object value)
730
  {
731
    if (FSMUtil.isTransient(this))
732
    {
733
      eSettings(); // Important to create eSettings array if necessary
734
      eSettings[dynamicFeatureID] = value;
735
    }
736
    else
737
    {
738
      // Delegate to CDOStore
739
      super.dynamicSet(dynamicFeatureID, value);
740
    }
741
  }
728
  }
742
729
730
  /**
731
   * Don't cache non-transient features in this CDOObject's {@link #eSettings()}.
732
   */
743
  @Override
733
  @Override
744
  public void dynamicUnset(int dynamicFeatureID)
734
  protected boolean eIsCaching()
745
  {
735
  {
746
    if (FSMUtil.isTransient(this))
736
    return false;
747
    {
748
      if (eSettings != null)
749
      {
750
        eSettings[dynamicFeatureID] = null;
751
      }
752
    }
753
    else
754
    {
755
      // Delegate to CDOStore
756
      super.dynamicUnset(dynamicFeatureID);
757
    }
758
  }
737
  }
759
738
760
  @Override
739
  @Override
Lines 768-774 Link Here
768
    else
747
    else
769
    {
748
    {
770
      // Delegate to CDOStore
749
      // Delegate to CDOStore
771
      container = getStore().getContainer(this);
750
      container = cdoStore().getContainer(this);
772
    }
751
    }
773
752
774
    if (container instanceof CDOResource)
753
    if (container instanceof CDOResource)
Lines 788-794 Link Here
788
    }
767
    }
789
768
790
    // Delegate to CDOStore
769
    // Delegate to CDOStore
791
    return getStore().getContainingFeatureID(this);
770
    return cdoStore().getContainingFeatureID(this);
792
  }
771
  }
793
772
794
  /**
773
  /**
Lines 960-966 Link Here
960
    }
939
    }
961
    else
940
    else
962
    {
941
    {
963
      getStore().setContainer(this, cdoDirectResource(), newEContainer, newContainerFeatureID);
942
      cdoStore().setContainer(this, cdoDirectResource(), newEContainer, newContainerFeatureID);
964
    }
943
    }
965
  }
944
  }
966
945
Lines 991-1206 Link Here
991
    return ModelUtil.getCDOClass(cdoObject.eClass(), packageManager);
970
    return ModelUtil.getCDOClass(cdoObject.eClass(), packageManager);
992
  }
971
  }
993
972
994
  private CDOStore getStore()
973
  private CDOStore cdoStore()
995
  {
974
  {
996
    return (CDOStore)eStore();
975
    return cdoView().getStore();
997
  }
976
  }
998
977
999
  /**
978
  /**
1000
   * TODO Remove this when EMF has fixed http://bugs.eclipse.org/197487
1001
   * 
1002
   * @author Eike Stepper
979
   * @author Eike Stepper
980
   * @since 2.0
1003
   */
981
   */
1004
  public class CDOStoreEList<E> extends DelegatingEcoreEList.Dynamic<E>
982
  public static class CDOStoreSettingsImpl implements InternalEObject.EStore
1005
  {
983
  {
1006
    private static final long serialVersionUID = 1L;
984
    public static CDOStoreSettingsImpl INSTANCE = new CDOStoreSettingsImpl();
1007
985
1008
    public CDOStoreEList(EStructuralFeature eStructuralFeature)
986
    private CDOStoreSettingsImpl()
1009
    {
987
    {
1010
      super(CDOObjectImpl.this, eStructuralFeature);
1011
    }
988
    }
1012
989
1013
    @Override
990
    protected Object getValue(InternalEObject eObject, int dynamicFeatureID)
1014
    protected List<E> delegateList()
1015
    {
991
    {
1016
      throw new UnsupportedOperationException();
992
      return ((CDOObjectImpl)eObject).cdoSettings()[dynamicFeatureID];
993
1017
    }
994
    }
1018
995
1019
    @Override
996
    protected EList<Object> getValueAsList(InternalEObject eObject, int dynamicFeatureID)
1020
    public EStructuralFeature getEStructuralFeature()
1021
    {
997
    {
1022
      return eStructuralFeature;
998
      @SuppressWarnings("unchecked")
999
      EList<Object> result = (EList<Object>)getValue(eObject, dynamicFeatureID);
1000
      if (result == null)
1001
      {
1002
        result = new BasicEList<Object>();
1003
        ((CDOObjectImpl)eObject).cdoSettings()[dynamicFeatureID] = result;
1004
      }
1005
1006
      return result;
1023
    }
1007
    }
1024
1008
1025
    @Override
1009
    protected Object setValue(InternalEObject eObject, int dynamicFeatureID, Object newValue)
1026
    protected void delegateAdd(int index, Object object)
1027
    {
1010
    {
1028
      getStore().add(owner, eStructuralFeature, index, object);
1011
      Object eSettings[] = ((CDOObjectImpl)eObject).cdoSettings();
1012
1013
      try
1014
      {
1015
        return eSettings[dynamicFeatureID];
1016
      }
1017
      finally
1018
      {
1019
        eSettings[dynamicFeatureID] = newValue;
1020
      }
1029
    }
1021
    }
1030
1022
1031
    @Override
1023
    protected int eDynamicFeatureID(InternalEObject eObject, EStructuralFeature feature)
1032
    protected void delegateAdd(Object object)
1033
    {
1024
    {
1034
      delegateAdd(delegateSize(), object);
1025
      return ((CDOObjectImpl)eObject).eDynamicFeatureID(feature);
1035
    }
1026
    }
1036
1027
1037
    @Override
1028
    public Object get(InternalEObject eObject, EStructuralFeature feature, int index)
1038
    protected List<E> delegateBasicList()
1039
    {
1029
    {
1040
      int size = delegateSize();
1030
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1041
      if (size == 0)
1031
      if (feature.isMany())
1042
      {
1032
      {
1043
        return ECollections.emptyEList();
1033
        return getValueAsList(eObject, dynamicFeatureID).get(index);
1044
      }
1034
      }
1045
1035
1046
      Object[] data = getStore().toArray(owner, eStructuralFeature);
1036
      return getValue(eObject, dynamicFeatureID);
1047
      return new EcoreEList.UnmodifiableEList<E>(owner, eStructuralFeature, data.length, data);
1048
    }
1037
    }
1049
1038
1050
    @Override
1039
    public Object set(InternalEObject eObject, EStructuralFeature feature, int index, Object value)
1051
    protected void delegateClear()
1052
    {
1040
    {
1053
      getStore().clear(owner, eStructuralFeature);
1041
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1042
      if (feature.isMany())
1043
      {
1044
        return getValueAsList(eObject, dynamicFeatureID).set(index, value);
1045
      }
1046
1047
      return setValue(eObject, dynamicFeatureID, value);
1054
    }
1048
    }
1055
1049
1056
    @Override
1050
    public void add(InternalEObject eObject, EStructuralFeature feature, int index, Object value)
1057
    protected boolean delegateContains(Object object)
1058
    {
1051
    {
1059
      return getStore().contains(owner, eStructuralFeature, object);
1052
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1053
      getValueAsList(eObject, dynamicFeatureID).add(index, value);
1060
    }
1054
    }
1061
1055
1062
    @Override
1056
    public Object remove(InternalEObject eObject, EStructuralFeature feature, int index)
1063
    protected boolean delegateContainsAll(Collection<?> collection)
1064
    {
1057
    {
1065
      for (Object o : collection)
1058
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1066
      {
1059
      return getValueAsList(eObject, dynamicFeatureID).remove(index);
1067
        if (!delegateContains(o))
1068
        {
1069
          return false;
1070
        }
1071
      }
1072
      return true;
1073
    }
1060
    }
1074
1061
1075
    @SuppressWarnings("unchecked")
1062
    public Object move(InternalEObject eObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
1076
    @Override
1077
    protected E delegateGet(int index)
1078
    {
1063
    {
1079
      return (E)getStore().get(owner, eStructuralFeature, index);
1064
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1065
      return getValueAsList(eObject, dynamicFeatureID).move(targetIndex, sourceIndex);
1080
    }
1066
    }
1081
1067
1082
    @Override
1068
    public void clear(InternalEObject eObject, EStructuralFeature feature)
1083
    protected int delegateHashCode()
1084
    {
1069
    {
1085
      return getStore().hashCode(owner, eStructuralFeature);
1070
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1071
      if (feature.isMany())
1072
      {
1073
        getValueAsList(eObject, dynamicFeatureID).clear();
1074
      }
1075
1076
      setValue(eObject, dynamicFeatureID, null);
1086
    }
1077
    }
1087
1078
1088
    @Override
1079
    public int size(InternalEObject eObject, EStructuralFeature feature)
1089
    protected int delegateIndexOf(Object object)
1090
    {
1080
    {
1091
      return getStore().indexOf(owner, eStructuralFeature, object);
1081
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1082
      return getValueAsList(eObject, dynamicFeatureID).size();
1092
    }
1083
    }
1093
1084
1094
    @Override
1085
    public int indexOf(InternalEObject eObject, EStructuralFeature feature, Object value)
1095
    protected boolean delegateIsEmpty()
1096
    {
1086
    {
1097
      return getStore().isEmpty(owner, eStructuralFeature);
1087
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1088
      return getValueAsList(eObject, dynamicFeatureID).indexOf(value);
1098
    }
1089
    }
1099
1090
1100
    @Override
1091
    public int lastIndexOf(InternalEObject eObject, EStructuralFeature feature, Object value)
1101
    protected Iterator<E> delegateIterator()
1102
    {
1092
    {
1103
      return iterator();
1093
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1094
      return getValueAsList(eObject, dynamicFeatureID).lastIndexOf(value);
1104
    }
1095
    }
1105
1096
1106
    @Override
1097
    public Object[] toArray(InternalEObject eObject, EStructuralFeature feature)
1107
    protected int delegateLastIndexOf(Object object)
1108
    {
1098
    {
1109
      return getStore().lastIndexOf(owner, eStructuralFeature, object);
1099
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1100
      return getValueAsList(eObject, dynamicFeatureID).toArray();
1110
    }
1101
    }
1111
1102
1112
    @Override
1103
    public <T> T[] toArray(InternalEObject eObject, EStructuralFeature feature, T[] array)
1113
    protected ListIterator<E> delegateListIterator()
1114
    {
1104
    {
1115
      return listIterator();
1105
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1106
      return getValueAsList(eObject, dynamicFeatureID).toArray(array);
1116
    }
1107
    }
1117
1108
1118
    @SuppressWarnings("unchecked")
1109
    public boolean isEmpty(InternalEObject eObject, EStructuralFeature feature)
1119
    @Override
1120
    protected E delegateRemove(int index)
1121
    {
1110
    {
1122
      return (E)getStore().remove(owner, eStructuralFeature, index);
1111
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1112
      return getValueAsList(eObject, dynamicFeatureID).isEmpty();
1123
    }
1113
    }
1124
1114
1125
    @SuppressWarnings("unchecked")
1115
    public boolean contains(InternalEObject eObject, EStructuralFeature feature, Object value)
1126
    @Override
1127
    protected E delegateSet(int index, E object)
1128
    {
1116
    {
1129
      return (E)getStore().set(owner, eStructuralFeature, index, object);
1117
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1118
      return getValueAsList(eObject, dynamicFeatureID).contains(value);
1130
    }
1119
    }
1131
1120
1132
    @Override
1121
    public int hashCode(InternalEObject eObject, EStructuralFeature feature)
1133
    protected int delegateSize()
1134
    {
1122
    {
1135
      return getStore().size(owner, eStructuralFeature);
1123
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1124
      return getValueAsList(eObject, dynamicFeatureID).hashCode();
1136
    }
1125
    }
1137
1126
1138
    @Override
1127
    public InternalEObject getContainer(InternalEObject eObject)
1139
    protected Object[] delegateToArray()
1140
    {
1128
    {
1141
      return getStore().toArray(owner, eStructuralFeature);
1129
      return null;
1142
    }
1130
    }
1143
1131
1144
    @Override
1132
    public EStructuralFeature getContainingFeature(InternalEObject eObject)
1145
    protected <T> T[] delegateToArray(T[] array)
1146
    {
1133
    {
1147
      return getStore().toArray(owner, eStructuralFeature, array);
1134
      // This should never be called.
1135
      throw new UnsupportedOperationException();
1148
    }
1136
    }
1149
1137
1150
    @SuppressWarnings("unchecked")
1138
    public EObject create(EClass eClass)
1151
    @Override
1152
    protected E delegateMove(int targetIndex, int sourceIndex)
1153
    {
1139
    {
1154
      return (E)getStore().move(owner, eStructuralFeature, targetIndex, sourceIndex);
1140
      return new EStoreEObjectImpl(eClass, this);
1155
    }
1141
    }
1156
1142
1157
    @Override
1143
    public boolean isSet(InternalEObject eObject, EStructuralFeature feature)
1158
    protected boolean delegateEquals(Object object)
1159
    {
1144
    {
1160
      if (object == this)
1145
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1161
      {
1146
      return getValue(eObject, dynamicFeatureID) != null;
1162
        return true;
1163
      }
1164
1165
      if (!(object instanceof List))
1166
      {
1167
        return false;
1168
      }
1169
1170
      List<?> list = (List<?>)object;
1171
      if (list.size() != delegateSize())
1172
      {
1173
        return false;
1174
      }
1175
1176
      for (ListIterator<?> i = list.listIterator(); i.hasNext();)
1177
      {
1178
        Object element = i.next();
1179
        if (element == null ? get(i.previousIndex()) != null : !element.equals(get(i.previousIndex())))
1180
        {
1181
          return false;
1182
        }
1183
      }
1184
1185
      return true;
1186
    }
1147
    }
1187
1148
1188
    @Override
1149
    public void unset(InternalEObject eObject, EStructuralFeature feature)
1189
    protected String delegateToString()
1190
    {
1150
    {
1191
      StringBuffer stringBuffer = new StringBuffer();
1151
      int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
1192
      stringBuffer.append("[");
1152
      setValue(eObject, dynamicFeatureID, null);
1193
      for (int i = 0, size = size(); i < size;)
1194
      {
1195
        Object value = delegateGet(i);
1196
        stringBuffer.append(String.valueOf(value));
1197
        if (++i < size)
1198
        {
1199
          stringBuffer.append(", ");
1200
        }
1201
      }
1202
      stringBuffer.append("]");
1203
      return stringBuffer.toString();
1204
    }
1153
    }
1205
  }
1154
  }
1206
1155
Lines 1233-1239 Link Here
1233
    @Override
1182
    @Override
1234
    protected void delegateAdd(int index, Entry object)
1183
    protected void delegateAdd(int index, Entry object)
1235
    {
1184
    {
1236
      getStore().add(owner, eStructuralFeature, index, object);
1185
      eStore().add(owner, eStructuralFeature, index, object);
1237
    }
1186
    }
1238
1187
1239
    @Override
1188
    @Override
Lines 1251-1270 Link Here
1251
        return ECollections.emptyEList();
1200
        return ECollections.emptyEList();
1252
      }
1201
      }
1253
1202
1254
      Object[] data = getStore().toArray(owner, eStructuralFeature);
1203
      Object[] data = cdoStore().toArray(owner, eStructuralFeature);
1255
      return new EcoreEList.UnmodifiableEList<FeatureMap.Entry>(owner, eStructuralFeature, data.length, data);
1204
      return new EcoreEList.UnmodifiableEList<FeatureMap.Entry>(owner, eStructuralFeature, data.length, data);
1256
    }
1205
    }
1257
1206
1258
    @Override
1207
    @Override
1259
    protected void delegateClear()
1208
    protected void delegateClear()
1260
    {
1209
    {
1261
      getStore().clear(owner, eStructuralFeature);
1210
      eStore().clear(owner, eStructuralFeature);
1262
    }
1211
    }
1263
1212
1264
    @Override
1213
    @Override
1265
    protected boolean delegateContains(Object object)
1214
    protected boolean delegateContains(Object object)
1266
    {
1215
    {
1267
      return getStore().contains(owner, eStructuralFeature, object);
1216
      return eStore().contains(owner, eStructuralFeature, object);
1268
    }
1217
    }
1269
1218
1270
    @Override
1219
    @Override
Lines 1277-1307 Link Here
1277
          return false;
1226
          return false;
1278
        }
1227
        }
1279
      }
1228
      }
1229
1280
      return true;
1230
      return true;
1281
    }
1231
    }
1282
1232
1283
    @Override
1233
    @Override
1284
    protected Entry delegateGet(int index)
1234
    protected Entry delegateGet(int index)
1285
    {
1235
    {
1286
      return (Entry)getStore().get(owner, eStructuralFeature, index);
1236
      return (Entry)eStore().get(owner, eStructuralFeature, index);
1287
    }
1237
    }
1288
1238
1289
    @Override
1239
    @Override
1290
    protected int delegateHashCode()
1240
    protected int delegateHashCode()
1291
    {
1241
    {
1292
      return getStore().hashCode(owner, eStructuralFeature);
1242
      return eStore().hashCode(owner, eStructuralFeature);
1293
    }
1243
    }
1294
1244
1295
    @Override
1245
    @Override
1296
    protected int delegateIndexOf(Object object)
1246
    protected int delegateIndexOf(Object object)
1297
    {
1247
    {
1298
      return getStore().indexOf(owner, eStructuralFeature, object);
1248
      return eStore().indexOf(owner, eStructuralFeature, object);
1299
    }
1249
    }
1300
1250
1301
    @Override
1251
    @Override
1302
    protected boolean delegateIsEmpty()
1252
    protected boolean delegateIsEmpty()
1303
    {
1253
    {
1304
      return getStore().isEmpty(owner, eStructuralFeature);
1254
      return eStore().isEmpty(owner, eStructuralFeature);
1305
    }
1255
    }
1306
1256
1307
    @Override
1257
    @Override
Lines 1313-1319 Link Here
1313
    @Override
1263
    @Override
1314
    protected int delegateLastIndexOf(Object object)
1264
    protected int delegateLastIndexOf(Object object)
1315
    {
1265
    {
1316
      return getStore().lastIndexOf(owner, eStructuralFeature, object);
1266
      return eStore().lastIndexOf(owner, eStructuralFeature, object);
1317
    }
1267
    }
1318
1268
1319
    @Override
1269
    @Override
Lines 1325-1361 Link Here
1325
    @Override
1275
    @Override
1326
    protected Entry delegateRemove(int index)
1276
    protected Entry delegateRemove(int index)
1327
    {
1277
    {
1328
      return (Entry)getStore().remove(owner, eStructuralFeature, index);
1278
      return (Entry)eStore().remove(owner, eStructuralFeature, index);
1329
    }
1279
    }
1330
1280
1331
    @Override
1281
    @Override
1332
    protected Entry delegateSet(int index, Entry object)
1282
    protected Entry delegateSet(int index, Entry object)
1333
    {
1283
    {
1334
      return (Entry)getStore().set(owner, eStructuralFeature, index, object);
1284
      return (Entry)eStore().set(owner, eStructuralFeature, index, object);
1335
    }
1285
    }
1336
1286
1337
    @Override
1287
    @Override
1338
    protected int delegateSize()
1288
    protected int delegateSize()
1339
    {
1289
    {
1340
      return getStore().size(owner, eStructuralFeature);
1290
      return eStore().size(owner, eStructuralFeature);
1341
    }
1291
    }
1342
1292
1343
    @Override
1293
    @Override
1344
    protected Object[] delegateToArray()
1294
    protected Object[] delegateToArray()
1345
    {
1295
    {
1346
      return getStore().toArray(owner, eStructuralFeature);
1296
      return eStore().toArray(owner, eStructuralFeature);
1347
    }
1297
    }
1348
1298
1349
    @Override
1299
    @Override
1350
    protected <T> T[] delegateToArray(T[] array)
1300
    protected <T> T[] delegateToArray(T[] array)
1351
    {
1301
    {
1352
      return getStore().toArray(owner, eStructuralFeature, array);
1302
      return eStore().toArray(owner, eStructuralFeature, array);
1353
    }
1303
    }
1354
1304
1355
    @Override
1305
    @Override
1356
    protected Entry delegateMove(int targetIndex, int sourceIndex)
1306
    protected Entry delegateMove(int targetIndex, int sourceIndex)
1357
    {
1307
    {
1358
      return (Entry)getStore().move(owner, eStructuralFeature, targetIndex, sourceIndex);
1308
      return (Entry)eStore().move(owner, eStructuralFeature, targetIndex, sourceIndex);
1359
    }
1309
    }
1360
1310
1361
    @Override
1311
    @Override
Lines 1372-1377 Link Here
1372
          stringBuffer.append(", ");
1322
          stringBuffer.append(", ");
1373
        }
1323
        }
1374
      }
1324
      }
1325
1375
      stringBuffer.append("]");
1326
      stringBuffer.append("]");
1376
      return stringBuffer.toString();
1327
      return stringBuffer.toString();
1377
    }
1328
    }
(-)src/org/eclipse/emf/internal/cdo/CDOCommitContext.java (-2 / +1 lines)
Lines 21-27 Link Here
21
21
22
import java.util.List;
22
import java.util.List;
23
import java.util.Map;
23
import java.util.Map;
24
import java.util.Set;
25
24
26
/**
25
/**
27
 * Provides a context for a commit operation.
26
 * Provides a context for a commit operation.
Lines 45-51 Link Here
45
44
46
  public Map<CDOID, CDOObject> getDirtyObjects();
45
  public Map<CDOID, CDOObject> getDirtyObjects();
47
46
48
  public Set<CDOID> getDetachedObjects();
47
  public Map<CDOID, CDOObject> getDetachedObjects();
49
48
50
  public Map<CDOID, CDORevisionDelta> getRevisionDeltas();
49
  public Map<CDOID, CDORevisionDelta> getRevisionDeltas();
51
}
50
}
(-)src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java (-1 / +1 lines)
Lines 103-109 Link Here
103
    Collection<CDOResource> newResources = commitContext.getNewResources().values();
103
    Collection<CDOResource> newResources = commitContext.getNewResources().values();
104
    Collection<CDOObject> newObjects = commitContext.getNewObjects().values();
104
    Collection<CDOObject> newObjects = commitContext.getNewObjects().values();
105
    Collection<CDORevisionDelta> revisionDeltas = commitContext.getRevisionDeltas().values();
105
    Collection<CDORevisionDelta> revisionDeltas = commitContext.getRevisionDeltas().values();
106
    Collection<CDOID> detachedObjects = commitContext.getDetachedObjects();
106
    Collection<CDOID> detachedObjects = commitContext.getDetachedObjects().keySet();
107
107
108
    out.writeInt(newPackages.size());
108
    out.writeInt(newPackages.size());
109
    out.writeInt(newResources.size() + newObjects.size());
109
    out.writeInt(newResources.size() + newObjects.size());
(-)src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java (-1 / +5 lines)
Lines 16-21 Link Here
16
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_246442_Test;
16
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_246442_Test;
17
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_246456_Test;
17
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_246456_Test;
18
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_246622_Test;
18
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_246622_Test;
19
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_248052_Test;
19
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_248124_Test;
20
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_248124_Test;
20
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_248915_Test;
21
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_248915_Test;
21
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_250036_Test;
22
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_250036_Test;
Lines 23-28 Link Here
23
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_250910_Test;
24
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_250910_Test;
24
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251087_Test;
25
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251087_Test;
25
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251263_Test;
26
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251263_Test;
27
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251544_Test;
26
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251752_Test;
28
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251752_Test;
27
import org.eclipse.emf.cdo.tests.config.ConfigTest;
29
import org.eclipse.emf.cdo.tests.config.ConfigTest;
28
import org.eclipse.emf.cdo.tests.config.ConfigTestSuite;
30
import org.eclipse.emf.cdo.tests.config.ConfigTestSuite;
Lines 85-98 Link Here
85
    testClasses.add(Bugzilla_246442_Test.class);
87
    testClasses.add(Bugzilla_246442_Test.class);
86
    testClasses.add(Bugzilla_246456_Test.class);
88
    testClasses.add(Bugzilla_246456_Test.class);
87
    testClasses.add(Bugzilla_246622_Test.class);
89
    testClasses.add(Bugzilla_246622_Test.class);
90
    testClasses.add(Bugzilla_248052_Test.class);
88
    testClasses.add(Bugzilla_248124_Test.class);
91
    testClasses.add(Bugzilla_248124_Test.class);
89
    testClasses.add(Bugzilla_248915_Test.class);
92
    testClasses.add(Bugzilla_248915_Test.class);
90
    testClasses.add(Bugzilla_250036_Test.class);
93
    testClasses.add(Bugzilla_250036_Test.class);
91
    testClasses.add(Bugzilla_250757_Test.class);
94
    testClasses.add(Bugzilla_250757_Test.class);
95
    testClasses.add(Bugzilla_250910_Test.class);
92
    testClasses.add(Bugzilla_251087_Test.class);
96
    testClasses.add(Bugzilla_251087_Test.class);
93
    testClasses.add(Bugzilla_251263_Test.class);
97
    testClasses.add(Bugzilla_251263_Test.class);
98
    testClasses.add(Bugzilla_251544_Test.class);
94
    testClasses.add(Bugzilla_251752_Test.class);
99
    testClasses.add(Bugzilla_251752_Test.class);
95
    testClasses.add(Bugzilla_250910_Test.class);
96
100
97
    // TODO testClasses.add(NonCDOResourceTest.class);
101
    // TODO testClasses.add(NonCDOResourceTest.class);
98
    // TODO testClasses.add(GeneratedEcoreTest.class);
102
    // TODO testClasses.add(GeneratedEcoreTest.class);
(-)src/org/eclipse/emf/cdo/tests/DetachTest.java (-13 / +23 lines)
Lines 57-62 Link Here
57
    assertNull(transaction.getResourceSet().getEObject(uriC1, false));
57
    assertNull(transaction.getResourceSet().getEObject(uriC1, false));
58
58
59
    transaction.commit();
59
    transaction.commit();
60
    assertNull(transaction.getResourceSet().getEObject(uriC1, false));
61
    session.close();
60
  }
62
  }
61
63
62
  public void testCleanObjectDeletion() throws Exception
64
  public void testCleanObjectDeletion() throws Exception
Lines 76-93 Link Here
76
78
77
    resource.getContents().remove(c1);
79
    resource.getContents().remove(c1);
78
    assertTransient(c1);
80
    assertTransient(c1);
81
    assertSame(c1, transaction.getObject(id));
82
    assertSame(c1, transaction.getResourceSet().getEObject(uriC1, false));
79
83
80
    try
81
    {
82
      transaction.getObject(id);
83
      fail("ObjectNotFoundException expected");
84
    }
85
    catch (ObjectNotFoundException expected)
86
    {
87
      // SUCCESS
88
    }
89
90
    assertNull(transaction.getResourceSet().getEObject(uriC1, false));
91
    transaction.commit();
84
    transaction.commit();
92
    assertTransient(c1);
85
    assertTransient(c1);
93
86
Lines 102-107 Link Here
102
    }
95
    }
103
96
104
    assertNull(transaction.getResourceSet().getEObject(uriC1, false));
97
    assertNull(transaction.getResourceSet().getEObject(uriC1, false));
98
    session.close();
105
  }
99
  }
106
100
107
  public void testSavePointNewObjectDeletion() throws Exception
101
  public void testSavePointNewObjectDeletion() throws Exception
Lines 149-164 Link Here
149
143
150
    CDOSavepoint savepoint2 = transaction.setSavepoint();
144
    CDOSavepoint savepoint2 = transaction.setSavepoint();
151
    c1.setName("SIMON2");
145
    c1.setName("SIMON2");
152
    assertNull(transaction.getResourceSet().getEObject(uriC1, false));
146
    if (isPersisted)
147
    {
148
      assertNotNull(transaction.getResourceSet().getEObject(uriC1, false));
149
    }
150
    else
151
    {
152
      assertNull(transaction.getResourceSet().getEObject(uriC1, false));
153
    }
153
154
154
    savepoint2.rollback();
155
    savepoint2.rollback();
155
    assertEquals("SIMON2", c1.getName());
156
    assertEquals("SIMON2", c1.getName());
156
    assertTransient(c1);
157
    assertTransient(c1);
157
    assertNull(transaction.getResourceSet().getEObject(uriC1, false));
158
159
    if (isPersisted)
160
    {
161
      assertNotNull(transaction.getResourceSet().getEObject(uriC1, false));
162
    }
163
    else
164
    {
165
      assertNull(transaction.getResourceSet().getEObject(uriC1, false));
166
    }
158
167
159
    savepoint.rollback();
168
    savepoint.rollback();
160
    assertEquals("SIMON", c1.getName());
169
    assertEquals("SIMON", c1.getName());
161
    assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
170
    assertEquals(c1, transaction.getResourceSet().getEObject(uriC1, false));
171
162
    if (isPersisted)
172
    if (isPersisted)
163
    {
173
    {
164
      assertDirty(c1, transaction);
174
      assertDirty(c1, transaction);
(-)src/org/eclipse/emf/cdo/tests/TransactionTest.java (-2 / +1 lines)
Lines 63-69 Link Here
63
    }
63
    }
64
  }
64
  }
65
65
66
  @SuppressWarnings("deprecation")
67
  public void testCreateManyTransactions() throws Exception
66
  public void testCreateManyTransactions() throws Exception
68
  {
67
  {
69
    msg("Opening session");
68
    msg("Opening session");
Lines 79-86 Link Here
79
      msg("Transaction " + i + "    (" + lastDuration + ")");
78
      msg("Transaction " + i + "    (" + lastDuration + ")");
80
      lastDuration = System.currentTimeMillis();
79
      lastDuration = System.currentTimeMillis();
81
      transaction = session.openTransaction();
80
      transaction = session.openTransaction();
82
      transaction.setUniqueResourceContents(false);
83
      resource = transaction.getResource("/test2");
81
      resource = transaction.getResource("/test2");
82
84
      Category category = getModel1Factory().createCategory();
83
      Category category = getModel1Factory().createCategory();
85
      resource.getContents().add(category);
84
      resource.getContents().add(category);
86
      transaction.commit();
85
      transaction.commit();
(-)src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246456_Test.java (-2 lines)
Lines 24-30 Link Here
24
 */
24
 */
25
public class Bugzilla_246456_Test extends AbstractCDOTest
25
public class Bugzilla_246456_Test extends AbstractCDOTest
26
{
26
{
27
  @SuppressWarnings("deprecation")
28
  public void testBugzilla_246456() throws Exception
27
  public void testBugzilla_246456() throws Exception
29
  {
28
  {
30
    msg("Opening session");
29
    msg("Opening session");
Lines 36-42 Link Here
36
        .setCapacityRevised(10);
35
        .setCapacityRevised(10);
37
    ((LRURevisionCache)((TwoLevelRevisionCache)transaction.getSession().getRevisionManager().getCache()).getLevel1())
36
    ((LRURevisionCache)((TwoLevelRevisionCache)transaction.getSession().getRevisionManager().getCache()).getLevel1())
38
        .setCapacityCurrent(10);
37
        .setCapacityCurrent(10);
39
    transaction.setUniqueResourceContents(false);
40
38
41
    msg("Creating resource");
39
    msg("Creating resource");
42
    CDOResource resource = transaction.createResource("/test1");
40
    CDOResource resource = transaction.createResource("/test1");
(-)src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java (+68 lines)
Added Link Here
1
package org.eclipse.emf.cdo.tests.bugzilla;
2
3
import org.eclipse.emf.cdo.CDOSession;
4
import org.eclipse.emf.cdo.CDOTransaction;
5
import org.eclipse.emf.cdo.eresource.CDOResource;
6
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
7
import org.eclipse.emf.cdo.tests.model1.Order;
8
import org.eclipse.emf.cdo.tests.model1.OrderDetail;
9
import org.eclipse.emf.cdo.tests.model1.Product1;
10
11
import org.eclipse.emf.common.util.EList;
12
import org.eclipse.emf.ecore.EObject;
13
14
/**
15
 * Resources fetched using CDOViewImpl.getResource(CDOID) not added to ResourceSet
16
 * <p>
17
 * See https://bugs.eclipse.org/251544
18
 * 
19
 * @author Simon McDuff
20
 */
21
public class Bugzilla_251544_Test extends AbstractCDOTest
22
{
23
  public void testFromPersistedToTransient() throws Exception
24
  {
25
    CDOSession session = openModel1Session();
26
    CDOTransaction transaction = session.openTransaction();
27
    CDOResource resource = transaction.createResource("/my/resource");
28
29
    Order order1 = getModel1Factory().createOrder();
30
    OrderDetail orderDetail = getModel1Factory().createOrderDetail();
31
    Product1 product = getModel1Factory().createProduct1();
32
    EList<EObject> contentList = resource.getContents();
33
    resource.getContents().add(order1);
34
    order1.getOrderDetails().add(orderDetail);
35
    orderDetail.setProduct(product);
36
37
    EList<OrderDetail> list = order1.getOrderDetails();
38
    // 
39
    resource.getContents().remove(0); // remove object by index
40
    list.remove(orderDetail);
41
    transaction.commit();
42
43
    resource.delete(null);
44
45
    assertSame(contentList, resource.getContents());
46
  }
47
48
  public void testFromTransientToPersisted() throws Exception
49
  {
50
    CDOSession session = openModel1Session();
51
    CDOTransaction transaction = session.openTransaction();
52
    CDOResource resource = transaction.createResource("/my/resource");
53
54
    Order order1 = getModel1Factory().createOrder();
55
    OrderDetail orderDetail = getModel1Factory().createOrderDetail();
56
    EList<OrderDetail> orderDetails = order1.getOrderDetails();
57
    order1.getOrderDetails().add(orderDetail);
58
59
    msg("Persist the graph");
60
    resource.getContents().add(order1);
61
    assertSame(orderDetails, order1.getOrderDetails());
62
    resource.getContents().remove(0); // remove object by index
63
    assertSame(orderDetails, order1.getOrderDetails());
64
    assertEquals(true, orderDetails.remove(orderDetail));
65
    transaction.commit();
66
  }
67
68
}

Return to bug 251544