Merge branch 'master' of ssh://git.eclipse.org/gitroot/emf-store/org.eclipse.emf.emfstore.core
diff --git a/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/OperationManager.java b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/OperationManager.java
index c4d2483..e36e769 100644
--- a/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/OperationManager.java
+++ b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/OperationManager.java
@@ -51,7 +51,7 @@
* the project space the operation manager should be attached to
*/
public OperationManager(ProjectSpaceBase projectSpace) {
- operationRecorder = new OperationRecorder(projectSpace, projectSpace.getProject().getChangeNotifier());
+ operationRecorder = new OperationRecorder(projectSpace);
operationRecorder.addOperationRecorderListener(this);
operationListeners = new ArrayList<OperationObserver>();
configureOperationRecorder();
diff --git a/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/OperationRecorder.java b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/OperationRecorder.java
index 5b0e888..002b67f 100644
--- a/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/OperationRecorder.java
+++ b/bundles/org.eclipse.emf.emfstore.client/src/org/eclipse/emf/emfstore/internal/client/model/impl/OperationRecorder.java
@@ -48,12 +48,12 @@
import org.eclipse.emf.emfstore.internal.client.model.changeTracking.notification.filter.FilterStack;
import org.eclipse.emf.emfstore.internal.client.model.changeTracking.notification.recording.NotificationRecorder;
import org.eclipse.emf.emfstore.internal.client.model.exceptions.MissingCommandException;
+import org.eclipse.emf.emfstore.internal.client.model.impl.api.ESLocalProjectImpl;
import org.eclipse.emf.emfstore.internal.client.model.util.WorkspaceUtil;
import org.eclipse.emf.emfstore.internal.common.model.IdEObjectCollection;
import org.eclipse.emf.emfstore.internal.common.model.ModelElementId;
import org.eclipse.emf.emfstore.internal.common.model.Project;
import org.eclipse.emf.emfstore.internal.common.model.impl.IdEObjectCollectionImpl;
-import org.eclipse.emf.emfstore.internal.common.model.util.EObjectChangeNotifier;
import org.eclipse.emf.emfstore.internal.common.model.util.IdEObjectCollectionChangeObserver;
import org.eclipse.emf.emfstore.internal.common.model.util.ModelUtil;
import org.eclipse.emf.emfstore.internal.common.model.util.NotificationInfo;
@@ -97,7 +97,6 @@
private ProjectSpaceBase projectSpace;
private IdEObjectCollectionImpl collection;
- private EObjectChangeNotifier changeNotifier;
private boolean isRecording;
private boolean commandIsRunning;
@@ -109,14 +108,11 @@
*
* @param projectSpace
* the {@link ProjectSpaceBase} the recorder should be attached to
- * @param changeNotifier
- * a change notifier that informs clients about changes in the collection
*/
// TODO: provide ext. point for rollBackInCaseOfCommandFailure
- public OperationRecorder(ProjectSpaceBase projectSpace, EObjectChangeNotifier changeNotifier) {
+ public OperationRecorder(ProjectSpaceBase projectSpace) {
this.projectSpace = projectSpace;
this.collection = (IdEObjectCollectionImpl) projectSpace.getProject();
- this.changeNotifier = changeNotifier;
operations = new ArrayList<AbstractOperation>();
observers = new ArrayList<OperationRecorderListener>();
@@ -124,6 +120,8 @@
config = new OperationRecorderConfig();
converter = new NotificationToOperationConverter(collection);
+
+ ESWorkspaceProviderImpl.getObserverBus().register(this);
}
/**
@@ -987,7 +985,7 @@
}
private void clearAllocatedCaches(ESLocalProject project) {
- if (project.equals(collection)) {
+ if (((ESLocalProjectImpl) project).toInternalAPI().getProject().equals(collection)) {
collection.forceClearAllocatedCaches();
}
}
diff --git a/tests/org.eclipse.emf.emfstore.client.test/src/org/eclipse/emf/emfstore/client/test/changeTracking/recording/AllocateIdsPolicyTest.java b/tests/org.eclipse.emf.emfstore.client.test/src/org/eclipse/emf/emfstore/client/test/changeTracking/recording/AllocateIdsPolicyTest.java
index 2539875..8d3398a 100644
--- a/tests/org.eclipse.emf.emfstore.client.test/src/org/eclipse/emf/emfstore/client/test/changeTracking/recording/AllocateIdsPolicyTest.java
+++ b/tests/org.eclipse.emf.emfstore.client.test/src/org/eclipse/emf/emfstore/client/test/changeTracking/recording/AllocateIdsPolicyTest.java
@@ -11,17 +11,24 @@
package org.eclipse.emf.emfstore.client.test.changeTracking.recording;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
import java.util.concurrent.Callable;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.emfstore.bowling.BowlingFactory;
import org.eclipse.emf.emfstore.bowling.Game;
import org.eclipse.emf.emfstore.bowling.Matchup;
-import org.eclipse.emf.emfstore.client.test.WorkspaceTest;
+import org.eclipse.emf.emfstore.client.test.server.ServerTests;
+import org.eclipse.emf.emfstore.client.test.testmodel.TestElement;
import org.eclipse.emf.emfstore.client.util.RunESCommand;
import org.eclipse.emf.emfstore.internal.common.model.ModelElementId;
-import org.eclipse.emf.emfstore.internal.common.model.Project;
+import org.eclipse.emf.emfstore.internal.common.model.impl.IdEObjectCollectionImpl;
+import org.eclipse.emf.emfstore.server.exceptions.ESException;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -30,7 +37,43 @@
* @author jsommerfeldt
*
*/
-public class AllocateIdsPolicyTest extends WorkspaceTest {
+public class AllocateIdsPolicyTest extends ServerTests {
+
+ private IdEObjectCollectionImpl collection;
+
+ /**
+ * Set up collection.
+ */
+ @Before
+ public void initCollection() {
+ collection = ((IdEObjectCollectionImpl) getProject());
+ }
+
+ /**
+ * Check clear after server actions.
+ *
+ * @throws ESException if there is a problem during a server action.
+ */
+ @SuppressWarnings("restriction")
+ @Test
+ public void clearAfterServerActionWithAlwaysIdAllocation() throws ESException {
+ collection.setAlwaysIdAllocation(true);
+ TestElement element = getTestElement();
+
+ addRemoveObject(element);
+ getProjectSpace().commit(new NullProgressMonitor());
+ assertNull(collection.getDeletedModelElementId(element));
+
+ addRemoveObject(element);
+ getProjectSpace().shareProject(new NullProgressMonitor());
+ assertNull(collection.getDeletedModelElementId(element));
+ }
+
+ private void addRemoveObject(EObject object) {
+ collection.addModelElement(object);
+ collection.deleteModelElement(object);
+ assertNotNull(collection.getDeletedModelElementId(object));
+ }
/**
* Test using the always id allocation policy.
@@ -60,28 +103,27 @@
* @param comparator The {@link IdComparator} to compare ids.
*/
public void removeAddWithCommand(boolean alwaysIdAllocation, IdComparator comparator) {
- final Project project = getProject();
- project.setAlwaysIdAllocation(alwaysIdAllocation);
+ collection.setAlwaysIdAllocation(alwaysIdAllocation);
final Matchup matchup = BowlingFactory.eINSTANCE.createMatchup();
Game game = BowlingFactory.eINSTANCE.createGame();
- project.addModelElement(matchup);
- ModelElementId matchupId1 = project.getModelElementId(matchup);
+ collection.addModelElement(matchup);
+ ModelElementId matchupId1 = collection.getModelElementId(matchup);
matchup.getGames().add(game);
- ModelElementId gameId1 = project.getModelElementId(game);
+ ModelElementId gameId1 = collection.getModelElementId(game);
// remove and add matchup in different commands
RunESCommand.run(new Callable<Void>() {
public Void call() throws Exception {
- project.deleteModelElement(matchup);
- project.addModelElement(matchup);
+ collection.deleteModelElement(matchup);
+ collection.addModelElement(matchup);
return null;
}
});
- comparator.compare(matchupId1, project.getModelElementId(matchup));
- comparator.compare(gameId1, project.getModelElementId(game));
+ comparator.compare(matchupId1, collection.getModelElementId(matchup));
+ comparator.compare(gameId1, collection.getModelElementId(game));
}
/**
@@ -92,34 +134,33 @@
*/
public void removeAddWithCommands(boolean alwaysIdAllocation, IdComparator comparator) {
- final Project project = getProject();
- project.setAlwaysIdAllocation(alwaysIdAllocation);
+ collection.setAlwaysIdAllocation(alwaysIdAllocation);
final Matchup matchup = BowlingFactory.eINSTANCE.createMatchup();
Game game = BowlingFactory.eINSTANCE.createGame();
- project.addModelElement(matchup);
- ModelElementId matchupId1 = project.getModelElementId(matchup);
+ collection.addModelElement(matchup);
+ ModelElementId matchupId1 = collection.getModelElementId(matchup);
matchup.getGames().add(game);
- ModelElementId gameId1 = project.getModelElementId(game);
+ ModelElementId gameId1 = collection.getModelElementId(game);
// remove and add matchup in different commands
RunESCommand.run(new Callable<Void>() {
public Void call() throws Exception {
- project.deleteModelElement(matchup);
+ collection.deleteModelElement(matchup);
return null;
}
});
RunESCommand.run(new Callable<Void>() {
public Void call() throws Exception {
- project.addModelElement(matchup);
+ collection.addModelElement(matchup);
return null;
}
});
- comparator.compare(matchupId1, project.getModelElementId(matchup));
- comparator.compare(gameId1, project.getModelElementId(game));
+ comparator.compare(matchupId1, collection.getModelElementId(matchup));
+ comparator.compare(gameId1, collection.getModelElementId(game));
}
/**
@@ -129,21 +170,20 @@
* @param comparator The {@link IdComparator} to compare ids.
*/
public void removeAddWithoutCommand(boolean alwaysIdAllocation, IdComparator comparator) {
- Project project = getProject();
- project.setAlwaysIdAllocation(alwaysIdAllocation);
+ collection.setAlwaysIdAllocation(alwaysIdAllocation);
Matchup matchup = BowlingFactory.eINSTANCE.createMatchup();
Game game = BowlingFactory.eINSTANCE.createGame();
- project.addModelElement(matchup);
- ModelElementId matchupId1 = project.getModelElementId(matchup);
+ collection.addModelElement(matchup);
+ ModelElementId matchupId1 = collection.getModelElementId(matchup);
matchup.getGames().add(game);
- ModelElementId gameId1 = project.getModelElementId(game);
+ ModelElementId gameId1 = collection.getModelElementId(game);
// remove and add matchup without command
- project.deleteModelElement(matchup);
- project.addModelElement(matchup);
+ collection.deleteModelElement(matchup);
+ collection.addModelElement(matchup);
- comparator.compare(matchupId1, project.getModelElementId(matchup));
- comparator.compare(gameId1, project.getModelElementId(game));
+ comparator.compare(matchupId1, collection.getModelElementId(matchup));
+ comparator.compare(gameId1, collection.getModelElementId(game));
}
/**