Revision: 3977
Author: [email protected]
Date: Fri Nov  5 14:53:21 2010
Log: Updated the conflict resolver as retrying a change multiple times was previously adding in the change to the persister listener multiple times.
http://code.google.com/p/power-architect/source/detail?r=3977

Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectNetworkConflictResolver.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectNetworkConflictResolver.java Mon Oct 18 08:17:49 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectNetworkConflictResolver.java Fri Nov 5 14:53:21 2010
@@ -23,6 +23,7 @@
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;

 import org.apache.http.client.HttpClient;
@@ -38,8 +39,8 @@
 import ca.sqlpower.dao.PersistedSPOProperty;
 import ca.sqlpower.dao.PersistedSPObject;
 import ca.sqlpower.dao.RemovedObjectEntry;
-import ca.sqlpower.dao.SPPersister.DataType;
 import ca.sqlpower.dao.SPSessionPersister;
+import ca.sqlpower.dao.SPPersister.DataType;
 import ca.sqlpower.dao.json.SPJSONMessageDecoder;
 import ca.sqlpower.enterprise.AbstractNetworkConflictResolver;
 import ca.sqlpower.enterprise.JSONMessage;
@@ -52,6 +53,7 @@
 import ca.sqlpower.util.UserPrompterFactory.UserPromptType;

 import com.enterprisedt.util.debug.Logger;
+import com.google.common.collect.LinkedListMultimap;
 import com.google.common.collect.Multimap;

public class ArchitectNetworkConflictResolver extends AbstractNetworkConflictResolver implements MessageSender<JSONObject> {
@@ -146,7 +148,7 @@
currentWaitPerPersist = currentWaitPerPersist * 0.9 + processTimePerObj * 0.1;
                 }
             } else {
- // Did not successfully post json, we must update ourselves, and then try again if we can. + // Did not successfully post json, we must update ourselves, and then try again if we can.
                 if (!reflush) {
// These lists should reflect the state of the workspace at the time of the conflict. // The workspace could be updated several times before a successful post is made.
@@ -156,7 +158,7 @@
                 try {
SPSessionPersister.undoForSession(session.getWorkspace(), new LinkedList<PersistedSPObject>(outboundObjectsToAdd.values()),
-                            outboundPropertiesToChange,
+ LinkedListMultimap.create(outboundPropertiesToChange), new LinkedList<RemovedObjectEntry>(outboundObjectsToRemove.values()), converter);
                 } catch (Exception e) {
throw new RuntimeException("Reflush failed on rollback", e);
@@ -189,9 +191,13 @@
                 if (conflicts.size() == 0) {
// Try to return the persisted objects to their state pre-update.
                     try {
+                        listener.clear();
+ for (Map.Entry<String, PersistedSPObject> entry : outboundObjectsToAdd.entrySet()) {
+                            entry.getValue().setLoaded(false);
+                        }
                         SPSessionPersister.redoForSession(getWorkspace(),
new LinkedList<PersistedSPObject>(outboundObjectsToAdd.values()),
-                                outboundPropertiesToChange,
+ LinkedListMultimap.create(outboundPropertiesToChange), new LinkedList<RemovedObjectEntry>(outboundObjectsToRemove.values()), converter); // We want to re-send our changes, but only if we were able to restore them
                         flush(true);

Reply via email to