From 7c7f23708b2ea073fee2162421c8db98f55f8603 Mon Sep 17 00:00:00 2001 From: Steffen Pingel Date: Sun, 12 May 2013 14:35:21 -0700 Subject: 202967: [discussion] document synchronization scenarios Change-Id: I477aaa9ce5caf3cab2e9ff5226cf9cb2f4f265b8 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=202967 --- .../tasks/core/AbstractRepositoryConnector.java | 84 +++++++++++++++++++++- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java index 1055b566b..11d95441a 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java @@ -38,9 +38,70 @@ import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession; * + *

Synchronization

+ *

+ * The tasks framework has a notion of synchronization for keeping a local cache of tasks synchronized with repository + * state. Synchronization are anchored around queries which brings in tasks from the repository based on search + * criteria. A synchronization has several stages: + *

    + *
  1. Identify stale tasks (optional): {@link #preSynchronization(ISynchronizationSession, IProgressMonitor)} + *
  2. Perform each query: + * {@link #performQuery(TaskRepository, IRepositoryQuery, TaskDataCollector, ISynchronizationSession, IProgressMonitor)} + *
  3. Check each retrieved task if it is stale: {@link #hasTaskChanged(TaskRepository, ITask, TaskData)} + *
  4. Update cached state: {@link #updateTaskFromTaskData(TaskRepository, ITask, TaskData)} + *
  5. For each stale task: {@link #getTaskData(TaskRepository, String, IProgressMonitor)} + *
  6. Update cached state: {@link #updateTaskFromTaskData(TaskRepository, ITask, TaskData)} + *
  7. Persist synchronization state (optional): {@link #postSynchronization(ISynchronizationSession, IProgressMonitor)} + *
+ *

+ * Connectors can implement these methods in several ways depending on APIs provided by the repository. In order to + * ensure correct synchronization it is important that the method interaction follows one of the contracts specified + * below. + *

+ * Methods denoted as optional above are required to synchronize tasks not contained in queries. See + * {@link #preSynchronization(ISynchronizationSession, IProgressMonitor)} and + * {@link ISynchronizationSession#markStale(ITask)} for more details. + *

+ *

Full data synchronization

+ * + *

Stale tasks are managed on a per repository basis

+ * + *

Stale tasks are managed on a per task basis

+ * + *

Partial data synchronization only

+ * * * @author Mik Kersten @@ -300,7 +361,13 @@ public abstract class AbstractRepositoryConnector { } /** + * Returns true, if the state in taskData is different than the state stored in + * task. + *

+ * See {@link AbstractRepositoryConnector} for more details how this method interacts with other methods. + * * @since 3.0 + * @see #updateTaskFromTaskData(TaskRepository, ITask, TaskData) */ public abstract boolean hasTaskChanged(TaskRepository taskRepository, ITask task, TaskData taskData); @@ -360,6 +427,8 @@ public abstract class AbstractRepositoryConnector { * does not return the full task data for a result, {@link TaskData#isPartial()} will return true. *

* Implementors must complete executing query before returning from this method. + *

+ * See {@link AbstractRepositoryConnector} for more details how this method interacts with other methods. * * @param repository * task repository to run query against @@ -405,6 +474,8 @@ public abstract class AbstractRepositoryConnector { /** * Hook into the synchronization process. + *

+ * See {@link AbstractRepositoryConnector} for more details how this method interacts with other methods. * * @since 3.0 */ @@ -446,6 +517,13 @@ public abstract class AbstractRepositoryConnector { } /** + * Updates task based on the state in taskData. {@link TaskMapper#applyTo(ITask)} can be + * used to map common attributes. + *

+ * See {@link AbstractRepositoryConnector} for more details how this method interacts with other methods. + * + * @see #hasTaskChanged(TaskRepository, ITask, TaskData) + * @see TaskMapper#applyTo(ITask) * @since 3.0 */ public abstract void updateTaskFromTaskData(TaskRepository taskRepository, ITask task, TaskData taskData); -- cgit v1.2.3