Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-02-24 02:52:57 -0500
committerEike Stepper2012-02-24 02:52:57 -0500
commita9bf83c5515f541052263dfc1f814c74fedb1c6f (patch)
treeea4f3807340e0456b69baf50aabc5a6c21f3acd2
parentff7a10f6271cfd3ff7ace8c5c6ff63fda0e3616b (diff)
downloadcdo-a9bf83c5515f541052263dfc1f814c74fedb1c6f.tar.gz
cdo-a9bf83c5515f541052263dfc1f814c74fedb1c6f.tar.xz
cdo-a9bf83c5515f541052263dfc1f814c74fedb1c6f.zip
372307: [Legacy] eContainer changes not properly propagated
https://bugs.eclipse.org/bugs/show_bug.cgi?id=372307
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_372307_Test.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java215
3 files changed, 135 insertions, 95 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_372307_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_372307_Test.java
index a39d8fda0c..e0f0299a35 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_372307_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_372307_Test.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EReference;
/**
* @author Steve Monnier
@@ -77,6 +78,11 @@ public class Bugzilla_372307_Test extends AbstractCDOTest
id1 = CDOUtil.getCDOObject(session1d.eContainer()).cdoID();
id2 = CDOUtil.getCDOObject(session2d.eContainer()).cdoID();
assertEquals("Container of D should have the same CDOID in both sessions", id1, id2);
+
+ // Validate that the containment feature of D on both sessions are not null, and equal
+ EReference ownedDs_Feature = getModel6Package().getA_OwnedDs();
+ assertEquals(ownedDs_Feature, session1d.eContainmentFeature());
+ assertEquals(ownedDs_Feature, session2d.eContainmentFeature());
}
public void testMoveElementToOtherContainerSingleValued() throws Exception
@@ -109,5 +115,10 @@ public class Bugzilla_372307_Test extends AbstractCDOTest
C session2d = transaction2.getObject(session1d);
assertEquals(CDOUtil.getCDOObject(session1a2).cdoID(), CDOUtil.getCDOObject(session2d.eContainer()).cdoID());
+
+ // Validate that the containment feature of D on both sessions are not null, and equal
+ EReference ownedC_Feature = getModel6Package().getB_OwnedC();
+ assertEquals(ownedC_Feature, session1d.eContainmentFeature());
+ assertEquals(ownedC_Feature, session2d.eContainmentFeature());
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index 3fcac5abf7..8cefd5b31d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -1013,7 +1013,9 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
else
{
- cdoStore().setContainer(this, cdoDirectResource(), newEContainer, newContainerFeatureID);
+ CDOResource directResource = cdoDirectResource();
+ CDOStore store = cdoStore();
+ store.setContainer(this, directResource, newEContainer, newContainerFeatureID);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java
index 3e8022a6a7..43d73c115f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java
@@ -88,7 +88,6 @@ public class CDOLegacyAdapter extends CDOLegacyWrapper implements Adapter.Intern
return;
}
- CDOStore store = view.getStore();
if (EMFUtil.isPersistent(feature))
{
int eventType = msg.getEventType();
@@ -99,130 +98,158 @@ public class CDOLegacyAdapter extends CDOLegacyWrapper implements Adapter.Intern
switch (eventType)
{
case Notification.SET:
- {
- store.set(instance, feature, position, newValue);
- if (feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- if (oldValue != null)
- {
- InternalEObject oldChild = (InternalEObject)oldValue;
- setContainer(store, oldChild, null, 0);
- }
-
- if (newValue != null)
- {
- InternalEObject newChild = (InternalEObject)newValue;
- setContainer(store, newChild, this, reference.getFeatureID());
- }
- }
- }
-
+ notifySet(feature, position, oldValue, newValue);
break;
- }
case Notification.UNSET:
- {
- if (feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- @SuppressWarnings("unchecked")
- List<Object> list = (List<Object>)oldValue;
- for (Object child : list)
- {
- if (child != null)
- {
- setContainer(store, (InternalEObject)child, null, 0);
- }
- }
- }
- }
-
- store.unset(instance, feature);
+ notifyUnset(feature, oldValue);
break;
- }
case Notification.MOVE:
- store.move(instance, feature, position, (Integer)oldValue);
+ notifyMove(feature, position, oldValue);
break;
case Notification.ADD:
- store.add(instance, feature, position, newValue);
- if (newValue != null && feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- InternalEObject newChild = (InternalEObject)newValue;
- setContainer(store, newChild, this, reference.getFeatureID());
- }
- }
-
+ notifyAdd(feature, position, newValue);
break;
case Notification.ADD_MANY:
- {
- int pos = position;
- @SuppressWarnings("unchecked")
- List<Object> list = (List<Object>)newValue;
- for (Object object : list)
- {
- store.add(instance, feature, pos++, object);
- if (object != null && feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- InternalEObject newChild = (InternalEObject)object;
- setContainer(store, newChild, this, reference.getFeatureID());
- }
- }
- }
+ notifyAddMany(feature, position, newValue);
+ break;
+
+ case Notification.REMOVE:
+ notifyRemove(feature, position);
+ break;
+ case Notification.REMOVE_MANY:
+ notifyRemoveMany(feature, oldValue);
break;
}
- case Notification.REMOVE:
+ // Align Container for bidirectional references because this is not set in the store. See Bugzilla_246622_Test
+ instanceToRevisionContainment();
+ }
+ }
+
+ protected void notifySet(EStructuralFeature feature, int position, Object oldValue, Object newValue)
+ {
+ CDOStore store = view.getStore();
+ store.set(instance, feature, position, newValue);
+ if (feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
{
- InternalEObject oldChild = (InternalEObject)store.remove(instance, feature, position);
- if (oldChild != null && feature instanceof EReference)
+ if (oldValue != null)
{
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- setContainer(store, oldChild, null, 0);
- }
+ InternalEObject oldChild = (InternalEObject)oldValue;
+ setContainer(store, oldChild, null, 0);
+ }
+
+ if (newValue != null)
+ {
+ InternalEObject newChild = (InternalEObject)newValue;
+ setContainer(store, newChild, this, reference.getFeatureID());
}
- break;
}
+ }
+ }
- case Notification.REMOVE_MANY:
+ protected void notifyUnset(EStructuralFeature feature, Object oldValue)
+ {
+ CDOStore store = view.getStore();
+ if (feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
{
@SuppressWarnings("unchecked")
List<Object> list = (List<Object>)oldValue;
- for (int i = list.size() - 1; i >= 0; --i)
+ for (Object child : list)
{
- InternalEObject oldChild = (InternalEObject)store.remove(instance, feature, i);
- if (oldChild != null && feature instanceof EReference)
+ if (child != null)
{
- EReference reference = (EReference)feature;
- if (reference.isContainment())
- {
- setContainer(store, oldChild, null, 0);
- }
+ setContainer(store, (InternalEObject)child, null, 0);
}
}
+ }
+ }
- break;
+ store.unset(instance, feature);
+ }
+
+ protected void notifyMove(EStructuralFeature feature, int position, Object oldValue)
+ {
+ CDOStore store = view.getStore();
+ store.move(instance, feature, position, (Integer)oldValue);
+ }
+
+ protected void notifyAdd(EStructuralFeature feature, int position, Object newValue)
+ {
+ CDOStore store = view.getStore();
+ store.add(instance, feature, position, newValue);
+ if (newValue != null && feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
+ {
+ InternalEObject newChild = (InternalEObject)newValue;
+ setContainer(store, newChild, this, reference.getFeatureID());
+ }
+ }
+ }
+
+ protected void notifyAddMany(EStructuralFeature feature, int position, Object newValue)
+ {
+ CDOStore store = view.getStore();
+ int pos = position;
+ @SuppressWarnings("unchecked")
+ List<Object> list = (List<Object>)newValue;
+ for (Object object : list)
+ {
+ store.add(instance, feature, pos++, object);
+ if (object != null && feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
+ {
+ InternalEObject newChild = (InternalEObject)object;
+ setContainer(store, newChild, this, reference.getFeatureID());
+ }
}
+ }
+ }
+
+ protected void notifyRemove(EStructuralFeature feature, int position)
+ {
+ CDOStore store = view.getStore();
+ InternalEObject oldChild = (InternalEObject)store.remove(instance, feature, position);
+ if (oldChild != null && feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
+ {
+ setContainer(store, oldChild, null, 0);
}
+ }
+ }
- // Align Container for bidirectional references because this is not set in the store. See Bugzilla_246622_Test
- instanceToRevisionContainment();
+ protected void notifyRemoveMany(EStructuralFeature feature, Object oldValue)
+ {
+ CDOStore store = view.getStore();
+ @SuppressWarnings("unchecked")
+ List<Object> list = (List<Object>)oldValue;
+ for (int i = list.size() - 1; i >= 0; --i)
+ {
+ InternalEObject oldChild = (InternalEObject)store.remove(instance, feature, i);
+ if (oldChild != null && feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isContainment())
+ {
+ setContainer(store, oldChild, null, 0);
+ }
+ }
}
}
@@ -240,7 +267,7 @@ public class CDOLegacyAdapter extends CDOLegacyWrapper implements Adapter.Intern
return;
}
- store.setContainer(object, null, container, containingFeatureID);
+ store.setContainer(object, null, container, InternalEObject.EOPPOSITE_FEATURE_BASE - containingFeatureID);
}
/**

Back to the top