summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Velten2014-01-30 11:21:54 (EST)
committerEike Stepper2014-02-04 07:36:47 (EST)
commit1c12f3d456a9506590ca95655a404cf147112494 (patch)
tree7999fb33e2b8b2265ba80bdf625a4ad7e9451030
parent56da3a490941f60b7a80d2552cbb8ea31e6dbc5f (diff)
downloadcdo-1c12f3d456a9506590ca95655a404cf147112494.zip
cdo-1c12f3d456a9506590ca95655a404cf147112494.tar.gz
cdo-1c12f3d456a9506590ca95655a404cf147112494.tar.bz2
427244: Wrong behavior when moving an object of containment inside of the same resource (no CDOView attached)refs/changes/56/21456/2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=427244 Signed-off-by: Mathieu Velten <mathieu.velten@atos.net> Change-Id: Ia4ea30d0755dbe9b217e4c5609578fd27b290a51
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java37
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java4
2 files changed, 39 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java
index f1da645..a1c3a2a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ContainmentTest.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.model1.Address;
import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
import org.eclipse.emf.cdo.tests.model1.Order;
import org.eclipse.emf.cdo.tests.model1.Supplier;
import org.eclipse.emf.cdo.tests.model2.PersistentContainment;
@@ -40,6 +41,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
/**
* @author Eike Stepper
@@ -604,4 +606,39 @@ public class ContainmentTest extends AbstractCDOTest
transaction.commit();
}
+
+ public void testContainmentChangeInSameResource()
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("model1", new Resource.Factory()
+ {
+ public Resource createResource(URI uri)
+ {
+ return new XMIResourceImpl(uri)
+ {
+ @Override
+ protected boolean useUUIDs()
+ {
+ return true;
+ }
+ };
+ }
+ });
+
+ Category category1 = Model1Factory.eINSTANCE.createCategory();
+ Category category2 = Model1Factory.eINSTANCE.createCategory();
+
+ Company company = Model1Factory.eINSTANCE.createCompany();
+ company.getCategories().add(category1);
+ company.getCategories().add(category2);
+
+ Resource resource = resourceSet.createResource(URI.createURI("test.model1", true));
+ resource.getContents().add(company);
+
+ String originalID = resource.getURIFragment(category2);
+
+ // Change object of containment feature
+ category1.getCategories().add(category2);
+ assertEquals("The id of the object changed while it should not", originalID, resource.getURIFragment(category2));
+ }
}
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 a37ddb7..df53af0 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
@@ -765,7 +765,7 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
: null;
boolean moved = oldView != null && oldView == newView;
- if (!moved && oldResource != null && !isResourceRoot)
+ if (!moved && oldResource != null && oldResource != newResource && !isResourceRoot)
{
oldResource.detached(this);
}
@@ -773,7 +773,7 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
int oldContainerFeatureID = eContainerFeatureID();
eBasicSetContainer(newContainer, newContainerFeatureID);
- if (!moved && oldResource != newResource && newResource != null)
+ if (!moved && newResource != null && newResource != oldResource)
{
newResource.attached(this);
}