|
|
@ -108,6 +108,12 @@ public abstract class SynchronizationProvider {
|
|
|
|
return synchronizer.isService();
|
|
|
|
return synchronizer.isService();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Check whether the synchronization request wants to only transmit
|
|
|
|
|
|
|
|
* one specific task. Returns null if this is not the case */
|
|
|
|
|
|
|
|
protected TaskIdentifier getSingleTaskForSync() {
|
|
|
|
|
|
|
|
return synchronizer.getSingleTaskForSync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Utility method for showing synchronization errors. If message is null,
|
|
|
|
/** Utility method for showing synchronization errors. If message is null,
|
|
|
|
* the contents of the throwable is displayed.
|
|
|
|
* the contents of the throwable is displayed.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -232,7 +238,7 @@ public abstract class SynchronizationProvider {
|
|
|
|
syncController.saveSyncMapping(mapping);
|
|
|
|
syncController.saveSyncMapping(mapping);
|
|
|
|
data.localIdToSyncMapping.put(taskId, mapping);
|
|
|
|
data.localIdToSyncMapping.put(taskId, mapping);
|
|
|
|
|
|
|
|
|
|
|
|
TaskProxy localTask = new TaskProxy(getId(), remoteId, false);
|
|
|
|
TaskProxy localTask = new TaskProxy(getId(), remoteId);
|
|
|
|
localTask.readFromTaskModel(task);
|
|
|
|
localTask.readFromTaskModel(task);
|
|
|
|
localTask.readTagsFromController(taskId, tagController, data.tags);
|
|
|
|
localTask.readTagsFromController(taskId, tagController, data.tags);
|
|
|
|
helper.pushTask(localTask, null, mapping);
|
|
|
|
helper.pushTask(localTask, null, mapping);
|
|
|
@ -264,8 +270,7 @@ public abstract class SynchronizationProvider {
|
|
|
|
|
|
|
|
|
|
|
|
// 3. UPDATE: for each updated local task
|
|
|
|
// 3. UPDATE: for each updated local task
|
|
|
|
for(SyncMapping mapping : data.localChanges) {
|
|
|
|
for(SyncMapping mapping : data.localChanges) {
|
|
|
|
TaskProxy localTask = new TaskProxy(getId(), mapping.getRemoteId(),
|
|
|
|
TaskProxy localTask = new TaskProxy(getId(), mapping.getRemoteId());
|
|
|
|
false);
|
|
|
|
|
|
|
|
TaskModelForSync task = taskController.fetchTaskForSync(
|
|
|
|
TaskModelForSync task = taskController.fetchTaskForSync(
|
|
|
|
mapping.getTask());
|
|
|
|
mapping.getTask());
|
|
|
|
localTask.readFromTaskModel(task);
|
|
|
|
localTask.readFromTaskModel(task);
|
|
|
@ -298,7 +303,7 @@ public abstract class SynchronizationProvider {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// re-fetch remote task
|
|
|
|
// re-fetch remote task
|
|
|
|
if(remoteConflict != null) {
|
|
|
|
if(remoteConflict != null || getSingleTaskForSync() != null) {
|
|
|
|
TaskProxy newTask = helper.refetchTask(remoteConflict);
|
|
|
|
TaskProxy newTask = helper.refetchTask(remoteConflict);
|
|
|
|
remoteTasks.remove(remoteConflict);
|
|
|
|
remoteTasks.remove(remoteConflict);
|
|
|
|
remoteTasks.add(newTask);
|
|
|
|
remoteTasks.add(newTask);
|
|
|
@ -441,7 +446,7 @@ public abstract class SynchronizationProvider {
|
|
|
|
|
|
|
|
|
|
|
|
public SyncData(Context context, LinkedList<TaskProxy> remoteTasks) {
|
|
|
|
public SyncData(Context context, LinkedList<TaskProxy> remoteTasks) {
|
|
|
|
// 1. get data out of the database
|
|
|
|
// 1. get data out of the database
|
|
|
|
mappings = synchronizer.getSyncController(context).getSyncMapping(getId());
|
|
|
|
mappings = synchronizer.getSyncController(context).getSyncMappings(getId());
|
|
|
|
activeTasks = synchronizer.getTaskController(context).getActiveTaskIdentifiers();
|
|
|
|
activeTasks = synchronizer.getTaskController(context).getActiveTaskIdentifiers();
|
|
|
|
allTasks = synchronizer.getTaskController(context).getAllTaskIdentifiers();
|
|
|
|
allTasks = synchronizer.getTaskController(context).getAllTaskIdentifiers();
|
|
|
|
tags = synchronizer.getTagController(context).getAllTagsAsMap();
|
|
|
|
tags = synchronizer.getTagController(context).getAllTagsAsMap();
|
|
|
@ -449,11 +454,8 @@ public abstract class SynchronizationProvider {
|
|
|
|
// 2. build helper data structures
|
|
|
|
// 2. build helper data structures
|
|
|
|
remoteIdToSyncMapping = new HashMap<String, SyncMapping>();
|
|
|
|
remoteIdToSyncMapping = new HashMap<String, SyncMapping>();
|
|
|
|
localIdToSyncMapping = new HashMap<TaskIdentifier, SyncMapping>();
|
|
|
|
localIdToSyncMapping = new HashMap<TaskIdentifier, SyncMapping>();
|
|
|
|
localChanges = new HashSet<SyncMapping>();
|
|
|
|
|
|
|
|
mappedTasks = new HashSet<TaskIdentifier>();
|
|
|
|
mappedTasks = new HashSet<TaskIdentifier>();
|
|
|
|
for(SyncMapping mapping : mappings) {
|
|
|
|
for(SyncMapping mapping : mappings) {
|
|
|
|
if(mapping.isUpdated())
|
|
|
|
|
|
|
|
localChanges.add(mapping);
|
|
|
|
|
|
|
|
remoteIdToSyncMapping.put(mapping.getRemoteId(), mapping);
|
|
|
|
remoteIdToSyncMapping.put(mapping.getRemoteId(), mapping);
|
|
|
|
localIdToSyncMapping.put(mapping.getTask(), mapping);
|
|
|
|
localIdToSyncMapping.put(mapping.getTask(), mapping);
|
|
|
|
mappedTasks.add(mapping.getTask());
|
|
|
|
mappedTasks.add(mapping.getTask());
|
|
|
@ -475,10 +477,21 @@ public abstract class SynchronizationProvider {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 4. build data structures of things to do
|
|
|
|
// 4. build data structures of things to do
|
|
|
|
newlyCreatedTasks = new HashSet<TaskIdentifier>(activeTasks);
|
|
|
|
if(getSingleTaskForSync() != null) {
|
|
|
|
newlyCreatedTasks.removeAll(mappedTasks);
|
|
|
|
newlyCreatedTasks = new HashSet<TaskIdentifier>();
|
|
|
|
deletedTasks = new HashSet<TaskIdentifier>(mappedTasks);
|
|
|
|
deletedTasks = new HashSet<TaskIdentifier>();
|
|
|
|
deletedTasks.removeAll(allTasks);
|
|
|
|
localChanges = new HashSet<SyncMapping>();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
newlyCreatedTasks = new HashSet<TaskIdentifier>(activeTasks);
|
|
|
|
|
|
|
|
newlyCreatedTasks.removeAll(mappedTasks);
|
|
|
|
|
|
|
|
deletedTasks = new HashSet<TaskIdentifier>(mappedTasks);
|
|
|
|
|
|
|
|
deletedTasks.removeAll(allTasks);
|
|
|
|
|
|
|
|
localChanges = new HashSet<SyncMapping>();
|
|
|
|
|
|
|
|
for(SyncMapping mapping : localIdToSyncMapping.values()) {
|
|
|
|
|
|
|
|
if(mapping.isUpdated())
|
|
|
|
|
|
|
|
localChanges.add(mapping);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -500,7 +513,8 @@ public abstract class SynchronizationProvider {
|
|
|
|
progressDialog.hide();
|
|
|
|
progressDialog.hide();
|
|
|
|
Resources r = context.getResources();
|
|
|
|
Resources r = context.getResources();
|
|
|
|
|
|
|
|
|
|
|
|
if(Preferences.shouldSuppressSyncDialogs(context)) {
|
|
|
|
if(Preferences.shouldSuppressSyncDialogs(context) ||
|
|
|
|
|
|
|
|
getSingleTaskForSync() != null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|