summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-03-10 03:05:18 (EST)
committerCaspar De Groot2011-03-10 03:05:18 (EST)
commit9217e2c014d554effbfc46dd6f9cbe4821ec69c4 (patch)
treeb6973bb2d0ed14d39d50424d91704919835ecc59
parentff51b0e581a80d7ebace6145c1ce45182896a339 (diff)
downloadcdo-9217e2c014d554effbfc46dd6f9cbe4821ec69c4.zip
cdo-9217e2c014d554effbfc46dd6f9cbe4821ec69c4.tar.gz
cdo-9217e2c014d554effbfc46dd6f9cbe4821ec69c4.tar.bz2
[Bug 338884] CommitIntegrityCheck does not check inclusion of normal refTargets in NEW state
https://bugs.eclipse.org/bugs/show_bug.cgi?id=338884
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java40
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java61
2 files changed, 72 insertions, 29 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java
index b3f268c..ac30518 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_338884_Test.java
@@ -21,7 +21,12 @@ import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.util.CommitIntegrityException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+
import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author Caspar De Groot
@@ -121,4 +126,39 @@ public class Bugzilla_338884_Test extends AbstractCDOTest
tx.close();
session.close();
}
+
+ public void test_canHandleUnset() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ model4Factory factory = getModel4Factory();
+ ContainedElementNoOpposite dummy = factory.createContainedElementNoOpposite();
+ resource.getContents().add(dummy);
+
+ RefSingleNonContainedNPL referencer = factory.createRefSingleNonContainedNPL();
+ resource.getContents().add(referencer);
+
+ ContainedElementNoOpposite referencee = factory.createContainedElementNoOpposite();
+ resource.getContents().add(referencee);
+
+ referencer.setElement(referencee);
+
+ tx.commit();
+
+ EReference ref = getModel4Package().getRefSingleNonContainedNPL_Element();
+ referencer.eUnset(ref);
+
+ // Make the dummy object dirty to make the commit partial
+ dummy.setName("dirty");
+
+ Set<EObject> committables = new HashSet<EObject>();
+ committables.add(referencer);
+ committables.add(referencee);
+ tx.setCommittables(committables);
+ tx.commit();
+
+ session.close();
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
index fee33f3..cd534f1 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
@@ -228,40 +228,43 @@ public class CommitIntegrityCheck
}
}
}
- else if (containmentOrWithOpposite && featureDelta instanceof CDORemoveFeatureDelta)
+ else if (containmentOrWithOpposite)
{
- Object idOrObject = ((CDORemoveFeatureDelta)featureDelta).getValue();
- CDOID id = (CDOID)transaction.convertObjectToID(idOrObject);
- checkIncluded(id, "removed child/refTarget of", dirtyObject);
- }
- else if (containmentOrWithOpposite && featureDelta instanceof CDOClearFeatureDelta)
- {
- EStructuralFeature feat = ((CDOClearFeatureDelta)featureDelta).getFeature();
- InternalCDORevision cleanRev = transaction.getCleanRevisions().get(dirtyObject);
- int n = cleanRev.size(feat);
- for (int i = 0; i < n; i++)
+ if (featureDelta instanceof CDORemoveFeatureDelta)
{
- Object idOrObject = cleanRev.get(feat, i);
+ Object idOrObject = ((CDORemoveFeatureDelta)featureDelta).getValue();
CDOID id = (CDOID)transaction.convertObjectToID(idOrObject);
checkIncluded(id, "removed child/refTarget of", dirtyObject);
}
- }
- else if (containmentOrWithOpposite && featureDelta instanceof CDOUnsetFeatureDelta)
- {
- EStructuralFeature feat = ((CDOUnsetFeatureDelta)featureDelta).getFeature();
- InternalCDORevision cleanRev = transaction.getCleanRevisions().get(dirtyObject);
- Object idOrObject = cleanRev.getValue(feat);
- CDOID id = (CDOID)transaction.convertObjectToID(idOrObject);
- checkIncluded(id, "removed child/refTarget of", dirtyObject);
- }
- else if (containmentOrWithOpposite && featureDelta instanceof CDOMoveFeatureDelta)
- {
- // Nothing to do: a move doesn't affect the child being moved
- // so that child does not need to be included
- }
- else
- {
- throw new IllegalArgumentException("Unexpected delta type: " + featureDelta.getClass().getSimpleName());
+ else if (featureDelta instanceof CDOClearFeatureDelta)
+ {
+ EStructuralFeature feat = ((CDOClearFeatureDelta)featureDelta).getFeature();
+ InternalCDORevision cleanRev = transaction.getCleanRevisions().get(dirtyObject);
+ int n = cleanRev.size(feat);
+ for (int i = 0; i < n; i++)
+ {
+ Object idOrObject = cleanRev.get(feat, i);
+ CDOID id = (CDOID)transaction.convertObjectToID(idOrObject);
+ checkIncluded(id, "removed child/refTarget of", dirtyObject);
+ }
+ }
+ else if (featureDelta instanceof CDOUnsetFeatureDelta)
+ {
+ EStructuralFeature feat = ((CDOUnsetFeatureDelta)featureDelta).getFeature();
+ InternalCDORevision cleanRev = transaction.getCleanRevisions().get(dirtyObject);
+ Object idOrObject = cleanRev.getValue(feat);
+ CDOID id = (CDOID)transaction.convertObjectToID(idOrObject);
+ checkIncluded(id, "removed child/refTarget of", dirtyObject);
+ }
+ else if (featureDelta instanceof CDOMoveFeatureDelta)
+ {
+ // Nothing to do: a move doesn't affect the child being moved
+ // so that child does not need to be included
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unexpected delta type: " + featureDelta.getClass().getSimpleName());
+ }
}
}