Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2014-05-31 16:43:26 +0000
committerEsteban DUGUEPEROUX2014-09-03 07:39:51 +0000
commitecd17c2fb40964753e94c14f35c5a873cdd043ed (patch)
tree35f81c7d6d29292242cda269159a6c90bb9e2c9c /plugins
parente3e8d94e474188b763fcdb40a5c06ab7a8d9c227 (diff)
downloadcdo-ecd17c2fb40964753e94c14f35c5a873cdd043ed.tar.gz
cdo-ecd17c2fb40964753e94c14f35c5a873cdd043ed.tar.xz
cdo-ecd17c2fb40964753e94c14f35c5a873cdd043ed.zip
[435532] Reordering elements in a containment feature causes DBException when audit mode is activated
https://bugs.eclipse.org/bugs/show_bug.cgi?id=435532 - enhanced test case - fixed bug (related to positive/negative offset) Change-Id: I1974c1b6d9344efdac5e9d25e2192cb5f18289b3 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=435532
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_435532_Test.java15
2 files changed, 25 insertions, 9 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
index 96130b4cfd..ae911bda37 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
@@ -304,6 +304,15 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
visitor.postProcess(accessor, id);
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Result to be written to DB:");
+ for (ManipulationElement e : visitor.manipulations)
+ {
+ TRACER.trace(e.toString());
+ }
+ }
+
// finally, write results to the database
visitor.writeResultToDatabase(accessor, id);
@@ -645,7 +654,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
if (TRACER.isEnabled())
{
- TRACER.trace("New offset = " + -offsetAfter); //$NON-NLS-1$
+ TRACER.trace("New offset = " + offsetAfter); //$NON-NLS-1$
}
applyOffsetToDestinationIndexes(offsetAfter);
@@ -695,7 +704,9 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
}
}
- return bestOffset;
+ // the offset which has occurred the most has to be applied negatively to normalize the list
+ // therefore return the negative offset as the new offset to be applied
+ return -bestOffset;
}
private void applyOffsetToSourceIndexes(int offsetBefore)
@@ -715,8 +726,8 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
{
if (element.destinationIndex != ManipulationConstants.NO_INDEX)
{
- // substract the offset from all indices to make them relative to the new offset
- element.destinationIndex -= offsetAfter;
+ // apply the offset to all indices to make them relative to the new offset
+ element.destinationIndex += offsetAfter;
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_435532_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_435532_Test.java
index c24809437b..bd8aaffa19 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_435532_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_435532_Test.java
@@ -69,7 +69,7 @@ public class Bugzilla_435532_Test extends AbstractCDOTest
*/
public void testDragChildrenAtListEnd() throws ConcurrentAccessException, CommitException
{
- doTestDragChildren(CHILDREN_NUMBER - 1);
+ doTestDragChildren(20, CHILDREN_NUMBER - 1);
}
/**
@@ -77,14 +77,19 @@ public class Bugzilla_435532_Test extends AbstractCDOTest
*/
public void testDragChildrenAtListBegin() throws ConcurrentAccessException, CommitException
{
- doTestDragChildren(0);
+ doTestDragChildren(20, 0);
}
- private void doTestDragChildren(int newPosition) throws ConcurrentAccessException, CommitException
+ public void testDragChildrenFromEndToBegin() throws ConcurrentAccessException, CommitException
+ {
+ doTestDragChildren(CHILDREN_NUMBER - CHILDREN_TO_MOVE_NUMBER - 1, 0);
+ }
+
+ private void doTestDragChildren(int oldPosition, int newPosition) throws ConcurrentAccessException, CommitException
{
// Step 1: get children to move
- List<Category> childrenToMove = new ArrayList<Category>(root.getCategories().subList(20,
- 20 + CHILDREN_TO_MOVE_NUMBER));
+ List<Category> childrenToMove = new ArrayList<Category>(root.getCategories().subList(oldPosition,
+ oldPosition + CHILDREN_TO_MOVE_NUMBER));
List<CDOID> childrenToMoveIds = new ArrayList<CDOID>();
for (Category child : childrenToMove)
{

Back to the top